-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Overwriting application to use DS.FixtureAdapter in start-app.js #3249
Comments
This should be all you need... // app/adapters/application.js
import config from '../config/environment';
import DS from 'ember-data';
var adapter;
if (config.environment === 'test') {
adapter = DS.FixtureAdapter.extend();
} else {
adapter = DS.RESTAdapter.extend();
}
export default adapter; |
I feel that is bad practice, as now my main application depends on that variable. I'd like to separate the test dependencies as much as possible. Is there a way to do this in start-app? |
Honestly, I'd recommend not using the FixtureAdapter and just stick with the RESTAdapter for all environments. Use ember-data-factory-guy to create fixtures for the RESTAdapter. |
@corydobson If you want to use the
With that said, I tend to agree with @jbrown and favor using a mock server library such as Pretender or Sinon for testing most applications. By mocking server responses, you can also test your adapters and serializers and better simulate error conditions. For example, check out how Discourse uses Pretender to test authentication. I don't have experience using ember-data-factory-guy, but that might be worth exploring too. |
@dgeb Thanks for the help Dan! Unfortunately using didn't work as expected either. I'll investigate using Pretender and go that route. |
start-app.js problems
Hi Ember-Devs,
I'm working on a project that is using the DS.RESTAdapter for production code, however I want to use the FixtureAdapter for my integration tests. Im having problems overwriting this property of the application in start-app.js using Ember-CLI and Ember-CLI-Mocha
And the test
and the route
However Ember is still using the RESTAdapter calling my api endpoint as defined in the application adapter.
What am I doing wrong / not doing to overwrite this adapter for my tests?
The text was updated successfully, but these errors were encountered: