mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 01:54:04 +08:00
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.
This commit is contained in:
parent
04f331a534
commit
87b310a13f
@ -1,23 +1,28 @@
|
|||||||
import assert from 'node:assert';
|
import assert from 'node:assert';
|
||||||
import { setTimeout } from 'node:timers/promises';
|
|
||||||
import { findFreePort } from '../../utils/network';
|
import { findFreePort } from '../../utils/network';
|
||||||
import { execAndWaitForOutputToMatch, killAllProcesses, ng } from '../../utils/process';
|
import {
|
||||||
|
execAndWaitForOutputToMatch,
|
||||||
|
killAllProcesses,
|
||||||
|
ng,
|
||||||
|
waitForAnyProcessOutputToMatch,
|
||||||
|
} from '../../utils/process';
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
await ng('cache', 'clean');
|
await ng('cache', 'clean');
|
||||||
await ng('cache', 'on');
|
await ng('cache', 'on');
|
||||||
|
|
||||||
const port = await findFreePort();
|
const port = await findFreePort();
|
||||||
|
await execAndWaitForOutputToMatch(
|
||||||
|
'ng',
|
||||||
|
['serve', '--port', `${port}`],
|
||||||
|
/Application bundle generation complete/,
|
||||||
|
// Use CI:0 to force caching
|
||||||
|
{ DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' },
|
||||||
|
);
|
||||||
|
|
||||||
const [, response] = await Promise.all([
|
const [, response] = await Promise.all([
|
||||||
execAndWaitForOutputToMatch(
|
waitForAnyProcessOutputToMatch(/dependencies optimized/, 10_000),
|
||||||
'ng',
|
fetch(`http://localhost:${port}/main.js`),
|
||||||
['serve', '--port', `${port}`],
|
|
||||||
/dependencies optimized/,
|
|
||||||
// Use CI:0 to force caching
|
|
||||||
{ DEBUG: 'vite:deps', CI: '0', NO_COLOR: 'true' },
|
|
||||||
),
|
|
||||||
setTimeout(4_000).then(() => fetch(`http://localhost:${port}/main.js`)),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert(response.ok, `Expected 'response.ok' to be 'true'.`);
|
assert(response.ok, `Expected 'response.ok' to be 'true'.`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user