|
| 1 | +import { appendToFile } from '../../utils/fs'; |
1 | 2 | import {
|
2 | 3 | killAllProcesses,
|
3 | 4 | waitForAnyProcessOutputToMatch,
|
4 |
| - execAndWaitForOutputToMatch |
5 | 5 | } from '../../utils/process';
|
6 |
| -import {appendToFile} from '../../utils/fs'; |
7 |
| -import {expectToFail, wait} from '../../utils/utils'; |
| 6 | +import { ngServe } from '../../utils/project'; |
| 7 | +import { expectToFail, wait } from '../../utils/utils'; |
8 | 8 |
|
9 | 9 | const webpackGoodRegEx = /: Compiled successfully./;
|
10 | 10 |
|
11 |
| -export default function() { |
12 |
| - // TODO(architect): This test is behaving oddly both here and in devkit/build-angular. |
13 |
| - // It seems to be because of file watchers. |
14 |
| - return; |
| 11 | +export default async function() { |
| 12 | + try { |
| 13 | + await ngServe('--poll=10000'); |
15 | 14 |
|
16 |
| - |
17 |
| - // @filipesilva: This test doesn't work correctly on CircleCI while being ran by the test script. |
18 |
| - // Polling time seems to be ignored and several builds are fired per second. |
19 |
| - // Debugging showed that webpack things the `src/` directory changed on each rebuild. |
20 |
| - // Disabling for now. |
21 |
| - if (process.env['CIRCLECI']) { |
22 |
| - return; |
23 |
| - } |
24 |
| - |
25 |
| - |
26 |
| - return execAndWaitForOutputToMatch('ng', ['build', '--watch', '--poll=10000'], webpackGoodRegEx) |
27 | 15 | // Wait before editing a file.
|
28 | 16 | // Editing too soon seems to trigger a rebuild and throw polling out of whack.
|
29 |
| - .then(() => wait(3000)) |
30 |
| - .then(() => appendToFile('src/main.ts', 'console.log(1);')) |
| 17 | + await wait(3000); |
| 18 | + await appendToFile('src/main.ts', 'console.log(1);'); |
| 19 | + |
31 | 20 | // We have to wait poll time + rebuild build time for the regex match.
|
32 |
| - .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000)) |
33 |
| - .then(() => appendToFile('src/main.ts', 'console.log(1);')) |
| 21 | + await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000); |
| 22 | + |
34 | 23 | // No rebuilds should occur for a while
|
35 |
| - .then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000))) |
| 24 | + await appendToFile('src/main.ts', 'console.log(1);'); |
| 25 | + await expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000)); |
| 26 | + |
36 | 27 | // But a rebuild should happen roughly within the 10 second window.
|
37 |
| - .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000)) |
38 |
| - .then(() => killAllProcesses(), (err: any) => { |
39 |
| - killAllProcesses(); |
40 |
| - throw err; |
41 |
| - }); |
| 28 | + await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000); |
| 29 | + } finally { |
| 30 | + killAllProcesses(); |
| 31 | + } |
42 | 32 | }
|
0 commit comments