-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.mjs
65 lines (58 loc) · 1.68 KB
/
jest.config.mjs
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
//@ts-check
import { argv, platform } from "node:process";
const otherPlatforms = ["linux", "darwin", "windows"]
.filter((ea) => ea !== (platform === "win32" ? "windows" : platform))
.map((ea) => `/${ea}/`);
/** @type {import('ts-jest').JestConfigWithTsJest} */
const config = {
displayName: "@photostructure/fs-metadata (ESM)",
testEnvironment: "jest-environment-node",
roots: ["<rootDir>/src"],
coverageProvider: "v8",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.(m)?ts$": [
"ts-jest",
{
useESM: true,
tsconfig: "tsconfig.jest-esm.json",
},
],
},
extensionsToTreatAsEsm: [".ts", ".mts"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
collectCoverage:
argv.includes("--coverage") && !argv.includes("--no-coverage"),
coverageDirectory: "coverage",
coverageReporters: ["text", "lcov"],
collectCoverageFrom: ["src/**/*.ts"],
coveragePathIgnorePatterns: [
"debuglog",
"/test-utils/",
"/types/",
...otherPlatforms,
],
coverageThreshold: {
// These are low because we're doing integration tests and there are quite
// different codepaths for macOS, Windows, and Linux
// As of 20241205, Windows (which is the lowest due to not testing the POSIX
// codepaths) is at { stmts: 82, branch: 75, funcs: 87, lines: 82 } so this
// gives us a little wiggle room
global: {
statements: 90,
branches: 80,
functions: 90,
lines: 90,
},
},
verbose: true,
silent: false,
randomize: true,
setupFilesAfterEnv: [
"jest-extended/all",
"<rootDir>/src/test-utils/jest-matchers.ts",
],
};
export default config;