Skip to content
Merged
Changes from all commits
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
23 changes: 20 additions & 3 deletions packages/core/src/check/progress.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { execFileSync } from 'node:child_process';
import { resolve } from 'node:path';
import { mkdirSync, mkdtempSync, rmSync } from 'node:fs';
import { createRequire } from 'node:module';
import { dirname, join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { expect, it } from 'vitest';
import { afterAll, expect, it } from 'vitest';
import { type ProgressEvent, progress } from '../domain/progress.js';

it('pairs progress events even when a phase fails', async () => {
Expand All @@ -18,8 +20,23 @@ it('pairs progress events even when a phase fails', async () => {
expect(events.map((e) => e.state)).toEqual(['start', 'done']);
expect(events[1]?.ms).toBeGreaterThanOrEqual(0);
});
// The built worker (dist/worker.js), not the source one the rest of the suite runs. Built into
// a private directory: `pnpm build` cleans and rewrites dist/, so a build running alongside
// (turbo, an editor, a second terminal) could delete the bundle mid-import (#58). Inside
// node_modules so the bundle's bare imports still resolve from the package.
const pkg = resolve(import.meta.dirname, '../..');
mkdirSync(join(pkg, 'node_modules'), { recursive: true });
const privateDist = mkdtempSync(join(pkg, 'node_modules/.uptide-progress-test-'));
afterAll(() => rmSync(privateDist, { recursive: true, force: true }));
it('forwards real workspace worker events without serializing the callback', () => {
const entry = pathToFileURL(resolve(import.meta.dirname, '../../dist/index.js')).href;
const tsup = join(
dirname(createRequire(import.meta.url).resolve('tsup/package.json')),
'dist/cli-default.js',
);
execFileSync(process.execPath, [tsup, '--no-dts', '--no-sourcemap', '--out-dir', privateDist], {
cwd: pkg,
});
const entry = pathToFileURL(join(privateDist, 'index.js')).href;
const cwd = resolve(import.meta.dirname, '../../../../fixtures/repos/workspace-consumer');
const output = execFileSync(
process.execPath,
Expand Down
Loading