-
Notifications
You must be signed in to change notification settings - Fork 76
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
Can mirage be used for testing? #316
Comments
It seems like something like this works: import DS from 'ember-data';
import EmberLocalStorageAdapter from 'ember-local-storage/adapters/local';
import ENV from 'swach/config/environment';
let Adapter = EmberLocalStorageAdapter;
if (ENV.environment === 'test') {
Adapter = DS.JSONAPIAdapter;
}
export default Adapter; We should decide how we want to best support Mirage and document it. |
Hey @rwwagner90, A comment about your approach from above: That would just test the JSONAPIAdapter which is not too different to ELS Adapter but not the same thing. I’ll need to think about it more but here is a quick suggestion. You can create some records in your app and use the export feature to export it to a JSON file. Then in your tests you can import that file and use it as fixtures. |
@fsmanuel I have it working with Mirage currently. I would love if we could get a more official Mirage solution in place though. |
@fsmanuel have you given this any more thought? We're hitting some issues now where running the tests against a mirage setup that doesn't use ELS is causing issues. |
Hey @rwwagner90, as I said I don't think we can use Mirage for the tests as ELS never issues a network request that Mirage can intercept. What you are doing is testing Are you on Discord? You can ping me there (fsmanuel) so we can talk about it. |
As discussed on Discord, the idea is to use mirage db to populate LocalStorage. |
Hey @samselikoff, do you have any input on that? |
Not really familiar with this addon – does it store network / ember-data payloads into localStorage? You can call |
@samselikoff thanks for the info and the pointer to |
@samselikoff looks like we could use this helper: https://www.ember-cli-mirage.com/docs/testing/integration-and-unit-tests#writing-a-helper-to-push-mirage-s-database |
I'm using the ember-data adapters from this addon, and I would like to write tests now. I setup some mirage fixtures, and loaded them, and it seems that the data is not loaded in. I am guessing because of the magic of the adapters. Is there any way to use this with mirage?
The text was updated successfully, but these errors were encountered: