forked from Mythic-Project/governance-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
29 lines (26 loc) · 913 Bytes
/
jest.config.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
const nextJest = require('next/jest')
const { resolve } = require('path')
const { readdirSync } = require('fs')
// XXX: hack to deal with tsconfig.baseUrl: "." and tsconfig.paths
const directories = readdirSync(__dirname, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map(({ name }) => name)
.filter((dir) => !dir.startsWith('.') && dir !== 'node_modules')
.reduce(
(acc, dir) => ({
...acc,
[`^${dir}/(.*)$`]: resolve(__dirname, `./${dir}/$1`),
[`^@${dir}/(.*)$`]: resolve(__dirname, `./${dir}/$1`),
}),
{}
)
const customConfig = {
moduleNameMapper: directories,
setupFilesAfterEnv: ['<rootDir>/test/setup.js'],
moduleDirectories: ['node_modules', '<rootDir>/'],
transform: {
'^.+\\.(t|j)sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
module.exports = nextJest({ dir: './' })(customConfig)