@@ -16,6 +16,7 @@ describe('registerSpaApps', () => {
1616 let composeAppSlotPairsStub : SinonStub ;
1717 let mockSlot : any ;
1818 let asyncBootUpWaitForSlotStub : SinonStub ;
19+ let registeredAppsResult : { destroy : ( ) => Promise < void [ ] > } | null = null ;
1920 let testCounter = 0 ;
2021
2122 beforeEach ( ( ) => {
@@ -103,8 +104,10 @@ describe('registerSpaApps', () => {
103104
104105 afterEach ( async ( ) => {
105106 // Unload all registered apps from single-spa to avoid conflicts with other tests
106- const registeredApps = singleSpa . getAppNames ( ) ;
107- await Promise . all ( registeredApps . map ( ( appName ) => singleSpa . unloadApplication ( appName ) ) ) ;
107+ if ( registeredAppsResult ) {
108+ await registeredAppsResult . destroy ( ) ;
109+ registeredAppsResult = null ;
110+ }
108111
109112 // Restore stubs
110113 composeAppSlotPairsStub . restore ( ) ;
@@ -122,7 +125,7 @@ describe('registerSpaApps', () => {
122125
123126 describe ( 'registerApplications' , ( ) => {
124127 it ( 'should register applications with single-spa' , ( ) => {
125- registerApplications (
128+ registeredAppsResult = registerApplications (
126129 mockIlcConfigRoot ,
127130 mockRouter ,
128131 mockAppErrorHandlerFactory ,
@@ -139,7 +142,7 @@ describe('registerSpaApps', () => {
139142 } ) ;
140143
141144 it ( 'should create custom props for each application' , ( ) => {
142- registerApplications (
145+ registeredAppsResult = registerApplications (
143146 mockIlcConfigRoot ,
144147 mockRouter ,
145148 mockAppErrorHandlerFactory ,
@@ -177,7 +180,7 @@ describe('registerSpaApps', () => {
177180 slotElement2 . id = `ilc-slot-${ secondSlotName } ` ;
178181 document . body . appendChild ( slotElement2 ) ;
179182
180- registerApplications (
183+ registeredAppsResult = registerApplications (
181184 mockIlcConfigRoot ,
182185 mockRouter ,
183186 mockAppErrorHandlerFactory ,
@@ -193,7 +196,7 @@ describe('registerSpaApps', () => {
193196 } ) ;
194197
195198 it ( 'should call composeAppSlotPairsToRegister with ilcConfigRoot' , ( ) => {
196- registerApplications (
199+ registeredAppsResult = registerApplications (
197200 mockIlcConfigRoot ,
198201 mockRouter ,
199202 mockAppErrorHandlerFactory ,
@@ -211,7 +214,7 @@ describe('registerSpaApps', () => {
211214 // Make getSdkFactoryByApplicationName throw an error
212215 mockSdkFactoryBuilder . getSdkFactoryByApplicationName . throws ( new Error ( 'SDK factory error' ) ) ;
213216
214- registerApplications (
217+ registeredAppsResult = registerApplications (
215218 mockIlcConfigRoot ,
216219 mockRouter ,
217220 mockAppErrorHandlerFactory ,
@@ -233,7 +236,7 @@ describe('registerSpaApps', () => {
233236 it ( 'should register app with correct activity function' , async ( ) => {
234237 mockRouter . isAppWithinSlotActive . returns ( false ) ;
235238
236- registerApplications (
239+ registeredAppsResult = registerApplications (
237240 mockIlcConfigRoot ,
238241 mockRouter ,
239242 mockAppErrorHandlerFactory ,
@@ -254,7 +257,7 @@ describe('registerSpaApps', () => {
254257 } ) ;
255258
256259 it ( 'should preload app bundle' , ( ) => {
257- registerApplications (
260+ registeredAppsResult = registerApplications (
258261 mockIlcConfigRoot ,
259262 mockRouter ,
260263 mockAppErrorHandlerFactory ,
@@ -278,7 +281,7 @@ describe('registerSpaApps', () => {
278281 wrappedWith : 'wrapperApp' ,
279282 } ) ;
280283
281- registerApplications (
284+ registeredAppsResult = registerApplications (
282285 mockIlcConfigRoot ,
283286 mockRouter ,
284287 mockAppErrorHandlerFactory ,
@@ -294,7 +297,7 @@ describe('registerSpaApps', () => {
294297 } ) ;
295298
296299 it ( 'should register with custom props containing appId' , ( ) => {
297- registerApplications (
300+ registeredAppsResult = registerApplications (
298301 mockIlcConfigRoot ,
299302 mockRouter ,
300303 mockAppErrorHandlerFactory ,
@@ -315,7 +318,7 @@ describe('registerSpaApps', () => {
315318 } ) ;
316319
317320 it ( 'should register with custom props containing domElementGetter' , ( ) => {
318- registerApplications (
321+ registeredAppsResult = registerApplications (
319322 mockIlcConfigRoot ,
320323 mockRouter ,
321324 mockAppErrorHandlerFactory ,
@@ -342,7 +345,7 @@ describe('registerSpaApps', () => {
342345 } ,
343346 } ) ;
344347
345- registerApplications (
348+ registeredAppsResult = registerApplications (
346349 mockIlcConfigRoot ,
347350 mockRouter ,
348351 mockAppErrorHandlerFactory ,
@@ -361,7 +364,7 @@ describe('registerSpaApps', () => {
361364 const mockPathProps = { testProp : 'testValue' } ;
362365 mockRouter . getCurrentRouteProps . returns ( mockPathProps ) ;
363366
364- registerApplications (
367+ registeredAppsResult = registerApplications (
365368 mockIlcConfigRoot ,
366369 mockRouter ,
367370 mockAppErrorHandlerFactory ,
@@ -379,7 +382,7 @@ describe('registerSpaApps', () => {
379382 it ( 'should register apps with getCurrentBasePath function' , ( ) => {
380383 mockRouter . getCurrentRoute . returns ( { basePath : '/test-base' } ) ;
381384
382- registerApplications (
385+ registeredAppsResult = registerApplications (
383386 mockIlcConfigRoot ,
384387 mockRouter ,
385388 mockAppErrorHandlerFactory ,
0 commit comments