developit / developit/jsdom-worker
Cannot import jsdom-worker with --experimental-vm-modules
- Dominant language
- JavaScript
- Stars
- 291
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
In order to be allowed to use `import.meta.url` in my jest tests, I turned on the option `--experimental-vm-modules`. But thereby I cannot import jsdom-worker anymore.
I have the following stack trace:
```
FAIL src/anonymized-path/anonymized.test.tsx
● Test suite failed to run
Must use import to load ES Module: C:\anonymized-path\anonymized\node_modules\node-fetch\src\index.js
4 | import { enableFetchMocks } from 'jest-fetch-mock';
5 | import { readFileSync, readdirSync } from 'fs';
> 6 | import 'jsdom-worker';
| ^
7 | import { getPathFromPublic } from 'utils/helpers';
8 |
9 | /* Wasm jest problems - the function locate file returns C:\ instead of localhost when testing with jest
at Runtime.requireModule (node_modules/jest-runtime/build/index.js:972:21)
at Object. (node_modules/jsdom-worker/dist/jsdom-worker.js:1:89)
at Object. (src/setupTests.ts:6:1)
```
Would you have insight how to solve this issue?
```
$ node -v
v17.9.1
$ npm -v
8.11.0
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the import in src/setupTests.ts and the failing entry point shown in node_modules/jsdom-worker/dist/jsdom-worker.js, then reproduce the failure using Node v17.9.1 with --experimental-vm-modules. Done means jsdom-worker can be imported under that configuration without the node-fetch ES module error and the test suite starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100