test(inspector): keep the cancellation fixture out of underscored temp roots

Fixes #9996

Supersedes #10118

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
MuhammadFaizan-progandgensokyo-dev authored and Ysopwnable committed 2026-11-14 17:59:38 +01:00
1 parent fc4c319cb4
commit f35b6a75b3
2 files changed
+43 -10

No files matched your search

@@ -1,6 +1,5 @@
import { mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { writeFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { pathToFileURL } from "node:url";
import { afterEach, expect, it, vi } from "vitest";
@@ -83,8 +82,8 @@ import { listElectronTargetsInputSchema } from "../domain/javascript/electronObs
import { V8InspectorProvider } from "./V8InspectorProvider.js";
import { startFakeCdpBrowser } from "../../tests/fixtures/fakeCdpBrowser.js";
import { startFakeV8Inspector } from "../../tests/fixtures/inspector/fakeV8Inspector.js";
import { createNodeDiscoveryTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";
const roots: string[] = [];
const fixtures: { close(): Promise<void> }[] = [];
const record = (value: unknown): Record<string, unknown> | undefined =>
@@ -103,14 +102,11 @@ afterEach(async () => {
fileAccess.discoveryGate = undefined;
fileAccess.calls = [];
await Promise.all(fixtures.splice(0).map((fixture) => fixture.close()));
await Promise.all(
roots.splice(0).map((root) => rm(root, { recursive: true, force: true })),
);
});
const targetFile = async (): Promise<string> => {
const root = await mkdtemp(join(tmpdir(), "rea-inspector-cancel-"));
roots.push(root);
// Node discovery reports this path, so its root must be reported exactly.
const root = await createNodeDiscoveryTempDirectory("rea-inspector-cancel-");
const path = join(root, "entry.js");
await writeFile(path, "// inert target file\n");
fileAccess.path = path;
@@ -119,7 +115,7 @@ const targetFile = async (): Promise<string> => {
it("stops Inspector target authorization after the current stat settles", async () => {
const path = await targetFile();
const extraPath = join(roots[0]!, "second.js");
const extraPath = join(dirname(path), "second.js");
await writeFile(extraPath, "// second inert target file\n");
fileAccess.extraPath = extraPath;
const fake = await startFakeV8Inspector({