Test suite failed while the code includes static initialization blocks.
class Model {
static {
this.schema.index( {} );
}
}
● Test suite failed to run
TypeError: Cannot read properties of undefined (reading 'schema')
23 |
24 | static {
> 25 | this.schema.index( {
| ^
26 | groups : -1
27 | } );
28 |
and this is my jest config:
module.exports = {
cacheDirectory : `${__dirname}/.jest-cache`,
preset : 'ts-jest',
// setupFilesAfterEnv : [ 'jest-extended/all' ],
testMatch : [
'**/test/**/*.spec.[tj]s?(x)',
'**/test/**/*.dt.ts'
],
// Indicates which provider should be used to instrument code for coverage
coverageProvider : 'v8',
// A list of reporter names that jest uses when writing coverage reports
coverageReporters : [
'json',
'text-summary',
'text',
'lcov',
'clover'
],
collectCoverageFrom : [
'**/src/**/*.{js,ts,jsx,tsx}',
'**/scripts/**/*.{js,ts,jsx,tsx}',
'!**/*.d.ts'
],
testEnvironment : 'node',
transform : {
'^.+\.tsx?$' : [
'ts-jest',
{
isolatedModules : true,
tsconfig : '<rootDir>/tsconfig.spec.json'
}
]
},
transformIgnorePatterns : [
'\.pnp\.[^\/]+$'
]
}
I tried changing compile target in tsconfig.json, but it didn’t work.