Skip to content

Instantly share code, notes, and snippets.

@blimmer
Last active July 22, 2018 00:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blimmer/35d3efbb64563029505a to your computer and use it in GitHub Desktop.
Save blimmer/35d3efbb64563029505a to your computer and use it in GitHub Desktop.
Ember-CLI-Mirage server.shutdown() explanation

What's the problem?

Mirage starts up a global server when your app initializers run. That means that each time you destroy your app, you need to call server.shutdown(). However, if you are on Ember CLI 1.13.8 or below, you won't have a destroy-app.js helper so we can automatically do this for you.

What can I do?

There are several things you can do to fix this. You only need to do one of the options below.

Upgrade Ember-CLI

This is the easiest way to fix this problem. Upgrade to Ember CLI 1.13.9 or higher (follow the upgrade steps with ember init) and re-run ember g ember-cli-mirage. That's it!

I wrote an ember watson formula to help convert your old acceptance tests to use this new destroyApp helper. See ember watson .

Create your own destroy-app helper

  1. Create tests/helpers/destroy-app.js
  2. Use the contents of the destroy-app file
  3. Replace instances of Ember.run(this.application, 'destroy') with the new destroy-app call. You can see how it's done here

Manually shutdown after each startApp

Ensure that you manually insert a server.shutdown() after the Ember.run(this.application, 'destroy') in acceptance tests.

@lifeart
Copy link

lifeart commented Apr 12, 2018

Have this error on ember-cli 3.3.1

@EstesE
Copy link

EstesE commented Apr 13, 2018

I have this error in 3.04 & 3.3.1.

@Eguzkiman
Copy link

I have this error too on 3.0.4

@twokul
Copy link

twokul commented Apr 16, 2018

I think this should take into account ember-cli@3+, more details here: new testing API makes this helper obsolete.

@symphonyh
Copy link

I have this error too on 3.1.3

@BrandonSchreck
Copy link

Error found in 3.1.4

@jagthedrummer
Copy link

Just saw this error in 3.1.4. Is it safe to assume I don't need to do anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment