diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js index f87144076bfe56e8ec6929eeab2d5bf5093e04ab..6a6ce934a7df8eb6065e1b250d7f398cc5091941 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 652e2c5fcca99e5ee5746e32534eed47cb0c03b3..6cb20282b61702fd79956348751bb518dd65a439 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 0000000000000000000000000000000000000000..ed3ea2bff7041c0b138738b7be52c3c418d3bf95 --- /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 684353ff163544c40b97d6b7f74b24ad6009bd42..4cc848026555e1848c8a7ff745baaa5127dac5a8 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) {