@samselikoff samselikoff released this Mar 1, 2018 · 239 commits to master since this release

  • 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 that ember-cli-mirage's blueprint adds to destroyApp().
  • 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 use destroyApp(), it's not at play either. So there are two options:
    • In each test that needs it, call setupMirageTest(), which will register beforeEach/afterEach hooks to set up and shut down the mirage server and make it accessible via this.server (and also the server global).
    • Set autostart: true in your ember-cli-mirage config object in config/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 as this.server on the test context (and also the server global), and also register and create a singleton that, when destroyed during app shutdown, will shut down the mirage server.

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 to setupMirageTest() and continue using this.server. As acceptance tests are migrated, add a call to setupMirageTest() and optionally switch from using the server global to using this.server.
  • Set autostart: true in config/environment, and then as non-acceptance tests are migrated, just delete the manual starting/stopping of the mirage server and continue using this.server. As acceptance tests are migrated, no changes are necessary, but users can optionally switch from using the server global to using this.server.
Assets 2