developit / developit/jsdom-worker

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

オープン
#22 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
291
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

説明

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
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

src/setupTests.ts の import と、node_modules/jsdom-worker/dist/jsdom-worker.js に示されている失敗するエントリーポイントから始め、--experimental-vm-modules を付けた Node v17.9.1 を使用して失敗を再現します。jsdom-worker をその構成で node-fetch ES module error なしに import でき、テストスイートが正常に開始すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。