Skip to content

Commit 533fd21

Browse files
committed
test: Introduce delay for file write to minimize flakiness
With recent updates to Vite, rebuild times have become significantly faster. To ensure reliable testing, we’ve added a deliberate delay to slow down the process during file writes.
1 parent c8955ff commit 533fd21

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/legacy-cli/e2e/tests/vite/reuse-dep-optimization-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ export default async function () {
3939
['serve', '--port=0'],
4040
/Hash is consistent\. Skipping/,
4141
// Use CI:0 to force caching
42-
{ DEBUG: 'vite:deps', CI: '0' },
42+
{ DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' },
4343
);
4444
}

tests/legacy-cli/e2e/tests/vite/ssr-new-dep-optimization.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import assert from 'node:assert';
22
import { setTimeout } from 'node:timers/promises';
3-
import { ng, waitForAnyProcessOutputToMatch } from '../../utils/process';
3+
import {
4+
execAndWaitForOutputToMatch,
5+
ng,
6+
waitForAnyProcessOutputToMatch,
7+
} from '../../utils/process';
48
import { installWorkspacePackages, uninstallPackage } from '../../utils/packages';
5-
import { ngServe, useSha } from '../../utils/project';
9+
import { useSha } from '../../utils/project';
610
import { getGlobalVariable } from '../../utils/env';
711
import { readFile, writeFile } from '../../utils/fs';
12+
import { findFreePort } from '../../utils/network';
813

914
export default async function () {
1015
assert(
@@ -22,7 +27,14 @@ export default async function () {
2227
await useSha();
2328
await installWorkspacePackages();
2429

25-
const port = await ngServe();
30+
// The Node.js specific module should not be found
31+
const port = await findFreePort();
32+
await execAndWaitForOutputToMatch(
33+
'ng',
34+
['serve', '--port', port.toString()],
35+
/Application bundle generation complete/,
36+
{ CI: '0', NO_COLOR: 'true' },
37+
);
2638
await validateResponse('/', /Hello,/);
2739

2840
const appConfigContentsUpdated = `

0 commit comments

Comments
 (0)