Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/tests/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { vi } from 'vitest';
import { beforeEach, vi } from 'vitest';

vi.mock('fs', async () => {
const actual = await vi.importActual<typeof import('fs')>('fs');
Expand All @@ -18,3 +18,12 @@ vi.mock('fs', async () => {
},
};
});

// Captured before any test can install fake timers, so this yield always
// uses the real timer. Suites made of synchronous spawnSync tests can keep
// a worker's event loop blocked for the whole file (>60s), which makes
// vitest's fixed 60s worker->main `onTaskUpdate` RPC timeout fire and the
// run exit 1 with every test green. Yielding between tests releases the
// loop so the RPC response is always processed in time.
const realSetTimeout = setTimeout;
beforeEach(() => new Promise((resolve) => realSetTimeout(resolve, 0)));
Loading