You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.7 KiB
50 lines
1.7 KiB
const { pathsToModuleNameMapper } = require("ts-jest"); |
|
const { compilerOptions } = require("./tsconfig"); |
|
|
|
const tsPreset = require("ts-jest/jest-preset"); |
|
const angularPreset = require("jest-preset-angular/jest-preset"); |
|
const { defaultTransformerOptions } = require("jest-preset-angular/presets"); |
|
|
|
/** @type {import('ts-jest').JestConfigWithTsJest} */ |
|
module.exports = { |
|
// ...tsPreset, |
|
// ...angularPreset, |
|
preset: "jest-preset-angular", |
|
|
|
reporters: ["default", "jest-junit"], |
|
|
|
collectCoverage: true, |
|
// Ensure we collect coverage from files without tests |
|
collectCoverageFrom: ["src/**/*.ts"], |
|
coverageReporters: ["html", "lcov"], |
|
coverageDirectory: "coverage", |
|
|
|
testEnvironment: "jsdom", |
|
testMatch: ["**/+(*.)+(spec).+(ts)"], |
|
|
|
roots: ["<rootDir>"], |
|
modulePaths: [compilerOptions.baseUrl], |
|
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: "<rootDir>/" }), |
|
setupFilesAfterEnv: ["<rootDir>/test.setup.ts"], |
|
|
|
// Workaround for a memory leak that crashes tests in CI: |
|
// https://github.com/facebook/jest/issues/9430#issuecomment-1149882002 |
|
// Also anecdotally improves performance when run locally |
|
maxWorkers: 3, |
|
|
|
transform: { |
|
"^.+\\.tsx?$": [ |
|
"jest-preset-angular", |
|
// 'ts-jest', |
|
{ |
|
...defaultTransformerOptions, |
|
tsconfig: "./tsconfig.json", |
|
// Further workaround for memory leak, recommended here: |
|
// https://github.com/kulshekhar/ts-jest/issues/1967#issuecomment-697494014 |
|
// Makes tests run faster and reduces size/rate of leak, but loses typechecking on test code |
|
// See https://bitwarden.atlassian.net/browse/EC-497 for more info |
|
isolatedModules: true, |
|
}, |
|
], |
|
}, |
|
};
|
|
|