Tests fail to run with Mirage
See original GitHub issueVersions:
- Embroider: current master (418af5a7fe53e8947a9a0454fdc01649be6fb22b)
- ember-cli-mirage: 1.1.0
- ember-auto-import: 1.5.2
When an application has Mirage installed, test runs give an early failure, when checking if Mirage should be used:
TypeError: Cannot destructure property `getContext` of 'undefined' or 'null'.
at getRfc232TestContext (webpack:///./node_modules/ember-cli-mirage/get-rfc232-test-context.js?:18:9)
at _shouldUseMirage (webpack:///./initializers/ember-cli-mirage.js?:57:109)
at Object.initialize (webpack:///./initializers/ember-cli-mirage.js?:38:9)
at http://localhost:7357/assets/vendor.js:46464:21
I suspect it might be because those lines in Mirage use require
to check if @ember/test-helpers
is a project dependency.
I have a reproduction of this on the mirage branch of my Embroider sandbox, here: https://github.com/balinterdi/go-embroider-go/tree/mirage
(The test passes on the master branch, before adding Mirage)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Testing server errors with Mirage | EmberMap
Testing server errors with Mirage. Testing network requests that fail in an Ember app is currently a somewhat inconsistent experience.
Read more >Tutorial: Part 9 – Testing • Mirage JS
Part 9 – Testing. In this final section, we're going to learn how to use Mirage to test our app given a variety...
Read more >Ember mirage server is not defined in tests - Stack Overflow
Mirage starts up in an initializer. Since initializers only run when a full Ember app boots up, by default the Mirage server is...
Read more >UI Testing with React, Mirage, Jest and Testing Library
This video goes over some of the basics of writing UI tests for an existing React application using Mirage, Jest, and Testing Library....
Read more >Using Mirage JS And Cypress For UI Testing (Part 4)
In this final part of Mirage JS Deep Dive series, ... However, if we run our tests, it will fail because we don't...
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 FreeTop 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
Top GitHub Comments
Probably has something to do with:
https://github.com/samselikoff/ember-cli-mirage/blob/dcef77adced352d43d314ab484e47075018addb7/addon/utils/read-modules.js#L18-L25
or
https://github.com/samselikoff/ember-cli-mirage/blob/dcef77adced352d43d314ab484e47075018addb7/addon/utils/ember-data.js#L5
The most static options are enabled, the fewer things will reliably appear in
requirejs.entries
.Yes, that would be the solution for how to fix this upstream in mirage. Though you should probably hold off until
@embroider/macros
is updated to match the current RFC.The more temporary workaround is to use a compatAdapter to force
@ember/test-selectors
to be included as animplicit-test-module
.