Skip to content

Commit

Permalink
test: add poll test
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Feb 16, 2017
1 parent 53c1097 commit f0d4f38
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/e2e/tests/build/poll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
killAllProcesses,
waitForAnyProcessOutputToMatch,
silentExecAndWaitForOutputToMatch
} from '../../utils/process';
import {appendToFile} from '../../utils/fs';
import {expectToFail, wait} from '../../utils/utils';

const webpackGoodRegEx = /webpack: Compiled successfully./;

export default function() {
return silentExecAndWaitForOutputToMatch('ng', ['serve', '--poll=10000'], webpackGoodRegEx)
// Wait before editing a file.
// Editing too soon seems to trigger a rebuild and throw polling out of whack.
.then(() => wait(2000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
.then(() => appendToFile('src/main.ts', 'console.log(1);'))
// No rebuilds should occur for a while
.then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 6000)))
// But a rebuild should happen roughly within the 10 second window.
.then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 12000))
.then(() => killAllProcesses(), (err: any) => {
killAllProcesses();
throw err;
});
}

0 comments on commit f0d4f38

Please sign in to comment.