Skip to content

Commit 9f5cb1e

Browse files
committed
test: fix code coverage reporting
1 parent 876976a commit 9f5cb1e

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed
Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
/** @type {import('@jest/types').Config.InitialOptions} */
2-
module.exports = {
1+
import type { Config } from "jest";
2+
3+
const config: Config = {
34
testEnvironment: "jsdom",
45
transform: {
5-
"^.+\\.(t|j)sx?$": ["@swc/jest"],
6+
"^.+\\.(t|j)sx?$": "@swc/jest",
67
},
8+
setupFilesAfterEnv: ["<rootDir>/testSetup/init.ts"],
79
moduleNameMapper: {
810
// https://github.com/microsoft/accessibility-insights-web/pull/5421#issuecomment-1109168149
911
"^nanoid": require.resolve("nanoid"),
1012
"\\.scss$": "identity-obj-proxy",
1113
},
12-
setupFilesAfterEnv: ["<rootDir>/testSetup/init.ts"],
13-
collectCoverageFrom: [
14-
"<rootDir>/src/**/*.{ts,tsx}",
15-
"!<rootDir>/src/index.ts",
16-
],
14+
15+
testPathIgnorePatterns: ["/node_modules/", "/cypress/"],
16+
1717
watchPlugins: [
1818
"jest-watch-typeahead/filename",
1919
"jest-watch-typeahead/testname",
2020
],
21-
testPathIgnorePatterns: ["/node_modules/", "/cypress/"],
21+
22+
// this is required to get the correct line coverage when using swc for some
23+
// reason.
24+
coverageProvider: "v8",
25+
26+
collectCoverageFrom: [
27+
"<rootDir>/src/**/*.{ts,tsx}",
28+
"!<rootDir>/src/index.ts",
29+
],
2230
};
31+
32+
export default config;

0 commit comments

Comments
 (0)