Ports the kept-file portions of the upstream infra audit-fix subset onto the clean-slate template branch (auth-only shape; workspaces feature never existed here, so its package.json edit is skipped): - resolve the root playwright config in pnpm test:visual (S8) - prune dead VERCEL_ENV from turbo.json globalEnv (S9) - drop the duplicate chromium install in the storybook CI job (S10) - wire scripts/**/*.test.mjs under a dedicated vitest runner (vitest.scripts.config.mjs + pnpm test:scripts + CI validate step); convert node:test imports to vitest keeping node:assert - ignore *.tsbuildinfo repo-wide and untrack the committed build state - align every @trpc/* range on ^11.18.0 so the workspace resolves to a single version (peer-warning-free install) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
// Runs under vitest (pnpm test:scripts picks up scripts/**/*.test.mjs);
|
|
// node:assert keeps the original assertion style.
|
|
import { test, describe } from "vitest";
|
|
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 });
|
|
}
|
|
});
|
|
});
|