element-takesnapshot.test.js 1020 字节
Newer Older
1 2 3 4
const PAGE_PATH = "/pages/API/element-takesnapshot/element-takesnapshot";


describe("element-takesnapshot", () => {
5
  if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
雪洛's avatar
雪洛 已提交
6 7 8 9 10
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }
11 12 13 14 15 16 17 18 19 20 21
  let page;
  function getData(key = '') {
    return new Promise(async (resolve, reject) => {
      const data = await page.data()
      resolve(key ? data[key] : data)
    })
  }


  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
22
    await page.waitFor(1200);
23 24 25 26
  });


  it("takeSnapshot", async () => {
27
    await page.waitFor(1200)
28 29
    let btnTakeSnapshot = await page.$('.btn-TakeSnapshot')
    await btnTakeSnapshot.tap()
30
    await page.waitFor(1200)
31 32 33 34 35 36
    const image = await getData('snapImage')
    console.log(image)
    ///storage/emulated/0/Android/data/io.dcloud.uniappx/apps/__UNI__3584C99/cache/temp/screenshot/1697513148915.png
    expect(image.length).toBeGreaterThan(20)
  });
});