Files
agentic-dev/scripts/coverage/mutate.test.mjs
Danijel Martinek f77e6ea881 chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo
content deleted, auth-only reference feature, web-next shell, all gates
green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor
library traces, and product naming are curated out; generic template
repairs (coverage provider devDeps, root test:coverage script, live
lint fixes, root-only release-please) are kept. See TEMPLATE.md for
provenance, curation list, and usage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
2026-07-12 20:40:54 +02:00

72 lines
2.4 KiB
JavaScript

import { test, describe } from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import os from "node:os";
import { discoverStrykerConfigs } from "./mutate.mjs";
describe("discoverStrykerConfigs", () => {
test("finds stryker.config.json under packages/* and apps/*", () => {
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "mutate-disc-"));
try {
fs.mkdirSync(path.join(tmpRoot, "packages", "p1"), { recursive: true });
fs.mkdirSync(path.join(tmpRoot, "apps", "a1"), { recursive: true });
fs.mkdirSync(path.join(tmpRoot, "packages", "no-stryker"), {
recursive: true,
});
fs.writeFileSync(
path.join(tmpRoot, "packages", "p1", "stryker.config.json"),
"{}",
);
fs.writeFileSync(
path.join(tmpRoot, "packages", "p1", "package.json"),
JSON.stringify({ name: "@repo/p1" }),
);
fs.writeFileSync(
path.join(tmpRoot, "apps", "a1", "stryker.config.json"),
"{}",
);
fs.writeFileSync(
path.join(tmpRoot, "apps", "a1", "package.json"),
JSON.stringify({ name: "@repo/a1" }),
);
const found = discoverStrykerConfigs(tmpRoot);
assert.equal(found.length, 2);
const names = found.map((f) => f.packageName).sort();
assert.deepEqual(names, ["@repo/a1", "@repo/p1"]);
} finally {
fs.rmSync(tmpRoot, { recursive: true, force: true });
}
});
test("falls back to packageDir when no package.json", () => {
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "mutate-disc2-"));
try {
fs.mkdirSync(path.join(tmpRoot, "packages", "no-pkg-json"), {
recursive: true,
});
fs.writeFileSync(
path.join(tmpRoot, "packages", "no-pkg-json", "stryker.config.json"),
"{}",
);
const found = discoverStrykerConfigs(tmpRoot);
assert.equal(found.length, 1);
assert.equal(found[0].packageName, "packages/no-pkg-json");
} finally {
fs.rmSync(tmpRoot, { recursive: true, force: true });
}
});
test("returns empty when nothing matches", () => {
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "mutate-disc3-"));
try {
const found = discoverStrykerConfigs(tmpRoot);
assert.deepEqual(found, []);
} finally {
fs.rmSync(tmpRoot, { recursive: true, force: true });
}
});
});