Files
reverse-engineering-anything/tests/boundary/filesystem/temporaryDirectory.test.ts
morluto dee8853fde chore(deps): upgrade typescript, vitest, and MCP SDK to latest (#633)
typescript 5.9.3 to 7.0.2, vitest 4.1.10 to 5.0.3 (plus
@vitest/coverage-v8 and @fast-check/vitest 0.5.0 for peer compat),
@Modelcontextprotocol/client and server 2.0.0 to 2.3.1. Migrate the
removed describe.sequential to concurrent:false and regenerate
package metadata and product catalog.

Also restore byte-faithful reads in parseCliJsonInput: the safeJson
migration dropped the fatal UTF-8 check from #613. Vitest 5 requires
Node 22/24/26+, so verify on Node 24 (repo-pinned toolchain).
2026-10-06 05:15:17 +08:00

37 lines
1.3 KiB
TypeScript

import { access, realpath, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { describe, expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
describe("test temporary directory ownership", { concurrent: false }, () => {
let completedDirectory: string | undefined;
it("creates a canonical directory owned by the current test", async () => {
const directory = await createTestTempDirectory("rea-owned-temp-");
completedDirectory = directory;
expect(directory).toBe(await realpath(directory));
expect(dirname(directory)).toBe(await realpath(tmpdir()));
await writeFile(join(directory, "nested.txt"), "owned");
});
it("removes the prior test directory after that test finishes", async () => {
const directory = completedDirectory;
if (directory === undefined)
throw new Error("Prior test did not create a directory");
await expect(access(directory)).rejects.toMatchObject({
code: "ENOENT",
});
});
it.each(["", "../escape-", "/absolute-", "missing-dash"])(
"rejects unsafe prefix %j",
async (prefix) => {
await expect(createTestTempDirectory(prefix)).rejects.toThrow(TypeError);
},
);
});