diff --git a/packages/angular_devkit/build_angular/test/browser/poll_spec_large.ts b/packages/angular_devkit/build_angular/test/browser/poll_spec_large.ts index d3565810baf3..ea2b42387d58 100644 --- a/packages/angular_devkit/build_angular/test/browser/poll_spec_large.ts +++ b/packages/angular_devkit/build_angular/test/browser/poll_spec_large.ts @@ -15,8 +15,8 @@ describe('Browser Builder poll', () => { beforeEach(done => host.initialize().toPromise().then(done, done.fail)); afterEach(done => host.restore().toPromise().then(done, done.fail)); - xit('works', (done) => { - const overrides = { watch: true, poll: 2000 }; + it('works', (done) => { + const overrides = { watch: true, poll: 10000 }; const intervals: number[] = []; let startTime: number | undefined; runTargetSpec(host, browserTargetSpec, overrides).pipe( @@ -30,12 +30,12 @@ describe('Browser Builder poll', () => { startTime = Date.now(); host.appendToFile('src/main.ts', 'console.log(1);'); }), - take(6), + take(4), ).subscribe(undefined, done.fail, () => { intervals.sort(); const median = intervals[Math.trunc(intervals.length / 2)]; - expect(median).toBeGreaterThan(1000); - expect(median).toBeLessThan(4000); + expect(median).toBeGreaterThan(3000); + expect(median).toBeLessThan(12000); done(); }); }); diff --git a/tests/legacy-cli/e2e/tests/build/poll.ts b/tests/legacy-cli/e2e/tests/build/poll.ts index a76a8c6f1052..e2aacf46f586 100644 --- a/tests/legacy-cli/e2e/tests/build/poll.ts +++ b/tests/legacy-cli/e2e/tests/build/poll.ts @@ -1,42 +1,32 @@ +import { appendToFile } from '../../utils/fs'; import { killAllProcesses, waitForAnyProcessOutputToMatch, - execAndWaitForOutputToMatch } from '../../utils/process'; -import {appendToFile} from '../../utils/fs'; -import {expectToFail, wait} from '../../utils/utils'; +import { ngServe } from '../../utils/project'; +import { expectToFail, wait } from '../../utils/utils'; const webpackGoodRegEx = /: Compiled successfully./; -export default function() { - // TODO(architect): This test is behaving oddly both here and in devkit/build-angular. - // It seems to be because of file watchers. - return; +export default async function() { + try { + await ngServe('--poll=10000'); - - // @filipesilva: This test doesn't work correctly on CircleCI while being ran by the test script. - // Polling time seems to be ignored and several builds are fired per second. - // Debugging showed that webpack things the `src/` directory changed on each rebuild. - // Disabling for now. - if (process.env['CIRCLECI']) { - return; - } - - - return execAndWaitForOutputToMatch('ng', ['build', '--watch', '--poll=10000'], webpackGoodRegEx) // Wait before editing a file. // Editing too soon seems to trigger a rebuild and throw polling out of whack. - .then(() => wait(3000)) - .then(() => appendToFile('src/main.ts', 'console.log(1);')) + await wait(3000); + await appendToFile('src/main.ts', 'console.log(1);'); + // We have to wait poll time + rebuild build time for the regex match. - .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000)) - .then(() => appendToFile('src/main.ts', 'console.log(1);')) + await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 14000); + // No rebuilds should occur for a while - .then(() => expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000))) + await appendToFile('src/main.ts', 'console.log(1);'); + await expectToFail(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000)); + // But a rebuild should happen roughly within the 10 second window. - .then(() => waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000)) - .then(() => killAllProcesses(), (err: any) => { - killAllProcesses(); - throw err; - }); + await waitForAnyProcessOutputToMatch(webpackGoodRegEx, 7000); + } finally { + killAllProcesses(); + } }