Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7c30d1ad
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7c30d1ad
编写于
4月 07, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 调整部分测试例,兼容跨平台截图对比
上级
3c6689b4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
115 addition
and
60 deletion
+115
-60
pages/component/image/image.test.js
pages/component/image/image.test.js
+73
-56
pages/component/sticky-header/sticky-header.test.js
pages/component/sticky-header/sticky-header.test.js
+21
-1
pages/template/list-news/list-news.test.js
pages/template/list-news/list-news.test.js
+21
-3
未找到文件。
pages/component/image/image.test.js
浏览文件 @
7c30d1ad
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-image
'
,
()
=>
{
describe
(
'
component-native-image
'
,
()
=>
{
let
page
;
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
()
=>
{
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
'
);
page
=
await
program
.
reLaunch
(
'
/pages/component/image/image
'
);
await
page
.
waitFor
(
600
);
await
page
.
waitFor
(
600
);
});
});
...
@@ -52,9 +73,7 @@ describe('component-native-image', () => {
...
@@ -52,9 +73,7 @@ describe('component-native-image', () => {
it
(
'
path-screenshot
'
,
async
()
=>
{
it
(
'
path-screenshot
'
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-path
'
);
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-path
'
);
await
page
.
waitFor
(
3000
);
await
page
.
waitFor
(
3000
);
const
image
=
await
program
.
screenshot
({
const
image
=
await
program
.
screenshot
(
screenshotParams
)
fullPage
:
true
})
expect
(
image
).
toSaveImageSnapshot
()
expect
(
image
).
toSaveImageSnapshot
()
});
});
...
@@ -62,9 +81,7 @@ describe('component-native-image', () => {
...
@@ -62,9 +81,7 @@ describe('component-native-image', () => {
if
(
process
.
env
.
android_cpu_type
===
'
x86_64
'
)
return
if
(
process
.
env
.
android_cpu_type
===
'
x86_64
'
)
return
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-mode
'
);
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-mode
'
);
await
page
.
waitFor
(
1000
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
({
const
image
=
await
program
.
screenshot
(
screenshotParams
)
fullPage
:
true
})
expect
(
image
).
toSaveImageSnapshot
()
expect
(
image
).
toSaveImageSnapshot
()
});
});
});
});
pages/component/sticky-header/sticky-header.test.js
浏览文件 @
7c30d1ad
describe
(
'
component-native-sticky-header
'
,
()
=>
{
describe
(
'
component-native-sticky-header
'
,
()
=>
{
let
page
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
()
=>
{
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
'
)
page
=
await
program
.
reLaunch
(
'
/pages/component/sticky-header/sticky-header
'
)
await
page
.
waitFor
(
'
sticky-header
'
)
await
page
.
waitFor
(
'
sticky-header
'
)
})
})
...
@@ -8,7 +28,7 @@ describe('component-native-sticky-header', () => {
...
@@ -8,7 +28,7 @@ describe('component-native-sticky-header', () => {
//检测吸顶效果
//检测吸顶效果
it
(
'
check_sticky_header
'
,
async
()
=>
{
it
(
'
check_sticky_header
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
600
)
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
600
)
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
const
image
=
await
program
.
screenshot
(
screenshotParams
);
expect
(
image
).
toSaveImageSnapshot
();
expect
(
image
).
toSaveImageSnapshot
();
})
})
})
})
pages/template/list-news/list-news.test.js
浏览文件 @
7c30d1ad
...
@@ -2,15 +2,33 @@
...
@@ -2,15 +2,33 @@
describe
(
'
template-list-news
'
,
()
=>
{
describe
(
'
template-list-news
'
,
()
=>
{
let
page
;
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
()
=>
{
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
'
);
page
=
await
program
.
reLaunch
(
'
/pages/template/list-news/list-news
'
);
await
page
.
waitFor
(
3000
);
await
page
.
waitFor
(
3000
);
});
});
it
(
'
screenshot
'
,
async
()
=>
{
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
const
image
=
await
program
.
screenshot
(
screenshotParams
)
fullPage
:
true
})
expect
(
image
).
toSaveImageSnapshot
()
expect
(
image
).
toSaveImageSnapshot
()
});
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录