Pretender does not catch call when mock is not define - ERROR : "The adapter operation was aborted"
victorsmits opened this issue · 0 comments
victorsmits commented
Hello, We have installed the addon on our application to be able to mock all queries during testing, however when we make a mistake like missing a mock for a call the test runner freeze and in the console we can find the following error. This issue does not appear when we made no error in the test.
And in the network we can see that a call has been made
Our application is built around 3 API, so we have made 3 stores the first one is the default ember store, the 2 others extend the default ember store, and we set a specific adapter for those stores
Here is an example of the implementation
import Store from '@ember-data/store';
import { getOwner } from '@ember/application';
export default class TmsService extends Store {
// adapter = oms;
adapterFor(modelName) {
let owner = getOwner(this);
return owner.lookup(`adapter:tms`);
}
}
import config from 'sbo-connect-ui/config/environment';
import ApplicationAdapter from './application';
export default class TmsAdapter extends ApplicationAdapter {
host = config.api.tms;
}
import ActiveModelAdapter from 'active-model-adapter';
import { inject as service } from '@ember/service';
import config from 'sbo-connect-ui/config/environment';
export default class ApplicationAdapter extends ActiveModelAdapter {
host = config.api.connect;
@service currentUser;
ajax(url, method, hash) {
hash = hash || {}; // hash may be undefined
hash.crossDomain = true;
hash.xhrFields = { withCredentials: true };
hash.headers = {
'X-ActiveModelSerializers': '1',
};
return super.ajax(url, method, hash);
}
}