Skip to content

Commit

Permalink
test(core): Wait for zone stability before test completion (#55468)
Browse files Browse the repository at this point in the history
Need to wait for microtaskEmty to emit or test will leak into others.

PR Close #55468
  • Loading branch information
atscott authored and alxhub committed Apr 23, 2024
1 parent 9894278 commit f84d7dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/test/zone/ng_zone_spec.ts
Expand Up @@ -9,6 +9,7 @@
import {EventEmitter, NgZone} from '@angular/core';
import {fakeAsync, flushMicrotasks, inject, waitForAsync} from '@angular/core/testing';
import {Log} from '@angular/core/testing/src/testing_internal';
import {firstValueFrom} from 'rxjs';

import {scheduleCallbackWithRafRace as scheduler} from '../../src/util/callback_scheduler';
import {global} from '../../src/util/global';
Expand Down Expand Up @@ -1193,10 +1194,13 @@ function commonTests() {
});
});

it('does not throw when apply args array has `undefined`', () => {
it('does not throw when apply args array has `undefined`', async () => {
expect(() => {
coalesceZone.run(function(this: any, arg: any) {}, undefined, [undefined]);
}).not.toThrow();
// wait for the zone to stabilize after the task above. Needed to prevent this from leaking
// into a follow-up test
await firstValueFrom(coalesceZone.onMicrotaskEmpty);
});
});
});
Expand Down

0 comments on commit f84d7dd

Please sign in to comment.