Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretender does not catch call when mock is not define - ERROR : "The adapter operation was aborted" #482

Open
victorsmits opened this issue Jan 17, 2023 · 0 comments

Comments

@victorsmits
Copy link

victorsmits commented Jan 17, 2023

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.

image
image

And in the network we can see that a call has been made

image

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);
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant