fix(core): guard the jasmine hooks (#51394)

This commit fixes a regression introduced in #50063

Fixes #51382

PR Close #51394
This commit is contained in:
Matthieu Riegler
2023-08-16 23:10:09 +02:00
committed by Andrew Kushnir
parent 4b0ef5acfb
commit 36f434e49d
+6 -2
View File
@@ -16,12 +16,16 @@ import {resetFakeAsyncZone} from './fake_async';
import {TestBedImpl} from './test_bed';
// Reset the test providers and the fake async zone before each test.
beforeEach(getCleanupHook(false));
// We keep a guard because somehow this file can make it into a bundle and be executed
// beforeEach is only defined when executing the tests
globalThis.beforeEach?.(getCleanupHook(false));
// We provide both a `beforeEach` and `afterEach`, because the updated behavior for
// tearing down the module is supposed to run after the test so that we can associate
// teardown errors with the correct test.
afterEach(getCleanupHook(true));
// We keep a guard because somehow this file can make it into a bundle and be executed
// afterEach is only defined when executing the tests
globalThis.afterEach?.(getCleanupHook(true));
function getCleanupHook(expectedTeardownValue: boolean) {
return () => {