1
0

refactor: 清理测试代码 eslint-disable 指令,消除文件级和重复局部禁用

This commit is contained in:
2026-05-21 00:35:08 +08:00
parent ccd16a583e
commit b432581444
6 changed files with 185 additions and 175 deletions

View File

@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
import { mkdir, rm } from "node:fs/promises";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
@@ -45,17 +45,12 @@ describe("parseTargets", () => {
test("无效 target 导致进程退出", () => {
const exitCalls: number[] = [];
// eslint-disable-next-line @typescript-eslint/unbound-method
const originalExit = process.exit;
process.exit = ((code: number) => {
const exitSpy = spyOn(process, "exit").mockImplementation(((code: number) => {
exitCalls.push(code);
}) as never;
}) as typeof process.exit);
try {
parseTargets(["--target", "invalid-target"]);
} finally {
process.exit = originalExit;
}
parseTargets(["--target", "invalid-target"]);
exitSpy.mockRestore();
expect(exitCalls).toEqual([1]);
});