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

test: 优化 adb 截图区域

上级 9c54d09e
jest.setTimeout(20000); jest.setTimeout(20000);
const PAGE_PATH = "/pages/API/navigator/new-page/onLoad"; const PAGE_PATH = "/pages/API/navigator/new-page/onLoad";
const INTERMEDIATE_PAGE_PATH = "/pages/API/navigator/new-page/new-page-1"; const INTERMEDIATE_PAGE_PATH = "/pages/API/navigator/new-page/new-page-1";
const TARGET_PAGE_PATH = "/pages/API/navigator/new-page/new-page-3"; const TARGET_PAGE_PATH = "/pages/API/navigator/new-page/new-page-3";
let page; let page;
describe("onLoad", () => { describe("onLoad", () => {
it("adjustData", async () => { it("adjustData", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "adjustData"); await page.callMethod("navigateToOnLoadWithType", "adjustData");
await page.waitFor(100); await page.waitFor(100);
const image = await program.screenshot(); const image = await program.screenshot();
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
}); });
it("navigateTo", async () => { it("navigateTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateTo"); await page.callMethod("navigateToOnLoadWithType", "navigateTo");
await page.waitFor(100); await page.waitFor(100);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("navigateBack", async () => { it("navigateBack", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateBack"); await page.callMethod("navigateToOnLoadWithType", "navigateBack");
page = await program.currentPage(); page = await program.currentPage();
await page.waitFor('view'); await page.waitFor('view');
expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1)); expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1));
}); });
it("redirectTo", async () => { it("redirectTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "redirectTo"); await page.callMethod("navigateToOnLoadWithType", "redirectTo");
await page.waitFor(100); await page.waitFor(100);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("reLaunch", async () => { it("reLaunch", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "reLaunch"); await page.callMethod("navigateToOnLoadWithType", "reLaunch");
await page.waitFor(100); await page.waitFor(100);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("switchTab", async () => { it("switchTab", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "switchTab"); await page.callMethod("navigateToOnLoadWithType", "switchTab");
page = await program.currentPage(); page = await program.currentPage();
await page.waitFor(100); await page.waitFor(100);
expect(page.path).toBe("pages/tabBar/component"); expect(page.path).toBe("pages/tabBar/component");
}); });
it("showToast", async () => { it("showToast", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view'); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "showToast"); await page.callMethod("navigateToOnLoadWithType", "showToast");
await page.waitFor(500); await page.waitFor(500);
const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); const image = await program.screenshot({
expect(image).toMatchImageSnapshot(); adb: true,
await page.waitFor('view'); area: {
}); x: 0,
it("showLoading", async () => { y: 200,
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); height: 2340
await page.waitFor('view'); }
await page.callMethod("navigateToOnLoadWithType", "showLoading"); });
await page.waitFor(500); expect(image).toMatchImageSnapshot();
const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); await page.waitFor('view');
expect(image).toMatchImageSnapshot(); });
}); it("showLoading", async () => {
it("showModal", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); await page.waitFor('view');
await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "showLoading");
await page.callMethod("navigateToOnLoadWithType", "showModal"); await page.waitFor(500);
await page.waitFor(500); const image = await program.screenshot({
const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); adb: true,
expect(image).toMatchImageSnapshot(); area: {
}); x: 0,
it("showActionSheet", async () => { y: 200,
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); height: 2340
await page.waitFor('view'); }
await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); });
await page.waitFor(500); expect(image).toMatchImageSnapshot();
const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); });
expect(image).toMatchImageSnapshot(); it("showModal", async () => {
}); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "showModal");
await page.waitFor(500);
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: 2340
}
});
expect(image).toMatchImageSnapshot();
});
it("showActionSheet", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
await page.waitFor(500);
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: 2340
}
});
expect(image).toMatchImageSnapshot();
});
}); });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册