-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjest.config.js
67 lines (63 loc) · 1.91 KB
/
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
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
56
57
58
59
60
61
62
63
64
65
66
67
const tsConfig = require("./tsconfig.json")
const { pathsToModuleNameMapper } = require('ts-jest');
const path = require('path');
function getPaths(paths, allowInternals = false) {
if (allowInternals) {
return paths;
}
return Object.fromEntries(
Object.entries(paths).filter(([key]) => !key.includes('@stackla/*'))
);
}
const baseConfig = ({ tsConfig = {}, allowInternals = true }) => ({
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
setupFilesAfterEnv: [path.resolve(__dirname, 'tests', 'setup-env-vars.js')],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
...(tsConfig.compilerOptions &&
tsConfig.compilerOptions.paths && {
moduleNameMapper: pathsToModuleNameMapper(
getPaths(tsConfig.compilerOptions.paths, allowInternals),
{
prefix: '<rootDir>/',
}
),
}),
});
module.exports = {
...baseConfig({ tsConfig }),
testEnvironment: "@happy-dom/jest-environment",
globalSetup: "./tests/setup.ts",
collectCoverageFrom: [
"src/**/*.{ts,js}",
"!src/**/*.d.ts",
"!src/**/*.spec.ts",
"!src/**/*.test.ts",
"!src/**/*.spec.js",
"!src/**/*.test.js",
"!src/**/index.ts",
"!src/**/index.js",
"!src/**/exceptions/**",
"!src/functions/**",
"!src/libs/**",
"!src/**/*.template.ts",
"!src/**/*.component.ts",
"!src/**/*.style.ts",
"!src/**/*.interface.ts",
"!src/ui/packages/**",
"!**/types/**",
"!**/interfaces/**"
],
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/.serverless/", "/packages/"],
coverageDirectory: "<rootDir>/coverage",
coverageReporters: ["json", "lcov", "text", "clover", "html"],
transform: {
"^.+\\.js$": "babel-jest",
"^.+\\.(ts|tsx)$": "ts-jest",
'^.+\\.mjs$': 'babel-jest'
},
transformIgnorePatterns: [
'/node_modules/(?!swiper)', // Transpile the swiper module
],}