-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstryker.shared.test.ts
More file actions
55 lines (47 loc) · 1.75 KB
/
Copy pathstryker.shared.test.ts
File metadata and controls
55 lines (47 loc) · 1.75 KB
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
import { afterEach, describe, expect, it, vi } from "vitest";
import { packageStrykerConfig } from "./stryker.shared";
describe("packageStrykerConfig", () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it("gates the package on its own break threshold in a plain local run", () => {
vi.stubEnv("MUTATION_DEFER_BREAK", undefined);
expect(packageStrykerConfig({ breakThreshold: 80 }).thresholds?.break).toBe(
80,
);
});
it("leaves the break threshold out when the workflow defers it to the merged gate", () => {
vi.stubEnv("MUTATION_DEFER_BREAK", "true");
expect(
packageStrykerConfig({ breakThreshold: 80 }).thresholds,
).not.toHaveProperty("break");
});
it("keeps the high and low colour thresholds whichever way the break is decided", () => {
vi.stubEnv("MUTATION_DEFER_BREAK", "true");
expect(packageStrykerConfig({ breakThreshold: 80 }).thresholds).toEqual({
high: 80,
low: 60,
});
});
it("records no break for a package that passes none, deferred or not", () => {
vi.stubEnv("MUTATION_DEFER_BREAK", undefined);
expect(packageStrykerConfig().thresholds).not.toHaveProperty("break");
});
it("mutates every source file under src by default", () => {
expect(packageStrykerConfig().mutate).toContain("src/**/*.ts");
});
it("excludes test files and test-support after a package's own globs", () => {
expect(
packageStrykerConfig({ mutate: ["src/**/*.ts", "src/**/*.tsx"] }).mutate,
).toEqual([
"src/**/*.ts",
"src/**/*.tsx",
"!src/**/*.test.ts",
"!src/**/*.test.tsx",
"!src/**/test-support/**",
]);
});
it("writes the json report the merged gate reads", () => {
expect(packageStrykerConfig().reporters).toContain("json");
});
});