提交 febdb369 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化测试 waitFor 等待时间

上级 00efb758
......@@ -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");
......
......@@ -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");
......
......@@ -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)
......
......@@ -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()
......
......@@ -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()
......
......@@ -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)
})
......
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)
......
......@@ -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();
......
......@@ -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();
});
......
......@@ -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')
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册