Skip to content

Commit f0d4f38

Browse files
committed
test: add poll test
1 parent 53c1097 commit f0d4f38

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/e2e/tests/build/poll.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
killAllProcesses,
3+
waitForAnyProcessOutputToMatch,
4+
silentExecAndWaitForOutputToMatch
5+
} from '../../utils/process';
6+
import {appendToFile} from '../../utils/fs';
7+
import {expectToFail, wait} from '../../utils/utils';
8+
9+
const webpackGoodRegEx = /webpack: Compiled successfully./;
10+
11+
export default function() {
12+
return silentExecAndWaitForOutputToMatch('ng', ['serve', '--poll=10000'], webpackGoodRegEx)
13+
// Wait before editing a file.
14+
// Editing too soon seems to trigger a rebuild and throw polling out of whack.
15+
.then(() => wait(2000))
16+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
17+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
18+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
19+
// No rebuilds should occur for a while
20+
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 6000)))
21+
// But a rebuild should happen roughly within the 10 second window.
22+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
23+
.then(() => killAllProcesses(), (err: any) => {
24+
killAllProcesses();
25+
throw err;
26+
});
27+
}

0 commit comments

Comments
 (0)