Skip to content

Commit c037c58

Browse files
alan-agius4mmalerba
authored andcommitted
refactor(core): expose getCleanupHook via private exports (#61017)
Expose `getCleanupHook` as a private export to address integration issues with Vitest. In Vitest, `globalThis.beforeEach` and `globalThis.afterEach` are not available by default. Additionally, these hooks are patched during module evaluation, complicating seamless integration with Vitest. See: angular/angular-cli#30188 PR Close #61017
1 parent 09cc394 commit c037c58

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

packages/core/testing/src/test_hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ globalThis.beforeEach?.(getCleanupHook(false));
2727
// afterEach is only defined when executing the tests
2828
globalThis.afterEach?.(getCleanupHook(true));
2929

30-
function getCleanupHook(expectedTeardownValue: boolean) {
30+
export function getCleanupHook(expectedTeardownValue: boolean): VoidFunction {
3131
return () => {
3232
const testBed = TestBedImpl.INSTANCE;
3333
if (testBed.shouldTearDownTestingModule() === expectedTeardownValue) {

packages/core/testing/src/testing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export {
3838
TestEnvironmentOptions,
3939
ModuleTeardownOptions,
4040
} from './test_bed_common';
41-
export * from './test_hooks';
41+
export {__core_private_testing_placeholder__} from './test_hooks';
4242
export * from './metadata_override';
4343
export {MetadataOverrider as ɵMetadataOverrider} from './metadata_overrider';
4444
export {

packages/core/testing/src/testing_private_export.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*/
88

99
export {FakeNavigation as ɵFakeNavigation} from '../../primitives/dom-navigation/testing';
10+
export {getCleanupHook as ɵgetCleanupHook} from './test_hooks';

0 commit comments

Comments
 (0)