This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathjest.config.cjs
56 lines (49 loc) · 1.72 KB
/
jest.config.cjs
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
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable @typescript-eslint/no-var-requires */
const { readFileSync, existsSync } = require('fs')
const { resolve } = require('path')
const { parse: parseJSON } = require('JSON2016/JSON2016.js')
const { pathsToModuleNameMapper } = require('ts-jest')
const SKIP_LIB_CHECK = Boolean(
process.env.TS_JEST_COMPILER_OPTIONS_SKIP_LIB_CHECK
)
const ISOLATED_MODULES = Boolean(process.env.TS_JEST_ISOLATED_MODULES)
const MAP_PATHS_TO_MODULES =
process.env.TS_JEST_MAP_PATHS_TO_MODULES !== 'false'
const tsConfig = resolve(__dirname, 'tsconfig.json')
const { compilerOptions } = parseJSON(
readFileSync(tsConfig, { encoding: 'utf8' })
)
const pathsToModuleNames = pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `${__dirname}/`
})
const moduleNameMapper = MAP_PATHS_TO_MODULES ? pathsToModuleNames : undefined
let config = {
preset: 'ts-jest',
projects: ['<rootDir>/packages{-archived,}/*/jest.config.cjs'],
testEnvironment: `${__dirname}/commands/jest/jsdomWithFetchEnv.js`,
rootDir: '.',
moduleNameMapper,
resolver: `${__dirname}/commands/jest/resolver.js`,
extensionsToTreatAsEsm: ['.mts'],
moduleFileExtensions: ['js', 'ts', 'tsx', 'jsx', 'json', 'mts'],
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest']
},
setupFiles: [__dirname + '/commands/jest/loadReflection.js'],
globals: {
'ts-jest': {
compilerOptions: {
// Speed up typechecks
skipLibCheck: SKIP_LIB_CHECK
},
isolatedModules: ISOLATED_MODULES,
diagnostics: false
}
}
}
const localConfPath = `${__dirname}/jest.config.local.cjs`
const localConf = existsSync(localConfPath) ? require(localConfPath) : {}
if (typeof localConf === 'function') {
config = localConf(config)
}
module.exports = config