-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.preset.js
32 lines (28 loc) · 1.19 KB
/
jest.preset.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
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
moduleFileExtensions: ['ts', 'js', 'mjs'],
passWithNoTests: true,
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.[tj]s$': ['ts-jest', {
useESM: true,
tsconfig: '<rootDir>/tsconfig.json',
}]
},
transformIgnorePatterns: ['node_modules/(?!(serialize-error)|(exit-hook)|(chalk)|(find-cache-dir)|(pkg-dir)|(find-up)|(locate-path)|(p-locate)|(p-limit)|(yocto-queue)|(path-exists)|(change-case))'],
preset: 'ts-jest/presets/js-with-ts-esm',
moduleDirectories: ['node_modules', `${__dirname}/packages`],
coverageReporters: ['text', 'clover', 'json', 'lcov'],
coveragePathIgnorePatterns: ['/node_modules/', '__test__'],
moduleNameMapper: {
// Removes .js at the end to match typescript files
'^(\\.{1,2}/.*)\\.js$': '$1',
// Typescript packages
'^@jungvonmatt/(contentful-ssg|contentful-fakes|cssg-plugin-grow|cssg-plugin-assets)/(.*)$': `${__dirname}/packages/$1/dist/$2`,
// Javascript packages
'^@jungvonmatt/(.*)$': `${__dirname}/packages/$1`,
},
};