|
1 | 1 | import assert from 'node:assert';
|
2 |
| -import { setTimeout } from 'node:timers/promises'; |
3 | 2 | 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'; |
5 | 9 |
|
6 | 10 | export default async function () {
|
7 | 11 | await ng('cache', 'clean');
|
8 | 12 | await ng('cache', 'on');
|
9 | 13 |
|
10 | 14 | 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 | + ); |
11 | 22 |
|
12 | 23 | 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`), |
21 | 26 | ]);
|
22 | 27 |
|
23 | 28 | assert(response.ok, `Expected 'response.ok' to be 'true'.`);
|
|
0 commit comments