v0.4.2
- Adds support for new style (RFC232/RFC268) tests
- Parts of Mirage's factory layer that create data are faster
- Serializers support coalesced IDs
- Ensure JSONAPISerializer supports
include
as function - Add support for
options
mocking
How it works in different types of tests
- Old-style non-acceptance tests: mirage will not automatically start, and can still be manually started using the
startMirage()
import from<app>/initializers/ember-cli-mirage
. - Old-style acceptance tests: mirage will still be started before each test by
<app>/initializers/ember-cli-mirage
and shut down by the code thatember-cli-mirage
's blueprint adds todestroyApp()
. - RFC232 and RFC268 tests:
<app>/initializers/ember-cli-mirage
will detect that it's an RFC232/RFC268 test and not start the mirage server automatically in the way that is problematic for the new tests, and since the new tests don't usedestroyApp()
, it's not at play either. So there are two options:- In each test that needs it, call
setupMirageTest()
, which will registerbeforeEach
/afterEach
hooks to set up and shut down the mirage server and make it accessible viathis.server
(and also theserver
global). - Set
autostart: true
in yourember-cli-mirage
config object inconfig/environment
which will cause an instance initializer to run before each test (every RFC232/RFC268 test, not just "acceptance" (application) tests) to start mirage and set it asthis.server
on the test context (and also theserver
global), and also register and create a singleton that, when destroyed during app shutdown, will shut down the mirage server.
- In each test that needs it, call
Upgrade path
This is not a breaking change -- existing tests will run just as they are. Furthermore, new and old tests can live side by side and work properly with mirage if the right setup is done, so you are not forced to migrate your whole suite all at once. As you migrate tests, you have two options:
- As non-acceptance tests are migrated, delete the manual starting/stopping of mirage in
beforeEach
/afterEach
and replace it with a call tosetupMirageTest()
and continue usingthis.server
. As acceptance tests are migrated, add a call tosetupMirageTest()
and optionally switch from using theserver
global to usingthis.server
. - Set
autostart: true
inconfig/environment
, and then as non-acceptance tests are migrated, just delete the manual starting/stopping of the mirage server and continue usingthis.server
. As acceptance tests are migrated, no changes are necessary, but users can optionally switch from using theserver
global to usingthis.server
.