Files
OmniRoute/tests/unit/build/check-test-runner-api.test.ts
Diego Rodrigues de Sa e Souza d8967efc6c cherry-pick(pr-9605): ci(test): route orphaned Vitest tests through blocking CI (#9875)
* ci(test): route orphaned Vitest tests through blocking CI

* docs: fix advisory status in AGENTS.md and refresh baseline note

* fix(changelog): fix fragment format for #9415

* fix(changelog): preserve upstream fragment format

---------

Co-authored-by: MohitRawat017 <rawatmohit17906@gmail.com>
Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
2026-08-09 09:54:56 -03:00

57 lines
1.9 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { findRunnerMismatches } from "../../../scripts/check/check-test-runner-api.mjs";
function tmpRepo() {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "runner-api-"));
fs.mkdirSync(path.join(root, "tests/unit/autoCombo"), { recursive: true });
return root;
}
test("flags a vitest-only-dir test that imports node:test", () => {
const root = tmpRepo();
fs.writeFileSync(
path.join(root, "tests/unit/autoCombo/bad.test.ts"),
`import { describe, it } from "node:test";\ndescribe("x", () => it("y", () => {}));\n`
);
const bad = findRunnerMismatches(root);
assert.equal(bad.length, 1);
assert.match(bad[0].file.replace(/\\/g, "/"), /autoCombo\/bad\.test\.ts$/);
assert.match(bad[0].reason, /vitest-only/);
fs.rmSync(root, { recursive: true, force: true });
});
test("accepts a vitest-only-dir test that imports vitest", () => {
const root = tmpRepo();
fs.writeFileSync(
path.join(root, "tests/unit/autoCombo/good.test.ts"),
`import { describe, it } from "vitest";\ndescribe("x", () => it("y", () => {}));\n`
);
assert.equal(findRunnerMismatches(root).length, 0);
fs.rmSync(root, { recursive: true, force: true });
});
test("flags node:test imports in the Vitest-only config roots", () => {
const root = tmpRepo();
const dirs = [
"open-sse/services/__tests__",
"open-sse/translator/helpers/__tests__",
"src/lib/memory/__tests__",
"src/lib/skills/__tests__",
];
for (const dir of dirs) {
fs.mkdirSync(path.join(root, dir), { recursive: true });
fs.writeFileSync(
path.join(root, dir, "bad.test.ts"),
`import { describe, it } from "node:test";\ndescribe("x", () => it("y", () => {}));\n`
);
}
assert.equal(findRunnerMismatches(root).length, dirs.length);
fs.rmSync(root, { recursive: true, force: true });
});