Skip to content

Commit 2bdf99b

Browse files
clydinvikerman
authored andcommitted
test: cleanup poll CLI E2E test (#12497)
* test: cleanup poll CLI E2E test * test(@angular-devkit/build-angular): adjust poll test
1 parent 7d5caeb commit 2bdf99b

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

packages/angular_devkit/build_angular/test/browser/poll_spec_large.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ describe('Browser Builder poll', () => {
1515
beforeEach(done => host.initialize().toPromise().then(done, done.fail));
1616
afterEach(done => host.restore().toPromise().then(done, done.fail));
1717

18-
xit('works', (done) => {
19-
const overrides = { watch: true, poll: 2000 };
18+
it('works', (done) => {
19+
const overrides = { watch: true, poll: 10000 };
2020
const intervals: number[] = [];
2121
let startTime: number | undefined;
2222
runTargetSpec(host, browserTargetSpec, overrides).pipe(
@@ -30,12 +30,12 @@ describe('Browser Builder poll', () => {
3030
startTime = Date.now();
3131
host.appendToFile('src/main.ts', 'console.log(1);');
3232
}),
33-
take(6),
33+
take(4),
3434
).subscribe(undefined, done.fail, () => {
3535
intervals.sort();
3636
const median = intervals[Math.trunc(intervals.length / 2)];
37-
expect(median).toBeGreaterThan(1000);
38-
expect(median).toBeLessThan(4000);
37+
expect(median).toBeGreaterThan(3000);
38+
expect(median).toBeLessThan(12000);
3939
done();
4040
});
4141
});
+18-28
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,32 @@
1+
import { appendToFile } from '../../utils/fs';
12
import {
23
killAllProcesses,
34
waitForAnyProcessOutputToMatch,
4-
execAndWaitForOutputToMatch
55
} 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';
88

99
const webpackGoodRegEx = /: Compiled successfully./;
1010

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');
1514

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)
2715
// Wait before editing a file.
2816
// 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+
3120
// 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+
3423
// 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+
3627
// 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+
}
4232
}

0 commit comments

Comments
 (0)