tamilmani
tamilmani

Reputation: 591

can't import the test helper addon in ember-cli-mirage

Facing the same issue - https://github.com/miragejs/ember-cli-mirage/issues/1445

Uncaught Error: Could not find module project-name/tests/helpers/push-mirage-into-store imported from project-name/mirage/factories/addon

Initially got this error and tried @makepanic instructions

After that

Uncaught Error: Could not find module @ember/test-helpers imported from project-name/mirage/helpers/push-mirage-into-store

can you pls help here to resolve this.

Upvotes: 0

Views: 771

Answers (1)

jelhan
jelhan

Reputation: 6338

I bet you are running into the error, which is described in this comment by makepanic in the GitHub issue you linked:

When running the app directly, the browser opens index.html which isn't loading tests.js. This file contains everything related to tests.

If you open tests/index.html, that will also load tests.js and add any modules under tests/* to the loader registry.

This means without the tests file loaded, you can't import anything from tests/*.

You are affected by that issue if you face it when running ember serve.

The comment also includes a possible solution:

With you moving the helpers to /mirage, they gets registered in both index.html and tests/index.html.

An alternative would be to disable mirage in all enrironments except for test. But that is only a feasible solution if you use mirage only for testing but not for development.

Upvotes: 0

Related Questions