diff --git a/scripts/coverage-partitions.spec.ts b/scripts/coverage-partitions.spec.ts index 1a17a746c1..264a2686c4 100644 --- a/scripts/coverage-partitions.spec.ts +++ b/scripts/coverage-partitions.spec.ts @@ -28,6 +28,14 @@ async function temporaryRoot(): Promise { return await mkdtemp(join(tmpdir(), 'dsh-coverage-partitions-')) } +function successfulCommandRecorder(commands: CoverageCommand[]) { + return vi.fn(async (command: CoverageCommand) => { + commands.push(command) + await writeBlob(command) + return passed + }) +} + describe('coverage partition count', () => { it.each([ [undefined, undefined], @@ -77,11 +85,7 @@ describe('coverage partition coordinator', () => { it('runs every single-worker partition before one merged threshold check', async () => { const root = await temporaryRoot() const commands: CoverageCommand[] = [] - const runCommand = vi.fn(async (command: CoverageCommand) => { - commands.push(command) - await writeBlob(command) - return passed - }) + const runCommand = successfulCommandRecorder(commands) const coordinator = new CoveragePartitionCoordinator({ root, partitions: 3, @@ -128,11 +132,7 @@ describe('coverage partition coordinator', () => { it('runs a native pnpm entrypoint directly', async () => { const root = await temporaryRoot() const commands: CoverageCommand[] = [] - const runCommand = vi.fn(async (command: CoverageCommand) => { - commands.push(command) - await writeBlob(command) - return passed - }) + const runCommand = successfulCommandRecorder(commands) const coordinator = new CoveragePartitionCoordinator({ root, partitions: 2,