-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
50 lines (44 loc) · 1.34 KB
/
jest.config.ts
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
import type { JestConfigWithTsJest } from 'ts-jest'
import dotenv from 'dotenv'
console.log(
`
________________________________________
_______ __
/ ____(_)___ / /_ ___ _____
/ / / / __ \\/ __ \\/ _ \\/ ___/
/ /___/ / /_/ / / / / __/ /
\\____/_/ .___/_/ /_/\\___/_/
/_/
________________________________________
`
)
const env = process.env.NODE_ENV
const testEnv = process.env.JSDOM === 'true' ? 'jest-environment-jsdom' : 'node'
dotenv.config( { path: [
`.env.${ env }.local`,
`.env.${ env }`,
'.env.local',
'.env'
] } )
/**
* Initial file generated with `npx ts-jest config:init`
*
*/
const config: JestConfigWithTsJest = {
/** https://jestjs.io/docs/configuration#testenvironment-string */
testEnvironment: testEnv,
moduleDirectories: [ 'node_modules', '<rootDir>/' ],
setupFilesAfterEnv: [ './jest.setup.ts' ],
/**
* If you're using [Module Path Aliases](https://nextjs.org/docs/advanced-features/module-path-aliases),
* you will have to add the moduleNameMapper in order for jest to resolve your absolute paths.
* The paths have to be matching with the paths option within the compilerOptions in the tsconfig.json
*/
moduleNameMapper: {
'@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+.tsx?$': [ 'ts-jest', {} ],
},
}
export default config