Skip to content

Commit 87b310a

Browse files
committed
test: reduce flakiness of reuse-dep-optimization-cache e2e test
This commit reduces test flakiness by modifying the logic to perform the fetch only after the app is bundled.
1 parent 04f331a commit 87b310a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import assert from 'node:assert';
2-
import { setTimeout } from 'node:timers/promises';
32
import { findFreePort } from '../../utils/network';
4-
import { execAndWaitForOutputToMatch, killAllProcesses, ng } from '../../utils/process';
3+
import {
4+
execAndWaitForOutputToMatch,
5+
killAllProcesses,
6+
ng,
7+
waitForAnyProcessOutputToMatch,
8+
} from '../../utils/process';
59

610
export default async function () {
711
await ng('cache', 'clean');
812
await ng('cache', 'on');
913

1014
const port = await findFreePort();
15+
await execAndWaitForOutputToMatch(
16+
'ng',
17+
['serve', '--port', `${port}`],
18+
/Application bundle generation complete/,
19+
// Use CI:0 to force caching
20+
{ DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' },
21+
);
1122

1223
const [, response] = await Promise.all([
13-
execAndWaitForOutputToMatch(
14-
'ng',
15-
['serve', '--port', `${port}`],
16-
/dependencies optimized/,
17-
// Use CI:0 to force caching
18-
{ DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' },
19-
),
20-
setTimeout(4_000).then(() => fetch(`http://localhost:${port}/main.js`)),
24+
waitForAnyProcessOutputToMatch(/dependencies optimized/, 10_000),
25+
fetch(`http://localhost:${port}/main.js`),
2126
]);
2227

2328
assert(response.ok, `Expected 'response.ok' to be 'true'.`);

0 commit comments

Comments
 (0)