jest
jest copied to clipboard
[BUG] ReferenceError: jest is not defined

You might find importing:
import { jest } from '@jest/globals'`
to help. I suspect something is causing the jest injectGlobals
option to not apply.
Same issue here. I am using the following .swcrc
and jest configuration:
.swcrc
{
"$schema": "http://json.schemastore.org/swcrc",
"jsc": {
"target": "es2020",
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true,
"hidden": {
"jest": true
}
},
"externalHelpers": true
},
"module": {
"type": "commonjs",
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false
}
}
Jest
const config = {
transform: {
'^.+\\.tsx?$': ['@swc/jest'],
},
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
verbose: false,
testTimeout: 200,
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/build/'],
modulePathIgnorePatterns: ['<rootDir>/build/'],
restoreMocks: true,
clearMocks: true,
resetMocks: true,
}
export default config
Running a backend project with Node 18 and TypeScript