ember.jsoverridingacceptance-testingember-cli-mirage

Override mirage response in Acceptance tests?


In our Ember app [v.2.14], we're using mirage to mock our APIs and have provided the direct response for our model 'car'

mirage/config.js:

 this.get('/cars', () => {
 return {
  "data": {
    "type": "car",
    "id": "1",
    "attributes": {
     "exists" : true
    }
   }
 }

In our acceptance tests, I want to override this.
I understand that using factories and fixtures we can feed the mirage store which CAN be overridden in the tests using server.create().
It doesn't work though when I am providing the direct response as above. Any clues if it can be done?


Solution

  • Yes, it can be done. You’d need to use server.get() in your acceptance test, but things should work fine.

    If you still have trouble, if you post your code that isn’t working in your test we can take a look.