diff --git a/src/__tests__/async-behavior.test.ts b/src/__tests__/async-behavior.test.ts index e4286fb..96971bd 100644 --- a/src/__tests__/async-behavior.test.ts +++ b/src/__tests__/async-behavior.test.ts @@ -1,7 +1,7 @@ // src/__tests__/async-behavior.test.ts import { times } from "../array.js"; -import { TimeoutError } from "../async.js"; +import { delay, TimeoutError } from "../async.js"; import { defer } from "../defer.js"; import { ExcludedMountPointGlobsDefault, @@ -88,8 +88,9 @@ describe("Filesystem API Async Behavior", () => { // sometimes thenOrTimeout() fails to reject in time jest.retryTimes(5); }); - afterEach(() => { + afterEach(async () => { jest.retryTimes(0); + await delay(500); }); it("getVolumeMountPoints() should reject with timeoutMs=1", async () => { await expect(getVolumeMountPoints({ timeoutMs: 1 })).rejects.toThrow( diff --git a/src/__tests__/unix.test.ts b/src/__tests__/unix.test.ts index 81c921f..8a0c5be 100644 --- a/src/__tests__/unix.test.ts +++ b/src/__tests__/unix.test.ts @@ -1,5 +1,6 @@ // src/__tests__/unix.test.ts +import { sortByStr } from "../array.js"; import { ExcludedMountPointGlobsDefault, getVolumeMetadata, @@ -74,7 +75,7 @@ describePlatform("linux", "darwin")( it("should return sorted mount points", async () => { const mountPoints = await getVolumeMountPoints(); - const sorted = [...mountPoints].sort(); + const sorted = sortByStr([...mountPoints], (ea) => ea); expect(mountPoints).toEqual(sorted); }); }); @@ -199,6 +200,11 @@ describePlatform("linux", "darwin")( ...ExcludedMountPointGlobsDefault, "/init", "/boot", + // Avoid: "/System/Volumes/Data", "/System/Volumes/Data/home", + // "/System/Volumes/Hardware", "/System/Volumes/Preboot", + // "/System/Volumes/Update", "/System/Volumes/VM", + // "/System/Volumes/iSCPreboot", "/System/Volumes/xarts", + "/System/**", ], }); const arr = await Promise.all( diff --git a/src/async.ts b/src/async.ts index 6ddcd20..956b09c 100644 --- a/src/async.ts +++ b/src/async.ts @@ -73,3 +73,12 @@ export function thenOrTimeout( timeoutPromise, ]); } + +/** + * Delay for the specified number of milliseconds. + * + * @param ms The number of milliseconds to delay + */ +export async function delay(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +}