Skip to content

Commit

Permalink
fix(core): guard the jasmine hooks (#51394)
Browse files Browse the repository at this point in the history
This commit fixes a regression introduced in #50063

Fixes #51382

PR Close #51394
  • Loading branch information
JeanMeche authored and AndrewKushnir committed Aug 21, 2023
1 parent 4b0ef5a commit 36f434e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/testing/src/test_hooks.ts
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 36f434e

Please sign in to comment.