Assume I have a typescript project and I use decorators. Out dir is "build". I want to test the compiled code, not the source code, so my test pattern include "build". I don't see reason using ts-jest since the code was already compiled
But when I run Jest (remember on build code) it failes with error SyntaxError: /.../models/externalEntity.model.ts: Support for the experimental syntax 'decorators' isn't currently enabled (6:1):
I tried to configure
transform: {
"\\.(js|jsx|ts|tsx)$": [
"babel-jest",
{
decoratorsBeforeExport: true,
plugins: [
"@babel/plugin-proposal-decorators",
"@babel/plugin-syntax-decorators",
],
},
],
},
but it still fail with different error related to decorators
my jest config and tsconfig are:
module.exports = {
testEnvironment: "node",
rootDir: "./build",
testMatch: ['<rootDir>/**/integration/?(*.)+(spec|test).[jt]s?(x)']
}
{
"include": ["./src/**/*"],
"exclude": [],
"compilerOptions": {
"incremental": true,
"target": "es2019",
"module": "commonjs",
"lib": ["es2019", "esnext.asynciterable"],
"allowJs": true,
"checkJs": false,
"outDir": "build",
"rootDir": "src",
"noImplicitAny": false,
"strictNullChecks": false,
"strictFunctionTypes": false,
"strictBindCallApply": false,
"noImplicitThis": false,
"noUnusedLocals": true,
"moduleResolution": "node",
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"preserveConstEnums": true,
"resolveJsonModule": true,
"traceResolution": false,
"extendedDiagnostics": false
},
}