$ git clone https://github.com/upleveled/preflight.git
$ cd preflight
$ yarn
$ yarn test --coverage
...
Running coverage on untested files...Failed to collect coverage from /Users/k/p/preflight/src/preflightBinPath.ts
ERROR: src/preflightBinPath.ts:5:38 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
5 const { stdout: preflightBinPath } = await execa.command(`yarn bin`, {
~~~~~
src/preflightBinPath.ts:6:30 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
6 cwd: dirname(fileURLToPath(import.meta.url)),
~~~~~~~~~~~
STACK:
Failed to collect coverage from /Users/k/p/preflight/src/checks/eslintConfigIsLatestVersion.ts
ERROR: src/checks/eslintConfigIsLatestVersion.ts:7:7 - error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module.
7 const require = createRequire(`${process.cwd()}/`);
~~~~~~~
STACK:
Failed to collect coverage from /Users/k/p/preflight/src/checks/preflightIsLatestVersion.ts
ERROR: src/checks/preflightIsLatestVersion.ts:15:50 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
15 await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),
~~~~~~~~~~~
STACK:
Failed to collect coverage from /Users/k/p/preflight/src/checks/prettier.ts
These errors do not show up in the normal yarn test, since the tsconfig.json is respected.
Expected behavior
The tsconfig.json file should also be respected for the Coverage testing mode.
Suggested solution(s)
I tried to look into it for a few minutes, but didn't get too far - not sure which dependency is having troubles loading the tsconfig.json.
At first I thought it was ts-jest, which doesn't yet support ESM, but this is looking more and more like a red herring...
Additional context
I tried also adding NODE_OPTIONS=--experimental-vm-modules as suggested by the Jest ESM docs, but this also didn't help.
Current Behavior
These errors do not show up in the normal
yarn test
, since thetsconfig.json
is respected.Expected behavior
The
tsconfig.json
file should also be respected for the Coverage testing mode.Suggested solution(s)
I tried to look into it for a few minutes, but didn't get too far - not sure which dependency is having troubles loading the
tsconfig.json
.At first I thought it was
ts-jest
, which doesn't yet support ESM, but this is looking more and more like a red herring...Additional context
I tried also adding
NODE_OPTIONS=--experimental-vm-modules
as suggested by the Jest ESM docs, but this also didn't help.Your environment