@@ -21,14 +21,13 @@ import "zone.js";
21
21
import "zone.js/testing" ;
22
22
23
23
// Import Angular testing utilities
24
- import { getTestBed , TestBed } from "@angular/core/testing" ;
25
- import { BrowserDynamicTestingModule , platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing" ;
24
+ import { TestBed } from "@angular/core/testing" ;
26
25
27
26
// Ensure Zone.js testing environment is properly configured
28
27
beforeEach ( ( ) => {
29
28
// Reset Zone.js state before each test
30
29
if ( typeof Zone !== "undefined" ) {
31
- Zone . current . fork ( { } ) . run ( ( ) => {
30
+ Zone . current . fork ( { name : "test-zone" } ) . run ( ( ) => {
32
31
// Run each test in a fresh zone
33
32
} ) ;
34
33
}
@@ -41,13 +40,6 @@ import * as matchers from "@testing-library/jest-dom/matchers";
41
40
// Extend Vitest's expect with jest-dom matchers
42
41
expect . extend ( matchers ) ;
43
42
44
- // Initialize the testing environment with Zone.js support
45
- if ( ! TestBed . platform ) {
46
- TestBed . initTestEnvironment ( BrowserDynamicTestingModule , platformBrowserDynamicTesting ( ) , {
47
- teardown : { destroyAfterEach : false } ,
48
- } ) ;
49
- }
50
-
51
43
// Reset TestBed after each test to prevent configuration conflicts
52
44
afterEach ( ( ) => {
53
45
TestBed . resetTestingModule ( ) ;
@@ -60,11 +52,11 @@ declare global {
60
52
}
61
53
62
54
// Define global test utilities
63
- globalThis . spyOn = ( obj : any , method : string ) => {
55
+ ( globalThis as any ) . spyOn = ( obj : any , method : string ) => {
64
56
const spy = vi . spyOn ( obj , method ) ;
65
57
// Add Jasmine-compatible methods
66
- spy . and = {
67
- callFake : ( fn : Function ) => {
58
+ ( spy as any ) . and = {
59
+ callFake : ( fn : ( ... args : any [ ] ) => any ) => {
68
60
spy . mockImplementation ( fn ) ;
69
61
return spy ;
70
62
} ,
@@ -77,7 +69,7 @@ globalThis.spyOn = (obj: any, method: string) => {
77
69
return spy ;
78
70
} ,
79
71
} ;
80
- spy . calls = {
72
+ ( spy as any ) . calls = {
81
73
reset : ( ) => spy . mockClear ( ) ,
82
74
all : ( ) => spy . mock . calls ,
83
75
count : ( ) => spy . mock . calls . length ,
@@ -86,6 +78,6 @@ globalThis.spyOn = (obj: any, method: string) => {
86
78
} ;
87
79
return spy ;
88
80
} ;
89
- globalThis . pending = ( reason ?: string ) => {
81
+ ( globalThis as any ) . pending = ( reason ?: string ) => {
90
82
throw new Error ( `Test pending: ${ reason || "No reason provided" } ` ) ;
91
83
} ;
0 commit comments