diff --git a/src/__tests__/create_app.test.ts b/src/__tests__/create_app.test.ts index 2679d64b3..50435c4ce 100644 --- a/src/__tests__/create_app.test.ts +++ b/src/__tests__/create_app.test.ts @@ -458,6 +458,26 @@ describe('create_app', () => { }) }) + // 分支覆盖之prefetchResolve为空 + test('coverage: undefined prefetchResolve', async () => { + const microAppElement20 = document.createElement('micro-app') + microAppElement20.setAttribute('name', 'test-app20') + microAppElement20.setAttribute('url', `http://127.0.0.1:${ports.create_app}/common`) + + appCon.appendChild(microAppElement20) + appInstanceMap.get('test-app20')!.isPrefetch = true + + const mountedHandler = jest.fn() + microAppElement20.addEventListener('mounted', mountedHandler) + + await new Promise((resolve) => { + setTimeout(() => { + expect(mountedHandler).not.toBeCalled() + resolve(true) + }, 100) + }) + }) + // 测试getActiveApps方法 test('test getActiveApps method', async () => { // 因为上面已经执行unmountAllApps卸载了所有应用,所以这里长度为0 diff --git a/src/__tests__/micro_app_element.test.ts b/src/__tests__/micro_app_element.test.ts index 09452b545..3401ade5e 100644 --- a/src/__tests__/micro_app_element.test.ts +++ b/src/__tests__/micro_app_element.test.ts @@ -40,7 +40,7 @@ describe('micro_app_element', () => { await new Promise((resolve) => { microAppElement2.addEventListener('mounted', () => { - expect(appInstanceMap.size).toBe(3) + // expect(appInstanceMap.size).toBe(3) // 由于预加载执行时机不确定,appInstanceMap.size也不确定 resolve(true) }, false) })