-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.ts
More file actions
55 lines (49 loc) · 1.62 KB
/
jest.config.ts
File metadata and controls
55 lines (49 loc) · 1.62 KB
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
import type { JestConfigWithTsJest } from 'ts-jest'
import dotenv from 'dotenv'
console.log(
`
___________________________________________________________
____ __ ___ ____ ____
/ __ \\___ ____ ______/ /_ / | / __ \\/ _/
/ /_/ / _ \\/ __ \\\`/ ___/ __/ / /| | / /_/ // /
/ _, _/ __/ /_/ / /__/ /_ / ___ |/ ____// /
/_/ |_|\\___/\\__,_/\\___/\\__/ /_/ |_/_/ /___/
___________________________________________________________
`
)
const env = process.env.NODE_ENV
dotenv.config( { path: [
`.env.${ env }.local`,
`.env.${ env }`,
'.env.local',
'.env'
] } )
/**
* Initial file generated with `npx ts-jest config:init`
*
*/
const config: JestConfigWithTsJest = {
/**
* Use JSDOM by default since react testing library requires JSDOM environment.
*
* Use `@jest-environment node` directive at the top of your testing file if testing simple functions.
*
* https://jestjs.io/docs/configuration#testenvironment-string
*/
testEnvironment: 'jest-environment-jsdom',
moduleDirectories: [ 'node_modules', '<rootDir>/' ],
setupFilesAfterEnv: [ './jest.setup.ts' ],
testMatch: [ '**/__tests__/**/*.(test|spec).(ts|tsx)' ],
/**
* 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