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
;
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
);
});
let
page
;
it
(
'
check_image_load
'
,
async
()
=>
{
beforeAll
(
async
()
=>
{
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
)
page
=
await
program
.
reLaunch
(
'
/pages/component/image/image
'
);
});
await
page
.
waitFor
(
600
);
});
it
(
'
check_image_load
'
,
async
()
=>
{
it
(
'
check_image_load_url
'
,
async
()
=>
{
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
)
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_url
'
,
async
()
=>
{
it
(
'
check_image_load_error
'
,
async
()
=>
{
await
page
.
setData
({
await
page
.
setData
({
loadError
:
false
,
loadError
:
false
,
imageSrc
:
'
https://request.dcloud.net.cn/api/http/contentType/image/png
'
imageSrc
:
'
testerror.jpg
'
})
await
page
.
waitFor
(
300
);
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
)
})
})
await
page
.
waitFor
(
300
);
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
true
)
})
it
(
'
check_image_load_error
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
it
(
'
check-cookie
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
,
setCookieImage
:
'
https://cdn.dcloud.net.cn/img/shadow-grey.png
'
});
await
page
.
waitFor
(
1000
);
await
page
.
setData
({
await
page
.
setData
({
loadError
:
false
,
loadError
:
false
,
imageSrc
:
'
testerror.jpg
'
verifyCookieImage
:
'
https://request.dcloud.net.cn/img/shadow-grey.png
'
})
});
await
page
.
waitFor
(
300
);
await
page
.
waitFor
(
1000
);
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
true
)
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
);
await
page
.
setData
({
autoTest
:
false
});
})
})
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
it
(
'
path-screenshot
'
,
async
()
=>
{
it
(
'
check-cookie
'
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-path
'
);
await
page
.
setData
({
await
page
.
waitFor
(
3000
);
autoTest
:
true
,
const
image
=
await
program
.
screenshot
(
screenshotParams
)
setCookieImage
:
'
https://cdn.dcloud.net.cn/img/shadow-grey.png
'
expect
(
image
).
toSaveImageSnapshot
()
});
});
await
page
.
waitFor
(
1000
);
await
page
.
setData
({
loadError
:
false
,
verifyCookieImage
:
'
https://request.dcloud.net.cn/img/shadow-grey.png
'
});
await
page
.
waitFor
(
1000
);
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
);
await
page
.
setData
({
autoTest
:
false
});
})
}
it
(
'
path-screenshot
'
,
async
()
=>
{
it
(
'
mode-screenshot
'
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-path
'
);
if
(
process
.
env
.
android_cpu_type
===
'
x86_64
'
)
return
await
page
.
waitFor
(
3000
);
const
page
=
await
program
.
navigateTo
(
'
/pages/component/image/image-mode
'
);
const
image
=
await
program
.
screenshot
({
await
page
.
waitFor
(
1000
);
fullPage
:
true
const
image
=
await
program
.
screenshot
(
screenshotParams
)
})
expect
(
image
).
toSaveImageSnapshot
()
expect
(
image
).
toSaveImageSnapshot
()
});
});
it
(
'
mode-screenshot
'
,
async
()
=>
{
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
})
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录