I have been struggling to configure jest for use with typescript and despite trying several solutions, I am still facing issues. The error
SyntaxError: Unexpected token, expected ";"
keeps popping up, indicating that the configuration may not be compatible with typescript code. Here is the screenshot of the error message: https://i.sstatic.net/iGBCa.png
If anyone has any recommendations or suggestions, I would greatly appreciate it!
This is my package.json:
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"collectCoverageFrom": [
"**/*.js",
"**/*.ts",
"!__tests__/util.ts",
"!coverage/**",
"!**/node_modules/**"
],
"transform": {
"^.+\\.tsx?$": "babel-jest"
},
"verbose": true,
"automock": false,
"clearMocks": true,
"setupFilesAfterEnv": [
"jest-extended"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
Here is my tsconfig.json file:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": false,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": false,
"target": "esnext",
"types": ["@emotion/core", "@types/jest", "jest"],
"rootDir": ".",
"baseUrl": ".",
"noImplicitAny": false,
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}