-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathpoll.ts
More file actions
29 lines (23 loc) · 1.16 KB
/
poll.ts
File metadata and controls
29 lines (23 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { setTimeout } from 'node:timers/promises';
import { getGlobalVariable } from '../../utils/env';
import { appendToFile } from '../../utils/fs';
import { waitForAnyProcessOutputToMatch } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
const webpackGoodRegEx = getGlobalVariable('argv')['esbuild']
? /Application bundle generation complete\./
: / Compiled successfully\./;
export default async function () {
await ngServe('--poll=10000');
// Wait before editing a file.
// Editing too soon seems to trigger a rebuild and throw polling out of whack.
await setTimeout(3000);
await appendToFile('src/main.ts', 'console.log(1);');
// We have to wait poll time + rebuild build time for the regex match.
await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000);
// No rebuilds should occur for a while
await appendToFile('src/main.ts', 'console.log(1);');
await expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000));
// But a rebuild should happen roughly within the 10 second window.
await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000);
}