I am using v12.14.1 version, in my project when try to type npm run test, I am getting this warning There is a mismatch between your NodeJs version v12.14.1 and your TypeScript target ESNext. This might lead to some unexpected errors when running tests with ts-jest
and all my test is failed, please can you say what node version should I use, or how can I fix this warning, to pass my tests
The answer is in this cheatsheet.
You are running node version 12, so you must set "target": "es2019"
and "lib": ["ES2019"]
in your tsconfig.json
.
Example of what your tsconfig can look like:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "./dist",
"sourceMap": true,
"strict": true,
"target": "es2019",
"lib": [
"es2019",
"es2020.bigint",
"es2020.string",
"es2020.symbol.wellknown"
],
"typeRoots": ["node_modules/@types"],
"resolveJsonModule": true
},
"compileOnSave": true,
"include": ["./src/**/*"],
"exclude": ["node_modules"]
}