Skip to content

Commit 140c989

Browse files
committed
test: add poll test
1 parent aafc003 commit 140c989

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/e2e/tests/build/poll.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
killAllProcesses,
3+
waitForAnyProcessOutputToMatch,
4+
silentExecAndWaitForOutputToMatch
5+
} from '../../utils/process';
6+
import {appendToFile} from '../../utils/fs';
7+
import {expectToFail} from '../../utils/utils';
8+
9+
const webpackGoodRegEx = /webpack: bundle is now VALID|webpack: Compiled successfully./;
10+
11+
export default function() {
12+
if (process.platform.startsWith('win')) {
13+
return Promise.resolve();
14+
}
15+
16+
return silentExecAndWaitForOutputToMatch('ng', ['serve', '--poll=10000'], webpackGoodRegEx)
17+
// Wait for the first rebuild.
18+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
19+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
20+
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
21+
// No rebuilds should occur for a while
22+
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 5000)))
23+
// But a rebuild should happen roughly within the 10 second window.
24+
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 10000))
25+
.then(() => killAllProcesses(), (err: any) => {
26+
killAllProcesses();
27+
throw err;
28+
});
29+
}

0 commit comments

Comments
 (0)