get-element-by-id.test.js 951 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5
const PAGE_PATH = "/pages/API/get-element-by-id/get-element-by-id";
let page;

describe("getElementById", () => {
  beforeAll(async () => {
6
    page = await program.reLaunch(PAGE_PATH);
7
    await page.waitFor('view');
DCloud-WZF's avatar
DCloud-WZF 已提交
8 9 10
  });
  it("getElementByNotExistId", async () => {
    const res = await page.callMethod("getElementByNotExistId");
11
    expect(res).toBe(null);
DCloud-WZF's avatar
DCloud-WZF 已提交
12 13
  });
  it("changeStyle", async () => {
雪洛's avatar
雪洛 已提交
14 15 16
    if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
      await page.callMethod("changePageHeadBackgroundColor");
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18
    await page.callMethod("changeTextColor");
    await page.callMethod("changeViewStyle");
19
    await page.waitFor(500);
20
    const image = await program.screenshot({fullPage: true});
21
    expect(image).toSaveImageSnapshot();
DCloud-WZF's avatar
DCloud-WZF 已提交
22
  });
23 24 25 26 27 28 29
  /**
   * 检测元素offsetLeft属性值域
   */
  it("checkElementOffsetLeft", async() => {
    const res = await page.callMethod("getTextOffsetLeft");
    expect(res).toBe(0);
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
30
});