Skip to content

Commit

Permalink
fix: update timeout error handling in tests for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Dec 22, 2024
1 parent 7c63688 commit 110f684
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mount_point.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Filesystem Metadata", () => {
// < timeouts on windows are handled by the native bindings, and don't know about the magick "timeoutMs = 1" test option.
it("should timeout mount points if timeoutMs = 1", async () => {
await expect(getVolumeMountPoints({ timeoutMs: 1 })).rejects.toThrow(
/TimeoutError/, // < we can't check for instanceOf TimeoutError because it's imported from the tsup bundle
/timeout/i, // < we can't check for instanceOf TimeoutError because it's imported from the tsup bundle
);
});
}
Expand Down
7 changes: 4 additions & 3 deletions src/volume_metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { MiB } from "./units.js";
const rootPath = systemDrive();

describe("Volume Metadata", () => {
beforeEach(() => {
jest.setTimeout(30_000);
});
it("should get root filesystem metadata", async () => {
const metadata = await getVolumeMetadata(rootPath);

Expand Down Expand Up @@ -56,8 +59,6 @@ describe("Volume Metadata errors", () => {
});

describe("concurrent", () => {
jest.setTimeout(30_000);

it("should handle concurrent getVolumeMetadata() calls", async () => {
const mountPoints = await getVolumeMountPoints();
const expectedMountPoint = systemDrive();
Expand Down Expand Up @@ -91,7 +92,7 @@ describe("concurrent", () => {
} catch (error) {
if (timeoutMs === 1) {
console.log("Expected timeout", { mountPoint, timeoutMs, error });
expect(String(error)).toMatch(/TimeoutError/); // < we can't check for instanceOf TimeoutError because it's imported from the tsup bundle
expect(String(error)).toMatch(/timeout/i); // < we can't check for instanceOf TimeoutError because it's imported from the tsup bundle
return;
} else if (!validMountPoints.includes(mountPoint)) {
console.log("Expected bad mount point", {
Expand Down

0 comments on commit 110f684

Please sign in to comment.