Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion packages/rstack/tests/config/reload-doc-config/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { getRandomPort } from '@rstackjs/test-utils';
import { getRandomPort, waitFor } from '@rstackjs/test-utils';
import { test } from '#test-helpers';

test('should restart doc dev server when Rstack config changes', async ({
Expand Down Expand Up @@ -45,6 +45,8 @@ define.doc({
`doc --config test-temp-rstack.config.ts --port ${await getRandomPort()}`,
);
await logHelper.expectBuildEnd();
// The build log can arrive before the restart watcher finishes its initial scan.
await waitFor(100);
logHelper.clearLogs();

await writeConfig('after config change');
Expand All @@ -53,6 +55,7 @@ define.doc({
'restarting server as test-temp-rstack.config.ts changed',
);
await logHelper.expectBuildEnd();
await waitFor(100);
logHelper.clearLogs();

await writeFile(userWatchFile, 'changed\n');
Expand Down Expand Up @@ -96,6 +99,7 @@ define.doc({
`doc --config test-temp-import.config.ts --port ${await getRandomPort()}`,
);
await logHelper.expectBuildEnd();
await waitFor(100);
logHelper.clearLogs();

await writeFile(
Expand Down Expand Up @@ -150,6 +154,7 @@ define.doc({
expect(await initialResponse.text()).toContain(
'<title>before import change</title>',
);
await waitFor(100);
logHelper.clearLogs();

await writeFile(
Expand Down
7 changes: 6 additions & 1 deletion packages/rstack/tests/config/reload-lib-config/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { waitForFile } from '@rstackjs/test-utils';
import { waitFor, waitForFile } from '@rstackjs/test-utils';
import { test } from '#test-helpers';

test('should restart lib watch build when Rstack config changes', async ({
Expand Down Expand Up @@ -44,6 +44,8 @@ define.lib({
execCliAsync('lib --watch --config test-temp-rstack.config.ts');
await logHelper.expectLog('build completed, watching for changes...');
await waitForFile(path.join(dist1, 'index.js'));
// The build log precedes the restart watcher's initial filesystem scan.
await waitFor(100);
logHelper.clearLogs();

await writeConfig('dist-2');
Expand All @@ -53,6 +55,7 @@ define.lib({
);
await logHelper.expectLog('build completed, watching for changes...');
await waitForFile(path.join(dist2, 'index.js'));
await waitFor(100);
logHelper.clearLogs();

await writeFile(userWatchFile, 'changed\n');
Expand Down Expand Up @@ -93,6 +96,7 @@ define.lib({
execCliAsync('lib --watch --config test-temp-import.config.ts');
await logHelper.expectLog('build completed, watching for changes...');
await waitForFile(path.join(dist1, 'index.js'));
await waitFor(100);
logHelper.clearLogs();

await writeFile(importedFile, "export const distPath = 'dist-import-2';\n");
Expand Down Expand Up @@ -138,6 +142,7 @@ define.extends([sharedConfig]);
execCliAsync('lib --watch --config test-temp-shared.config.ts');
await logHelper.expectLog('build completed, watching for changes...');
await waitForFile(path.join(dist1, 'index.js'));
await waitFor(100);
logHelper.clearLogs();

await writeFile(
Expand Down
Loading