From cf5bd8f018c28991b33dec22abd408346edc4528 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Wed, 22 Nov 2023 12:49:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-view-local/web-view-local.test.js | 25 +++++++++++++------ .../web-view-local/web-view-local.uvue | 4 ++- pages/pages.test.js | 10 ++++---- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pages/component/web-view-local/web-view-local.test.js b/pages/component/web-view-local/web-view-local.test.js index ed3ea2bf..f7a01636 100644 --- a/pages/component/web-view-local/web-view-local.test.js +++ b/pages/component/web-view-local/web-view-local.test.js @@ -1,14 +1,23 @@ // uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ -describe('test title', () => { +describe('component-native-web-view', () => { + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/web-view-local/web-view-local'); + await page.waitFor(1000); + }); - let page; - beforeAll(async () => { - page = await program.reLaunch('/pages/component/web-view-local/web-view-local'); - await page.waitFor(1000); - }); + it('check_load_url', async () => { + expect(await page.data('loadError')).toBe(false) + }); - it('check_load_url', async () => { - expect(await page.data('loadError')).toBe(false) + it('screenshot', async () => { + await page.waitFor(async () => { + return await page.data('loadFinish') === true; + }); + const image = await program.screenshot({ + fullPage: true }); + expect(image).toMatchImageSnapshot(); + }); }); diff --git a/pages/component/web-view-local/web-view-local.uvue b/pages/component/web-view-local/web-view-local.uvue index 4cc84802..14048b90 100644 --- a/pages/component/web-view-local/web-view-local.uvue +++ b/pages/component/web-view-local/web-view-local.uvue @@ -10,7 +10,8 @@ export default { data() { return { - loadError: false + loadError: false, + loadFinish: false } }, methods: { @@ -29,6 +30,7 @@ console.log(JSON.stringify(event.type)); }, loaded(event : WebViewLoadedEvent) { + this.loadFinish = true; console.log(JSON.stringify(event.type)); } } diff --git a/pages/pages.test.js b/pages/pages.test.js index 77711411..d88998c6 100755 --- a/pages/pages.test.js +++ b/pages/pages.test.js @@ -8,9 +8,9 @@ const pages = [ '/pages/component/image/image-format', // '/pages/component/image/image-large', // 截图过大 '/pages/component/image/image-mode', - // '/pages/component/image/image-path', // 网络资源加载 + // '/pages/component/image/image-path', // 网络资源加载,单独测试例截图 '/pages/component/image/image', - '/pages/component/input/input', + // '/pages/component/input/input', // 自动获取焦点,单独测试例截图 '/pages/component/list-view/list-view', '/pages/component/navigator/navigate', '/pages/component/navigator/navigator', @@ -36,7 +36,7 @@ const pages = [ // '/pages/component/video/video', '/pages/component/view/view', // '/pages/component/web-view/web-view', // 动态内容 - '/pages/component/web-view-local/web-view-local', + // '/pages/component/web-view-local/web-view-local', // 依赖加载完成回调,单独测试例截图 '/pages/component/general-event/transition-event', // CSS @@ -84,7 +84,7 @@ const pages = [ '/pages/CSS/padding/padding-top', '/pages/CSS/padding/padding', '/pages/CSS/text/color', - // '/pages/CSS/text/font-family', // 网络资源加载 + // '/pages/CSS/text/font-family', // 网络资源加载,单独测试例截图 '/pages/CSS/text/font-size', '/pages/CSS/text/font-style', '/pages/CSS/text/font-weight', @@ -110,7 +110,7 @@ const pages = [ '/pages/template/custom-tab-bar/custom-tab-bar', // '/pages/template/drop-card/drop-card', '/pages/template/half-screen/half-screen', - // '/pages/template/list-news/list-news', // 网络资源加载 + // '/pages/template/list-news/list-news', // 网络资源加载,单独测试例截图 // '/pages/template/long-list/long-list', // 动态内容 '/pages/template/navbar-lite/navbar-lite', '/pages/template/pull-zoom-image/pull-zoom-image', -- GitLab