Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import jsdom-worker with --experimental-vm-modules #22

Open
Amatewasu opened this issue Mar 8, 2023 · 2 comments
Open

Cannot import jsdom-worker with --experimental-vm-modules #22

Amatewasu opened this issue Mar 8, 2023 · 2 comments

Comments

@Amatewasu
Copy link

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.<anonymous> (node_modules/jsdom-worker/dist/jsdom-worker.js:1:89)
      at Object.<anonymous> (src/setupTests.ts:6:1)

Would you have insight how to solve this issue?

$ node -v
v17.9.1
$ npm -v
8.11.0
@LeonardoRick
Copy link

Hey @Amatewasu did you find any solution to this problem? It's weird still having problems to use ESM modules in 2024 lol

@Amatewasu
Copy link
Author

Amatewasu commented Jan 14, 2024

@LeonardoRick I do not use jest anymore but the bun test suite with happy-dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants