On Debug only: error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', etc.
I have a simplistic express application that uses a top-level await.
Typescript is happy. Running the app works fine. Running the tests is fine. I found the setting jestrunner.jestCommand to make the latter work
However, when I use the inline Debug command provided by VS Jest Runner, I receive the following error which I haven't been able to resolve just yet:
FAIL src/server.integration.ts
● Test suite failed to run
src/server.ts:10:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
10 await configureApp(expressApp);
~~~~~
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.477 s
However, module is set to ESNext in tsconfig.json already. And when I use the inline Run command for the same test, then the output looks as follows:
node@express-testing-dev:/work/service$ node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest --passWithNoTests --testMatch '**/?(*.)+(integration|micro).[jt]s?(x)' '/work/service/src/server.integration.ts' -c '/work/service/jest.config.ts' -t 'server\.ts returns Hello, world! '
console.log
listening at http://localhost:21003
at Server.<anonymous> (src/server.ts:13:54)
PASS src/server.integration.ts
server.ts
✓ returns Hello, world! (35 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.445 s
Ran all test suites with tests matching "server\.ts returns Hello, world! ".
Where do I need to change the configuration to make this work for the Debug command as well? Any pointers, suggestions, thoughts, etc. would be highly welcome!
A complete repro repository is available at https://github.com/RimuTec/express-testing (Note this repo uses a dev container). The test I'm using is the only test in file /work/service/src/server.integration.ts (absolute path inside the dev container).
hey @ManfredLange
generally you can influence the debug settings using the jestrunner.debugOptions settings.
you can search for the option in issues and you will find plenty of examples
"jestrunner.debugOptions": {
"args": ["--no-cache"],
"sourcemaps": "inline",
"disableOptimisticBPs": true,
}
but i think you issue is conntect to the tsconfig settings.
best regards tristan