test: tighten browser and memory path assertions

This commit is contained in:
Shakker
2026-05-11 09:22:20 +01:00
parent 6a58d84b2d
commit cdc8247dd8
3 changed files with 24 additions and 3 deletions

View File

@@ -14,7 +14,14 @@ async function withTempDir<T>(run: (tempDir: string) => Promise<T>): Promise<T>
}
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
let error: unknown;
try {
await fs.access(targetPath);
} catch (caught) {
error = caught;
}
expect(error).toBeInstanceOf(Error);
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
}
describe("ensureOutputDirectory", () => {

View File

@@ -104,7 +104,14 @@ describe("pw-tools-core", () => {
}
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
let error: unknown;
try {
await fs.access(targetPath);
} catch (caught) {
error = caught;
}
expect(error).toBeInstanceOf(Error);
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
}
function createDownloadEventHarness() {

View File

@@ -27,7 +27,14 @@ describe("compileMemoryWikiVault", () => {
}
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
let error: unknown;
try {
await fs.access(targetPath);
} catch (caught) {
error = caught;
}
expect(error).toBeInstanceOf(Error);
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
}
function expectDigestPage<T extends { path: string }>(pages: T[], pagePath: string): T {