|
| 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: 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(() => wait(2000)) |
| 20 | + .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 10000)) |
| 21 | + .then(() => appendToFile('src/main.ts', 'console.log(1);')) |
| 22 | + .then(() => wait(2000)) |
| 23 | + // No rebuilds should occur for a while |
| 24 | + .then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 4000))) |
| 25 | + // But a rebuild should happen roughly within the 10 second window. |
| 26 | + .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 10000)) |
| 27 | + .then(() => killAllProcesses(), (err: any) => { |
| 28 | + killAllProcesses(); |
| 29 | + throw err; |
| 30 | + }); |
| 31 | +} |
0 commit comments