vitorsalgado / create-nodejs-ts

Starter Project for Node.js With TypeScript.
https://www.npmjs.com/package/create-nodejs-ts
MIT License
147 stars 27 forks source link

jest test failed to run #386

Open BurtHarris opened 2 years ago

BurtHarris commented 2 years ago

Describe the bug Test suit fails. I suspect it is related to ES modules.
In this case the test was launched by a VSCode add-in for Jest. I will research and add more details. Repro setup just like #385, but I ran git and npm install.

messages


[my-app]: Scheduled test run "watch-tests-1" for "orta.vscode-jest:my-app"
 FAIL  src/main.spec.ts
  ● Test suite failed to run

    src/main.spec.ts:25:39 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.

    25     const dir = dirname(fileURLToPath(import.meta.url))
                                             ~~~~~~~~~~~

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.21 s

* Screenshot *

![image](https://user-images.githubusercontent.com/2715647/179315420-bd6038da-b13e-41d3-a660-b35ec153fd0a.png)
BurtHarris commented 2 years ago

It passes when run by the NPM script. So this is probably something specific to the jest extension.