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

test: 优化测试例

上级 d41a32ad
...@@ -125,19 +125,20 @@ const pages = [ ...@@ -125,19 +125,20 @@ const pages = [
'/pages/API/element-draw/element-draw', '/pages/API/element-draw/element-draw',
] ]
const needLoadingNetworkResourcesPages = [ const needDelayPages = [
"/pages/CSS/text/font-family", "/pages/CSS/text/font-family", // load network font
"/pages/template/list-news/list-news", "/pages/template/list-news/list-news", // load network image
"/pages/component/list-view/list-view", // delay wait scroll to disappear
]; ];
let page; let page;
describe('page screenshot test', () => { describe("page screenshot test", () => {
beforeAll(async () => { beforeAll(async () => {
console.log("page screenshot test start"); console.log("page screenshot test start");
}); });
beforeEach(async () => { beforeEach(async () => {
page = await program.reLaunch(pages[pageIndex]); page = await program.reLaunch(pages[pageIndex]);
if (needLoadingNetworkResourcesPages.includes(pages[pageIndex])) { if (needDelayPages.includes(pages[pageIndex])) {
await page.waitFor(2000); await page.waitFor(2000);
} }
await page.waitFor(1000); await page.waitFor(1000);
...@@ -148,11 +149,11 @@ describe('page screenshot test', () => { ...@@ -148,11 +149,11 @@ describe('page screenshot test', () => {
afterAll(() => { afterAll(() => {
console.log("page screenshot test finish"); console.log("page screenshot test finish");
}); });
test.each(pages)('%s', async () => { test.each(pages)("%s", async () => {
const image = await program.screenshot({ const image = await program.screenshot({
fullPage: true fullPage: true,
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
await page.waitFor(500); await page.waitFor(500);
}) });
}) });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册