Skip to content

Commit 36f434e

Browse files
JeanMecheAndrewKushnir
authored andcommittedAug 21, 2023
fix(core): guard the jasmine hooks (#51394)
This commit fixes a regression introduced in #50063 Fixes #51382 PR Close #51394
1 parent 4b0ef5a commit 36f434e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎packages/core/testing/src/test_hooks.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ import {resetFakeAsyncZone} from './fake_async';
1616
import {TestBedImpl} from './test_bed';
1717

1818
// Reset the test providers and the fake async zone before each test.
19-
beforeEach(getCleanupHook(false));
19+
// We keep a guard because somehow this file can make it into a bundle and be executed
20+
// beforeEach is only defined when executing the tests
21+
globalThis.beforeEach?.(getCleanupHook(false));
2022

2123
// We provide both a `beforeEach` and `afterEach`, because the updated behavior for
2224
// tearing down the module is supposed to run after the test so that we can associate
2325
// teardown errors with the correct test.
24-
afterEach(getCleanupHook(true));
26+
// We keep a guard because somehow this file can make it into a bundle and be executed
27+
// afterEach is only defined when executing the tests
28+
globalThis.afterEach?.(getCleanupHook(true));
2529

2630
function getCleanupHook(expectedTeardownValue: boolean) {
2731
return () => {

0 commit comments

Comments
 (0)
Please sign in to comment.