forked from emberjs/ember-test-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overriding services/factories in the registry.
By default in Ember things that are automatically resolved take precedence over things that are manually registered. This is somewhat counterintuitive to many people, as they would like to be able to override a service or other factory in a given set of tests (for example to use a mock analytics service). The ability to do this has existed since the SSR/Fastboot work that split the registry from the container in 1.11, but I only recently realized how I could leverage that work here. This change adds new functionality on Ember 1.11+, but allows older versions to continue to work as they do today (aka non-breaking). --- Example: Assuming you have a `app/services/analytics.js` and want to use a mock service for a set of component integration tests, you might do something like this: ```javascript import MockAnalyticsService from '../mock-services/analytics'; import { moduleForComponent, test } from 'ember-qunit'; moduleForComponent('something-cool', { integration: true, beforeEach() { this.registry.register('service:analytics', MockAnalyticsService); } }); ``` In the above scenario, the mock service would be used instead of the one at `app/services/analytics.js`.
- Loading branch information
Showing
3 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters