Running Jest tests for Typescript ESM modules
typescript, programming, jest, vs code, ESM
package.json configuration
package.json configuration// {...
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"silent": true,
"extensionsToTreatAsEsm": [
".ts"
],
"moduleNameMapper": {
"^(\\\\.{1,2}/.*)\\\\.js$": "$1"
},
"transform": {
"^.+\\\\.ts$": [
"ts-jest",
{
"useESM": true
}
]
}
},
// ...}
launch.json configuration for VSCode
launch.json configuration for VSCodeError Notes
SyntaxError: Cannot use import statement outside a module
Plugin Recommendation
References
Last updated
Was this helpful?