From b2e6af9af88245b6fb72b14a2b3cdb0f7c41b022 Mon Sep 17 00:00:00 2001 From: shutao Date: Thu, 21 Sep 2023 17:30:31 +0800 Subject: [PATCH] update image.test.js --- pages/component/image/image.test.js | 18 ++++++++++++++++++ pages/component/image/image.uvue | 3 ++- .../web-view-local/web-view-local.test.js | 14 ++++++++++++++ .../web-view-local/web-view-local.uvue | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 pages/component/web-view-local/web-view-local.test.js diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js index f8714407..6a6ce934 100644 --- a/pages/component/image/image.test.js +++ b/pages/component/image/image.test.js @@ -11,4 +11,22 @@ describe('component-native-image', () => { it('check_image_load', async () => { expect(await page.data('loadError')).toBe(false) }); + + it('check_image_load_url', async () => { + await page.setData({ + loadError: false, + imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png' + }) + await page.waitFor(300); + expect(await page.data('loadError')).toBe(false) + }) + + it('check_image_load_error', async () => { + await page.setData({ + loadError: false, + imageSrc: 'testerror.jpg' + }) + await page.waitFor(300); + expect(await page.data('loadError')).toBe(true) + }) }); diff --git a/pages/component/image/image.uvue b/pages/component/image/image.uvue index 652e2c5f..6cb20282 100644 --- a/pages/component/image/image.uvue +++ b/pages/component/image/image.uvue @@ -3,7 +3,7 @@ - @@ -26,6 +26,7 @@ data() { return { title: 'image', + imageSrc: "/static/test-image/logo.png", loadError: false } }, diff --git a/pages/component/web-view-local/web-view-local.test.js b/pages/component/web-view-local/web-view-local.test.js new file mode 100644 index 00000000..ed3ea2bf --- /dev/null +++ b/pages/component/web-view-local/web-view-local.test.js @@ -0,0 +1,14 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('test title', () => { + + 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) + }); +}); diff --git a/pages/component/web-view-local/web-view-local.uvue b/pages/component/web-view-local/web-view-local.uvue index 684353ff..4cc84802 100644 --- a/pages/component/web-view-local/web-view-local.uvue +++ b/pages/component/web-view-local/web-view-local.uvue @@ -10,6 +10,7 @@ export default { data() { return { + loadError: false } }, methods: { @@ -21,6 +22,7 @@ }); }, error(event : WebViewErrorEvent) { + this.loadError = true console.log(JSON.stringify(event.detail)); }, loading(event : WebViewLoadingEvent) { -- GitLab