diff --git a/packages/core/testing/src/test_hooks.ts b/packages/core/testing/src/test_hooks.ts index ada3632d428..4165d3485db 100644 --- a/packages/core/testing/src/test_hooks.ts +++ b/packages/core/testing/src/test_hooks.ts @@ -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 () => {