提交 7c30d1ad 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 调整部分测试例,兼容跨平台截图对比

上级 3c6689b4
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-image', () => {
let page;
async function getWindowInfo() {
const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info')
await windowInfoPage.waitFor(600);
return await windowInfoPage.callMethod('jest_getWindowInfo')
}
const screenshotParams = { fullPage: true }
let windowInfo
beforeAll(async () => {
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
screenshotParams.fullPage = false
windowInfo = await getWindowInfo()
let offsetY = '0'
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('android')) {
offsetY = `${windowInfo.statusBarHeight + 44}`
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
offsetY = `${windowInfo.safeAreaInsets.top + 44}`
}
screenshotParams.offsetY = offsetY
}
page = await program.reLaunch('/pages/component/image/image');
await page.waitFor(600);
});
......@@ -52,9 +73,7 @@ describe('component-native-image', () => {
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
})
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
});
......@@ -62,9 +81,7 @@ describe('component-native-image', () => {
if (process.env.android_cpu_type === 'x86_64') return
const page = await program.navigateTo('/pages/component/image/image-mode');
await page.waitFor(1000);
const image = await program.screenshot({
fullPage: true
})
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
});
});
describe('component-native-sticky-header', () => {
let page
async function getWindowInfo() {
const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info')
await windowInfoPage.waitFor(600);
return await windowInfoPage.callMethod('jest_getWindowInfo')
}
const screenshotParams = { fullPage: true }
let windowInfo
beforeAll(async () => {
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
screenshotParams.fullPage = false
windowInfo = await getWindowInfo()
let offsetY = '0'
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('android')) {
offsetY = `${windowInfo.statusBarHeight + 44}`
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
offsetY = `${windowInfo.safeAreaInsets.top + 44}`
}
screenshotParams.offsetY = offsetY
}
page = await program.reLaunch('/pages/component/sticky-header/sticky-header')
await page.waitFor('sticky-header')
})
......@@ -8,7 +28,7 @@ describe('component-native-sticky-header', () => {
//检测吸顶效果
it('check_sticky_header', async () => {
await page.callMethod('confirm_scroll_top_input', 600)
const image = await program.screenshot({fullPage: true});
const image = await program.screenshot(screenshotParams);
expect(image).toSaveImageSnapshot();
})
})
......@@ -2,15 +2,33 @@
describe('template-list-news', () => {
let page;
async function getWindowInfo() {
const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info')
await windowInfoPage.waitFor(600);
return await windowInfoPage.callMethod('jest_getWindowInfo')
}
const screenshotParams = { fullPage: true }
let windowInfo
beforeAll(async () => {
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
screenshotParams.fullPage = false
windowInfo = await getWindowInfo()
let offsetY = '0'
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('android')) {
offsetY = `${windowInfo.statusBarHeight + 44}`
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
offsetY = `${windowInfo.safeAreaInsets.top + 44}`
}
screenshotParams.offsetY = offsetY
}
page = await program.reLaunch('/pages/template/list-news/list-news');
await page.waitFor(3000);
});
it('screenshot', async () => {
const image = await program.screenshot({
fullPage: true
})
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册