-
Notifications
You must be signed in to change notification settings - Fork 9
/
common.jest_config.ts
61 lines (58 loc) · 1.93 KB
/
common.jest_config.ts
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
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
import type { Config } from 'jest';
// Extracted from @jest/types
export declare interface ConfigGlobals {
[K: string]: unknown;
}
export function createConfig(testType: string, title: string): Config {
const isUnit = testType.toLowerCase() === "unit";
return {
maxWorkers: isUnit ? "100%" : 1,
testTimeout: 600000,
displayName: title,
modulePathIgnorePatterns: ["__tests__/__snapshots__/"],
transform: { ".(ts)": "ts-jest" },
transformIgnorePatterns: [ "^.+\\.cjs$", "^.+\\.js$", "^.+\\.json$" ],
testRegex: "(test|spec)\\.ts$",
moduleFileExtensions: ["ts", "js", "json"],
testPathIgnorePatterns: ["<rootDir>/__tests__/__results__", `.*/__${isUnit ? "system" : "unit"}__/.*`],
testEnvironment: "node",
collectCoverage: isUnit,
coverageReporters: ["json", "lcov", "text", "cobertura"],
coverageDirectory: `__tests__/__results__/${testType}/coverage`,
collectCoverageFrom: [
"src/**/*.ts",
"!**/__tests__/**",
"!**/index.ts",
"!**/main.ts"
],
reporters: [
"default",
["jest-junit", {
outputFile: `__tests__/__results__/${testType}/junit.xml`,
ancestorSeparator: " > ",
classNameTemplate: `${testType}.{classname}`,
title: "{title}"
}],
["jest-stare", {
resultDir: `__tests__/__results__/${testType}/jest-stare`,
coverageLink: "../coverage/lcov-report/index.html",
resultHtml: "index.html"
}],
["jest-html-reporter", {
pageTitle: title,
outputPath: `__tests__/__results__/${testType}/results.html`,
includeFailureMsg: true
}],
],
};
}