-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.preset.js
45 lines (40 loc) · 1.43 KB
/
jest.preset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// @ts-check
import nxPreset from '@nx/jest/preset/index.js'
import { pathsToModuleNameMapper } from 'ts-jest'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
// get dirname for esmodules
import { readFileSync } from 'fs'
import { join } from 'path'
const tsconfig = JSON.parse(readFileSync(join(__dirname, 'tsconfig.base.json'), 'utf8'))
const {
compilerOptions: { paths },
} = tsconfig
export default {
...nxPreset,
globals: {
__basedir: __dirname,
},
transform: {
'^.+\\.ne$': 'jest-transform-nearley',
'^.+\\.[jt]sx?$': ['@swc/jest', { swcrc: false }], // swcConfig],
},
testEnvironment: 'node',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: pathsToModuleNameMapper(paths, {
prefix: `${__dirname}/`,
}),
/* TODO: Update to latest Jest snapshotFormat
* By default Nx has kept the older style of Jest Snapshot formats
* to prevent breaking of any existing tests with snapshots.
* It's recommend you update to the latest format.
* You can do this by removing snapshotFormat property
* and running tests with --update-snapshot flag.
* Example: "nx affected --targets=test --update-snapshot"
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: { escapeString: true, printBasicPrototype: true },
}