image.test.js 1.2 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/

describe('component-native-image', () => {

    let page;
    beforeAll(async () => {
        page = await program.reLaunch('/pages/component/image/image');
        await page.waitFor(600);
    });

    it('check_image_load', async () => {
         expect(await page.data('loadError')).toBe(false)
    });
shutao-dc's avatar
shutao-dc 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

    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)
    })
32 33 34 35 36 37 38 39 40

    it('path-screenshot', async () => {
      const page = await program.navigateTo('/pages/component/image/image-path');
      await page.waitFor(3000);
      const image = await program.screenshot({
        fullPage: true
      })
      expect(image).toMatchImageSnapshot()
    });
shutao-dc's avatar
shutao-dc 已提交
41
});