Skip to content

Commit 93c8582

Browse files
clydinalan-agius4
authored andcommitted
test(@angular-devkit/architect): allow asynchronous jobs to start execution before expect
1 parent 5fc18ef commit 93c8582

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/angular_devkit/architect/src/index_spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import { json, schema } from '@angular-devkit/core';
99
import { timer } from 'rxjs';
1010
import { map, take, tap, toArray } from 'rxjs/operators';
11+
import { promisify } from 'util';
1112
import { TestingArchitectHost } from '../testing/testing-architect-host';
1213
import { BuilderOutput, BuilderRun } from './api';
1314
import { Architect } from './architect';
1415
import { createBuilder } from './create-builder';
1516

17+
const flush = promisify(setImmediate);
18+
1619
// tslint:disable-next-line:no-big-function
1720
describe('architect', () => {
1821
let testArchitectHost: TestingArchitectHost;
@@ -81,6 +84,7 @@ describe('architect', () => {
8184
it('runs builders parallel', async () => {
8285
const run = await architect.scheduleBuilder('package:test', {});
8386
const run2 = await architect.scheduleBuilder('package:test', {});
87+
await flush();
8488
expect(called).toBe(2);
8589
expect(await run.result).toEqual(jasmine.objectContaining({ success: true }));
8690
expect(await run2.result).toEqual(jasmine.objectContaining({ success: true }));
@@ -91,6 +95,7 @@ describe('architect', () => {
9195
it('runs targets parallel', async () => {
9296
const run = await architect.scheduleTarget(target1, {});
9397
const run2 = await architect.scheduleTarget(target1, {});
98+
await flush();
9499
expect(called).toBe(2);
95100
expect(await run.result).toEqual(jasmine.objectContaining({ success: true }));
96101
expect(await run2.result).toEqual(jasmine.objectContaining({ success: true }));
@@ -164,6 +169,7 @@ describe('architect', () => {
164169
called++;
165170

166171
for (let x = 0; x < 10; x++) {
172+
await new Promise(setImmediate);
167173
context.reportRunning();
168174
yield { success: true };
169175
results++;

0 commit comments

Comments
 (0)