Skip to content

Commit bcfccc9

Browse files
alan-agius4dgp1130
authored andcommitted
test: refactor web-worker to wait for filesystem to be fully settled
1 parent cdde7a0 commit bcfccc9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/angular_devkit/build_angular/test/browser/web-worker_spec_large.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import { Architect } from '@angular-devkit/architect';
1010
import { TestLogger } from '@angular-devkit/architect/testing';
1111
import { join, virtualFs } from '@angular-devkit/core';
12-
import { debounceTime, takeWhile, tap } from 'rxjs/operators';
12+
import { timer } from 'rxjs';
13+
import { debounceTime, map, switchMap, takeWhile, tap } from 'rxjs/operators';
1314
import { browserBuild, createArchitect, host, outputPath } from '../utils';
1415

1516

@@ -140,15 +141,14 @@ describe('Browser Builder Web Worker support', () => {
140141
const workerPath = join(outputPath, '0.worker.js');
141142
let workerContent = '';
142143

143-
const run = await architect.scheduleTarget(target, overrides);
144-
await run.output.pipe(
145-
// Wait for files to be written to disk.
146-
// FIXME: Not quite sure why such a long 'debounceTime' is needed.
147-
// Anything under `2500` is a constant failure locally when using
148-
// 'fdescribe' and this tests doesn't run as first one and is also rather flaky on CI.
149-
// It seems that the outputted files contents don't get updated in time.
150-
debounceTime(2500),
151-
tap((buildEvent) => expect(buildEvent.success).toBe(true, 'build should succeed')),
144+
// The current linux-based CI environments may not fully settled in regards to filesystem
145+
// changes from previous tests which reuse the same directory and fileset.
146+
// The initial delay helps mitigate false positive rebuild triggers in such scenarios.
147+
const { run } = await timer(1000).pipe(
148+
switchMap(() => architect.scheduleTarget(target, overrides)),
149+
switchMap(run => run.output.pipe(map(output => ({ run, output })))),
150+
debounceTime(500),
151+
tap(({ output }) => expect(output.success).toBe(true, 'build should succeed')),
152152
tap(() => {
153153
switch (phase) {
154154
case 1:

0 commit comments

Comments
 (0)