[Bug]: Jest doesn't run with node --loader option
See original GitHub issueVersion
27.0.6
Steps to reproduce
Example steps:
- Install any loader (targos/multiloader, quibble, node-loader/core were all tried)
- Run jest with
node --loader @multiloader/loader --experimental-vm-modules node_modules/.bin/jest
(replace loader name as you will)
Expected behavior
I expect the tests to run OR if the --loader flag in invalid I expect some kind of error message to appear and the test run to exit out.
Actual behavior
Error:
(node:44385) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:44385) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
and then the tests do not run at all, no actual error appears.
Additional context
No response
Environment
System:
OS: macOS 11.3.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm
npmPackages:
jest: ^27.x.x => 27.0.6
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to resolve "Cannot use import statement outside a ...
FYI, I was running into this when setting up a custom TestSequencer for Jest and I just switched to using require instead of...
Read more >Troubleshooting - Jest
The --runInBand cli option makes sure Jest runs the test in the same process rather than spawning processes for individual tests. Normally Jest...
Read more >Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your project or through the --config <path/to/json> option.
Read more >How To Test a React App with Jest and React Testing Library
If you did not install npm alongside Node.js , do that now. For Linux, use the command sudo apt install npm . For...
Read more >Debug Node.js Apps using Visual Studio Code
Setting up a project for Node.js debugging is straightforward with VS Code providing appropriate launch configuration defaults and snippets.
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
@sigveio thank you so much for looking into this more! The
--runInBand
does let the tests run, but the loader doesn’t seem to be registered properly in that case.The use case for this specific loader is that Jest doesn’t support ESM mocking yet, but testdouble does with the loader. The intent was to use testdouble as a workaround until mocking was available for ESM in Jest. This is what mocha recommends to get around their lack of ESM mocking, and I was hoping I could get it to work with Jest, since I prefer Jest and Jest lets me watch .mjs files.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.