diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js index c7863eb97bf1e8162ee2e593138ac71e5829a995..7311bbde478ea075d1c187e6742f074fa62607aa 100644 --- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js +++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js @@ -5,7 +5,7 @@ let page; describe("getElementByIdForMultipleRootNode", () => { beforeAll(async () => { page = await program.reLaunch(PAGE_PATH); - await page.waitFor(1000); + await page.waitFor('view'); }); it("getElementByNotExistId", async () => { const res = await page.callMethod("getElementByNotExistId"); diff --git a/pages/API/get-element-by-id/get-element-by-id.test.js b/pages/API/get-element-by-id/get-element-by-id.test.js index 00a5f2e78b5a9b162277838a30b2ff502e656ae0..a04f1b1ded90c1768b20e19bb357570782d5d6be 100644 --- a/pages/API/get-element-by-id/get-element-by-id.test.js +++ b/pages/API/get-element-by-id/get-element-by-id.test.js @@ -4,7 +4,7 @@ let page; describe("getElementById", () => { beforeAll(async () => { page = await program.reLaunch(PAGE_PATH); - await page.waitFor(1000); + await page.waitFor('view'); }); it("getElementByNotExistId", async () => { const res = await page.callMethod("getElementByNotExistId"); diff --git a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js index 1c603c6859c06fe41ea1d7ac0716dc18e7c34853..480279377a1a208aa7a9554205ba1505eaa1721b 100644 --- a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js +++ b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js @@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync' describe('getLaunchOptionsSync', () => { it('getLaunchOptionsSync', async () => { const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') await page.callMethod('getLaunchOptionsSync') const data = await page.data() expect(data.checked).toBe(true) diff --git a/pages/API/load-font-face/load-font-face-child.test.js b/pages/API/load-font-face/load-font-face-child.test.js index ad479f5b30c66289750754aacf9f3810799408d3..602fb40f422109a7b0c1b69081125eb2b78c5e96 100644 --- a/pages/API/load-font-face/load-font-face-child.test.js +++ b/pages/API/load-font-face/load-font-face-child.test.js @@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/load-font-face/load-font-face-child' describe('loadFontFace global', () => { beforeAll(async () => { const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(2000) + await page.waitFor('view') }) it('screenshot', async () => { const image = await program.screenshot() diff --git a/pages/API/load-font-face/load-font-face.test.js b/pages/API/load-font-face/load-font-face.test.js index 548343c03b463c9db70cbc2aca8f1bda91076837..826dabee0036a1bf8ab7dc83b647ed08f75f3115 100644 --- a/pages/API/load-font-face/load-font-face.test.js +++ b/pages/API/load-font-face/load-font-face.test.js @@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/load-font-face/load-font-face' describe('loadFontFace', () => { beforeAll(async () => { const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(4000) + await page.waitFor(3000) }) it('screenshot', async () => { const image = await program.screenshot() diff --git a/pages/API/navigator/navigator.test.js b/pages/API/navigator/navigator.test.js index 45c4efc021bac4de92266b8a4a8a93f744c5bfb9..8005eabf5560a5eb6cad34ef410a5b2b8223c1b2 100644 --- a/pages/API/navigator/navigator.test.js +++ b/pages/API/navigator/navigator.test.js @@ -17,12 +17,12 @@ describe('navigator', () => { it('reLaunch', async () => { page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') await page.callMethod('setLifeCycleNum', 0) await page.callMethod('reLaunch') await page.waitFor(500) page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) }) @@ -30,11 +30,11 @@ describe('navigator', () => { it('navigateTo', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateTo') - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) page = await program.navigateBack() - await page.waitFor(500) + await page.waitFor('view') }) it('navigateTo error page', async () => { @@ -52,45 +52,41 @@ describe('navigator', () => { lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(4) page = await program.navigateBack() - await page.waitFor(500) + await page.waitFor('view') }) it('navigateTo relative path', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateToRelativePath1') page = await program.navigateBack() - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) - await page.waitFor(500) }) it('navigateTo relative path ./', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateToRelativePath2') page = await program.navigateBack() - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) - await page.waitFor(500) }) it('navigateTo relative path ../', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateToRelativePath3') page = await program.navigateBack() - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) - await page.waitFor(500) }) it('navigateBack', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateBack') - await page.waitFor(500) page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) }) @@ -98,7 +94,6 @@ describe('navigator', () => { it('navigateBackWithDelta1', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateBackWithDelta1') - await page.waitFor(1000) page = await program.currentPage() expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) lifeCycleNum = await page.callMethod('getLifeCycleNum') @@ -108,11 +103,8 @@ describe('navigator', () => { it('navigateBackWithDelta2', async () => { await page.callMethod('setLifeCycleNum', 0) await program.navigateTo(CHILD2_PAGE_PATH) - await page.waitFor(500) page = await program.navigateTo(CHILD1_PAGE_PATH) - await page.waitFor(500) await page.callMethod('navigateBackWithDelta2') - await page.waitFor(500) page = await program.currentPage() expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) lifeCycleNum = await page.callMethod('getLifeCycleNum') @@ -123,8 +115,8 @@ describe('navigator', () => { page = await program.reLaunch(CURRENT_PAGE_PATH) await page.callMethod('setLifeCycleNum', 0) await page.callMethod('navigateBackWithDelta100') - await page.waitFor(1000) page = await program.currentPage() + await page.waitFor('view') expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) @@ -133,9 +125,8 @@ describe('navigator', () => { it('redirectTo', async () => { await page.callMethod('setLifeCycleNum', 0) await page.callMethod('redirectTo') - await page.waitFor(500) page = await program.redirectTo(CURRENT_PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) }) @@ -144,9 +135,8 @@ describe('navigator', () => { page = await program.reLaunch(CURRENT_PAGE_PATH) await page.callMethod('setLifeCycleNum', 0) await page.callMethod('switchTab') - await page.waitFor(500) page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(2) }) diff --git a/pages/API/navigator/new-page/new-page-2.test.js b/pages/API/navigator/new-page/new-page-2.test.js index 2ea7cadc05aaa00df4b62bb7280d8ed665b61755..99fb3dd5f9ebbc3e3a4e5331c09f7acc3be4d648 100644 --- a/pages/API/navigator/new-page/new-page-2.test.js +++ b/pages/API/navigator/new-page/new-page-2.test.js @@ -1,4 +1,4 @@ -jest.setTimeout(30000) +jest.setTimeout(20000) const PAGE_PATH = '/pages/API/navigator/new-page/new-page-2' const INTERMEDIATE_PAGE_PATH = '/pages/API/navigator/navigator' let page @@ -7,13 +7,13 @@ let lifeCycleNum describe('app-lifecycle', () => { it('onLaunch onShow', async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(1100) }) it('onLastPageBackPress', async () => { page = await program.navigateBack() - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(100) @@ -26,7 +26,7 @@ describe('app-lifecycle', () => { describe('page-lifecycle', () => { it('onLoad onShow onReady', async () => { page = await program.reLaunch(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(120) await page.callMethod('setLifeCycleNum', 0) @@ -48,28 +48,28 @@ describe('page-lifecycle', () => { }) it('onHide', async () => { page = await program.navigateTo(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(-10) page = await program.navigateBack() - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(0) }) it('onUnload', async () => { page = await program.redirectTo(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(-100) await page.callMethod('setLifeCycleNum', 0) }) it('onBackPress', async () => { page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(120) page = await program.navigateBack() - await page.waitFor(1000) + await page.waitFor('view') lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(10) await page.callMethod('setLifeCycleNum', 0) diff --git a/pages/API/navigator/new-page/onLoad.test.js b/pages/API/navigator/new-page/onLoad.test.js index 933193ac4e66d8256654faf0f219ef64fbb9dd38..7708452ba04273098bec9bd9bc41a5b0e2c8e4a0 100644 --- a/pages/API/navigator/new-page/onLoad.test.js +++ b/pages/API/navigator/new-page/onLoad.test.js @@ -7,50 +7,50 @@ let page; describe("onLoad", () => { it("adjustData", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "adjustData"); - await page.waitFor(1000); + await page.waitFor(500); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); it("navigateTo", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "navigateTo"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("navigateBack", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "navigateBack"); - await page.waitFor(1000); page = await program.currentPage(); + await page.waitFor('view'); expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1)); }); it("redirectTo", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "redirectTo"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("reLaunch", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "reLaunch"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("switchTab", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "switchTab"); - await page.waitFor(1000); page = await program.currentPage(); + await page.waitFor('view'); expect(page.path).toBe("pages/tabBar/component"); }); // toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面) @@ -66,7 +66,7 @@ describe("onLoad", () => { // 同 toast // it("showLoading", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showLoading"); // await page.waitFor(1000); // const image = await program.screenshot(); @@ -75,7 +75,7 @@ describe("onLoad", () => { // 同 toast // it("showModal", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showModal"); // await page.waitFor(1000); // const image = await program.screenshot(); @@ -84,7 +84,7 @@ describe("onLoad", () => { // 同 toast // it("showActionSheet", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); // await page.waitFor(1000); // const image = await program.screenshot(); diff --git a/pages/component/general-attribute/general-attribute.test.js b/pages/component/general-attribute/general-attribute.test.js index 2b3d46985745ce2e4d1aef67e61bc07671bb98f9..290b16a577a9149b69d37540c2f0e5075aeefc5a 100644 --- a/pages/component/general-attribute/general-attribute.test.js +++ b/pages/component/general-attribute/general-attribute.test.js @@ -5,7 +5,7 @@ describe('general attribute', () => { beforeAll(async () => { page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') }) it("class & style", async () => { const image = await program.screenshot(); @@ -20,7 +20,7 @@ describe('general attribute', () => { it("ref", async () => { const button = await page.$(".btn-ref"); await button.tap(); - await page.waitFor(1000); + await page.waitFor(500); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); diff --git a/pages/component/general-event/general-event.test.js b/pages/component/general-event/general-event.test.js index be05d4892f91fa854c239fd86c192cdf622ecd3f..ded3853e3ade9b306bb989785cc3cd324494c9e9 100644 --- a/pages/component/general-event/general-event.test.js +++ b/pages/component/general-event/general-event.test.js @@ -5,7 +5,7 @@ describe('event trigger sequence', () => { let el beforeAll(async () => { page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') el = await page.$('.target') })