-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.base.js
38 lines (35 loc) · 1.08 KB
/
jest.config.base.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
import { createRequire } from 'module';
/** @type {(dir: string) => import('ts-jest').JestConfigWithTsJest} */
export default (dir) => {
const require = createRequire(import.meta.url);
// eslint-disable-next-line import/no-dynamic-require
const packageObj = require(`${dir}/package.json`);
let reporters = ['default'];
if (process.env.DEPLOYMENT === 'ci') {
reporters = [['github-actions', { silent: false }], 'summary', 'jest-github-reporter'];
}
return {
testEnvironment: 'node',
reporters,
testMatch: ['<rootDir>/**/__tests__/**/*.test.[t]s?(x)'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
roots: [`<rootDir>`],
rootDir: dir,
displayName: packageObj.name.split('/')[1],
modulePaths: ['.'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^@app/config/env.js': '<rootDir>/../config/env.ts',
},
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: `${dir}tsconfig.spec.json`,
useESM: true,
},
],
},
};
};