developit / developit/jsdom-worker
Cannot import jsdom-worker with --experimental-vm-modules
- Ngôn ngữ chính
- JavaScript
- Star
- 291
- Fork
- 20
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với import trong src/setupTests.ts và entry point bị lỗi được hiển thị trong node_modules/jsdom-worker/dist/jsdom-worker.js, sau đó tái hiện lỗi bằng Node v17.9.1 với --experimental-vm-modules. Được xem là hoàn thành khi có thể import jsdom-worker trong cấu hình đó mà không gặp node-fetch ES module error và test suite khởi động thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- testing
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 30/100