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

Store not registered as service for tests #2994

Closed
technomage opened this issue Apr 12, 2015 · 5 comments
Closed

Store not registered as service for tests #2994

technomage opened this issue Apr 12, 2015 · 5 comments

Comments

@technomage
Copy link

Trying to test a component that has the following fails because the service:store is not defined.

moduleForComponent('actor-table', {
// specify the other units that are required for this test
needs: ['service:store']
});

@fivetanley
Copy link
Member

Did this work with store:main before?

@bmac
Copy link
Member

bmac commented Apr 17, 2015

Thanks for reporting this issue @technomage. I've opened a pr at emberjs/ember-test-helpers#39 to try and get the service:store automatically registered in tests.

@bmac
Copy link
Member

bmac commented Apr 28, 2015

Here is a work around I have used while waiting for the above pr to get merged.

import {
  moduleFor,
  test
} from 'ember-qunit';
import { getContext } from 'ember-test-helpers';
import DS from 'ember-data';

moduleFor('service:product', {
  // Specify the other units that are required for this test.
  needs: ['model:product'],
  beforeEach: function() {
    // Register the store as a service. This can go away once
    // https://github.com/switchfly/ember-test-helpers/pull/39 is
    // merged.
    var context = getContext();
    context.container.register('service:store', DS.Store);
  }
});

@bmac
Copy link
Member

bmac commented May 6, 2015

@technomage try version 0.3.2 of https://github.com/rwjblue/ember-qunit. It should now automatically register the store as a service when ED is on the page.

Please note that you should NOT include needs: ['service:store'] because that will override the Ember Data store by attempting to load a module from app/service/store.js (or app/store/service.js if you are using pods).

@bmac bmac closed this as completed May 6, 2015
@technomage
Copy link
Author

Thanks. I will update ASAP.

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

3 participants