"You created a second Pretender instance while there was already one running"
See original GitHub issueI started getting this error today with ember-cli-mirage@0.2.2, and I’m fairly certain it has to do with Pretender 1.4.0 (that has a Notify on second Pretender fix) that was released today.
beforeEach failed on visiting /myroute/foo: You created a second Pretender instance while there
was already one running. Running two Pretender servers at once will lead to unexpected
results!Please call .shutdown() on your instances when you no longer need them to respond.
This was in my acceptance test. I have failures in my integration tests as well, which look like:
Promise rejected before it renders: Assertion Failed: You cannot use the same root element
(#ember-testing) multiple times in an Ember.Application
So what is the appropriate way to shutdown the Mirage server? I currently have this in my acceptance tests:
afterEach() {
Ember.run(application, 'destroy');
server.shutdown();
}
Do I need something similar in my integration tests?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:19
- Comments:14 (7 by maintainers)
Top Results From Across the Web
You created a second Pretender instance while there was ...
Running two Pretender servers at once will lead to unexpected results!Please call .shutdown() on your instances when you no longer need them to ......
Read more >ember-cli-mirage in legacy app - Stack Overflow
You created a second Pretender instance while there was already one running. Running two Pretender servers at once will lead to unexpected ...
Read more >Tutorial: Part 9 – Testing • Mirage JS
Jest should start a watcher that will re-run your tests every time you make ... You created a second Pretender instance while there...
Read more >You created a second Pretender instance while there was ...
"You created a second Pretender instance while there was already one running" ... I started getting this error today with ember-cli-mirage@0.2.2 , ...
Read more >Mocking your JSON API with Ember CLI Mirage - Culttt
Last week we went from static HTML to calling a property on the controller to retrieve data for an Ember template.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m using mostly default generated tests with ember 2.10 and was having this issue. Resolved it by adding
if(server !== undefined) { server.shutdown(); }to beforeEach and afterEach in each acceptance test file. As in,Hope this helps someone else having the same problem.
Update: It seems that updating
module-for-acceptance.jsto the newest version (from Ember CLI 2.8) and adding this snippet to integration tests which use Mirage:does the job - everything is fine then.