Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
794ef1b6
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5680
Star
79
Fork
149
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
11
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
11
Issue
11
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
794ef1b6
编写于
4月 03, 2024
作者:
dcloud_wdl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
合并 alpha分支的test.js
上级
fd58d9f1
变更
53
隐藏空白更改
内联
并排
Showing
53 changed file
with
836 addition
and
485 deletion
+836
-485
jest-setup.js
jest-setup.js
+186
-21
jest.config.js
jest.config.js
+8
-2
pages/API/action-sheet/action-sheet.test.js
pages/API/action-sheet/action-sheet.test.js
+67
-67
pages/API/download-file/download-file.test.js
pages/API/download-file/download-file.test.js
+2
-2
pages/API/element-takesnapshot/element-takesnapshot.test.js
pages/API/element-takesnapshot/element-takesnapshot.test.js
+1
-1
pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js
...t-app-authorize-setting/get-app-authorize-setting.test.js
+2
-2
pages/API/get-app-base-info/get-app-base-info.test.js
pages/API/get-app-base-info/get-app-base-info.test.js
+3
-6
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
...lement-by-id/get-element-by-id-multiple-root-node.test.js
+4
-4
pages/API/get-element-by-id/get-element-by-id.test.js
pages/API/get-element-by-id/get-element-by-id.test.js
+2
-2
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+34
-16
pages/API/get-system-info/get-system-info.test.js
pages/API/get-system-info/get-system-info.test.js
+3
-8
pages/API/get-system-setting/get-system-setting.test.js
pages/API/get-system-setting/get-system-setting.test.js
+5
-5
pages/API/load-font-face/load-font-face.test.js
pages/API/load-font-face/load-font-face.test.js
+4
-4
pages/API/modal/modal.test.js
pages/API/modal/modal.test.js
+92
-91
pages/API/navigator/new-page/onLoad.test.js
pages/API/navigator/new-page/onLoad.test.js
+13
-13
pages/API/nodes-info/nodes-info.test.js
pages/API/nodes-info/nodes-info.test.js
+5
-0
pages/API/request-payment/reqeust-payment.test.js
pages/API/request-payment/reqeust-payment.test.js
+7
-1
pages/API/request/request.test.js
pages/API/request/request.test.js
+8
-2
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
...set-navigation-bar-color/set-navigation-bar-color.test.js
+2
-2
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
...set-navigation-bar-title/set-navigation-bar-title.test.js
+2
-2
pages/API/toast/toast.test.js
pages/API/toast/toast.test.js
+32
-32
pages/API/upload-file/upload-file.test.js
pages/API/upload-file/upload-file.test.js
+9
-9
pages/CSS/background/background-image.test.js
pages/CSS/background/background-image.test.js
+21
-0
pages/CSS/overflow/overflow.test.js
pages/CSS/overflow/overflow.test.js
+8
-8
pages/CSS/text/font-family.test.js
pages/CSS/text/font-family.test.js
+1
-1
pages/CSS/text/font-size.test.js
pages/CSS/text/font-size.test.js
+13
-0
pages/CSS/variable/variable.test.js
pages/CSS/variable/variable.test.js
+1
-1
pages/component/general-attribute/general-attribute.test.js
pages/component/general-attribute/general-attribute.test.js
+4
-4
pages/component/general-event/general-event.test.js
pages/component/general-event/general-event.test.js
+3
-3
pages/component/image/image.test.js
pages/component/image/image.test.js
+3
-3
pages/component/input/input.test.js
pages/component/input/input.test.js
+27
-2
pages/component/list-view/list-view-children-in-slot.test.js
pages/component/list-view/list-view-children-in-slot.test.js
+3
-2
pages/component/list-view/list-view-multiplex.test.js
pages/component/list-view/list-view-multiplex.test.js
+18
-18
pages/component/list-view/list-view-refresh.test.js
pages/component/list-view/list-view-refresh.test.js
+10
-10
pages/component/list-view/list-view.test.js
pages/component/list-view/list-view.test.js
+19
-14
pages/component/nested-scroll-body/nested-scroll-body.test.js
...s/component/nested-scroll-body/nested-scroll-body.test.js
+23
-0
pages/component/nested-scroll-header/nested-scroll-header.test.js
...mponent/nested-scroll-header/nested-scroll-header.test.js
+21
-0
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+1
-1
pages/component/scroll-view/scroll-view-props.test.js
pages/component/scroll-view/scroll-view-props.test.js
+2
-2
pages/component/scroll-view/scroll-view-refresher.test.js
pages/component/scroll-view/scroll-view-refresher.test.js
+11
-11
pages/component/scroll-view/scroll-view.test.js
pages/component/scroll-view/scroll-view.test.js
+4
-4
pages/component/sticky-header/sticky-header.test.js
pages/component/sticky-header/sticky-header.test.js
+3
-3
pages/component/sticky-section/sticky-section.test.js
pages/component/sticky-section/sticky-section.test.js
+10
-10
pages/component/swiper/swiper.test.js
pages/component/swiper/swiper.test.js
+17
-32
pages/component/text/text-props.test.js
pages/component/text/text-props.test.js
+1
-1
pages/component/video/video.test.js
pages/component/video/video.test.js
+14
-0
pages/component/web-view-local/web-view-local.test.js
pages/component/web-view-local/web-view-local.test.js
+2
-2
pages/component/web-view/web-view.test.js
pages/component/web-view/web-view.test.js
+1
-1
pages/pages.test.js
pages/pages.test.js
+49
-20
pages/template/list-news/list-news.test.js
pages/template/list-news/list-news.test.js
+1
-1
pages/template/navbar-lite/navbar-lite.test.js
pages/template/navbar-lite/navbar-lite.test.js
+5
-5
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
...reenshot-comparison/webview-screenshot-comparison.test.js
+20
-15
pages/webview-screenshot/webview-screenshot.test.js
pages/webview-screenshot/webview-screenshot.test.js
+29
-19
未找到文件。
jest-setup.js
浏览文件 @
794ef1b6
// 自动化测试
const
path
=
require
(
'
path
'
);
const
path
=
require
(
"
path
"
);
const
fs
=
require
(
"
fs
"
);
const
{
configureToMatchImageSnapshot
configureToMatchImageSnapshot
}
=
require
(
'
jest-image-snapshot
'
);
const
hbuilderx_version
=
process
.
env
.
HX_Version
const
uniTestPlatformInfo
=
process
.
env
.
uniTestPlatformInfo
?
process
.
env
.
uniTestPlatformInfo
.
replace
(
/
\s
/g
,
'
_
'
)
:
''
const
folderName
=
`__image_snapshots__/
${
hbuilderx_version
}
/__
${
uniTestPlatformInfo
}
__`
let
environment
=
'
official
'
if
(
hbuilderx_version
.
includes
(
'
dev
'
)){
environment
=
'
dev
'
}
else
if
(
hbuilderx_version
.
includes
(
'
alpha
'
)){
environment
=
'
alpha
'
}
const
baseFolderName
=
`__image_snapshots__/base/
${
environment
}
/__
${
uniTestPlatformInfo
}
__`
let
saveImageSnapshotDir
=
process
.
env
.
saveImageSnapshotDir
||
path
.
join
(
__dirname
,
'
__snapshot__
'
);
expect
.
extend
({
toMatchImageSnapshot
:
configureToMatchImageSnapshot
({
customSnapshotIdentifier
(
args
)
{
return
args
.
currentTestName
.
replace
(
/
\/
/g
,
'
-
'
).
replace
(
'
'
,
'
-
'
);
},
customSnapshotsDir
:
path
.
join
(
__dirname
,
baseFolderName
),
customDiffDir
:
path
.
join
(
__dirname
,
`
${
folderName
}
/`
,
'
diff
'
),
}),
toMatchImageSnapshot
:
configureToMatchImageSnapshot
({
customSnapshotIdentifier
(
args
)
{
return
args
.
currentTestName
.
replace
(
/
\/
/g
,
"
-
"
).
replace
(
"
"
,
"
-
"
);
},
customSnapshotsDir
:
process
.
env
.
saveImageSnapshotDir
,
customDiffDir
:
path
.
join
(
saveImageSnapshotDir
,
"
diff
"
),
}),
toSaveSnapshot
,
toSaveImageSnapshot
,
});
const
testCaseToSnapshotFilePath
=
process
.
env
.
testCaseToSnapshotFilePath
||
"
./testCaseToSnapshotFilePath.json
"
;
if
(
!
fs
.
existsSync
(
testCaseToSnapshotFilePath
))
{
fs
.
writeFileSync
(
testCaseToSnapshotFilePath
,
"
{}
"
);
}
function
writeTestCaseToSnapshotFile
(
testCaseName
,
snapshotFilePath
)
{
const
data
=
JSON
.
parse
(
fs
.
readFileSync
(
testCaseToSnapshotFilePath
));
if
(
testCaseName
.
includes
(
__dirname
))
{
testCaseName
=
testCaseName
.
substring
(
`
${
__dirname
}
`
.
length
);
if
(
testCaseName
[
0
]
==
'
/
'
||
testCaseName
[
0
]
==
'
\\
'
)
{
testCaseName
=
testCaseName
.
substring
(
1
);
};
};
if
(
!
data
[
testCaseName
])
{
data
[
testCaseName
]
=
[
snapshotFilePath
];
}
else
{
data
[
testCaseName
].
push
(
snapshotFilePath
);
}
fs
.
writeFileSync
(
testCaseToSnapshotFilePath
,
JSON
.
stringify
(
data
,
null
,
2
));
}
function
toSaveSnapshot
(
received
,
{
customSnapshotsDir
,
fileName
}
=
{})
{
const
{
snapshotState
:
{
_rootDir
},
testPath
,
currentTestName
,
}
=
this
;
const
SNAPSHOTS_DIR
=
"
__file_snapshots__
"
;
const
snapshotDir
=
process
.
env
.
saveSnapshotDir
||
createSnapshotDir
({
customSnapshotsDir
,
testPath
,
SNAPSHOTS_DIR
,
});
const
_fileName
=
createFileName
({
fileName
,
testPath
,
currentTestName
,
});
const
filePath
=
path
.
join
(
snapshotDir
,
_fileName
);
let
message
=
()
=>
`
${
currentTestName
}
toSaveSnapshot success`
;
let
pass
=
true
;
try
{
checkSnapshotDir
(
path
.
dirname
(
filePath
));
fs
.
writeFileSync
(
filePath
,
received
);
writeTestCaseToSnapshotFile
(
testPath
.
replace
(
`
${
_rootDir
}
/`
,
""
),
filePath
);
}
catch
(
e
)
{
console
.
log
(
"
toSaveSnapshot fail
"
,
e
);
message
=
()
=>
e
.
message
;
pass
=
false
;
}
return
{
message
,
pass
,
};
}
function
toSaveImageSnapshot
(
received
,
{
customSnapshotsDir
,
customSnapshotIdentifier
}
=
{}
)
{
const
{
snapshotState
:
{
_rootDir
},
testPath
,
currentTestName
,
}
=
this
;
const
SNAPSHOTS_DIR
=
"
__image_snapshots__
"
;
const
snapshotDir
=
process
.
env
.
saveImageSnapshotDir
||
createSnapshotDir
({
customSnapshotsDir
,
testPath
,
SNAPSHOTS_DIR
,
});
const
_fileName
=
createFileName
({
fileName
:
customSnapshotIdentifier
?
`
${
customSnapshotIdentifier
()}
.png`
:
""
,
testPath
,
currentTestName
,
fileType
:
"
png
"
,
});
const
filePath
=
path
.
join
(
snapshotDir
,
_fileName
);
let
message
=
()
=>
`
${
currentTestName
}
toSaveImageSnapshot success`
;
let
pass
=
true
;
try
{
checkSnapshotDir
(
path
.
dirname
(
filePath
));
fs
.
writeFileSync
(
filePath
,
Buffer
.
from
(
received
,
"
base64
"
));
writeTestCaseToSnapshotFile
(
testPath
.
replace
(
`
${
_rootDir
}
/`
,
""
),
filePath
);
}
catch
(
e
)
{
console
.
log
(
"
toSaveImageSnapshot fail
"
,
e
);
message
=
()
=>
e
.
message
;
pass
=
false
;
}
return
{
message
,
pass
,
};
}
function
createSnapshotDir
({
customSnapshotsDir
,
testPath
,
SNAPSHOTS_DIR
})
{
return
customSnapshotsDir
||
path
.
join
(
path
.
dirname
(
testPath
),
SNAPSHOTS_DIR
);
}
function
createFileName
({
fileName
,
testPath
,
currentTestName
,
fileType
})
{
return
(
fileName
||
createSnapshotIdentifier
({
testPath
,
currentTestName
,
fileType
,
})
);
}
function
createSnapshotIdentifier
({
testPath
,
currentTestName
,
fileType
=
"
txt
"
,
})
{
const
snapshotIdentifier
=
kebabCase
(
`
${
path
.
basename
(
testPath
)}
-
${
currentTestName
}
`
);
const
counter
=
timesCalled
.
get
(
`
${
snapshotIdentifier
}
-
${
fileType
}
`
)
||
1
;
timesCalled
.
set
(
`
${
snapshotIdentifier
}
-
${
fileType
}
`
,
counter
+
1
);
return
`
${
snapshotIdentifier
}
-
${
counter
}
.
${
fileType
}
`
;
}
function
kebabCase
(
str
)
{
return
str
.
replaceAll
(
/
([
a-z
])([
A-Z
])
/g
,
"
$1-$2
"
)
.
replaceAll
(
/
\s
+/g
,
"
-
"
)
.
replaceAll
(
/_+/g
,
"
-
"
)
.
replaceAll
(
/
\/
+/g
,
"
-
"
)
.
replaceAll
(
/
\.
+/g
,
"
-
"
)
.
toLowerCase
();
}
function
checkSnapshotDir
(
snapshotDir
)
{
if
(
!
fs
.
existsSync
(
snapshotDir
))
{
fs
.
mkdirSync
(
snapshotDir
,
{
recursive
:
true
,
});
}
}
const
timesCalled
=
new
Map
();
jest.config.js
浏览文件 @
794ef1b6
// 自动化测试
// 自动化测试
module
.
exports
=
{
testTimeout
:
30000
,
reporters
:
[
'
default
'
],
...
...
@@ -6,6 +6,12 @@ module.exports = {
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
"
<rootDir>/pages/**/*test.[jt]s?(x)
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
<rootDir>/pages/API/download-file/download-file.test.js
'
,
'
<rootDir>/pages/API/upload-file/upload-file.test.js
'
,
'
<rootDir>/pages/API/get-battery-info/get-battery-info.test.js
'
,
'
<rootDir>/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
'
],
setupFilesAfterEnv
:
[
'
<rootDir>/jest-setup.js
'
],
}
pages/API/action-sheet/action-sheet.test.js
浏览文件 @
794ef1b6
...
...
@@ -3,7 +3,7 @@
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isA
ndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
const
isA
pp
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
||
process
.
env
.
UNI_OS_NAME
===
"
ios
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/action-sheet/action-sheet
'
)
...
...
@@ -12,13 +12,13 @@ describe('API-loading', () => {
it
(
"
onload-action-sheet-test
"
,
async
()
=>
{
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
await
page
.
waitFor
(
500
);
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -27,13 +27,13 @@ describe('API-loading', () => {
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -57,9 +57,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -67,13 +67,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -99,9 +99,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -109,13 +109,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -140,9 +140,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -150,13 +150,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -181,9 +181,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -191,13 +191,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -222,9 +222,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -232,13 +232,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -266,9 +266,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -276,13 +276,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -307,9 +307,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -317,13 +317,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -348,9 +348,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -358,13 +358,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -389,9 +389,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -399,13 +399,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -431,9 +431,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -441,13 +441,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -472,9 +472,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -482,13 +482,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
...
...
@@ -513,9 +513,9 @@ describe('API-loading', () => {
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -523,13 +523,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
pages/API/download-file/download-file.test.js
浏览文件 @
794ef1b6
...
...
@@ -23,7 +23,7 @@ describe('ExtApi-DownloadFile', () => {
});
let
shouldTestCookie
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
shouldTestCookie
=
version
>
9
...
...
@@ -47,4 +47,4 @@ describe('ExtApi-DownloadFile', () => {
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
});
pages/API/element-takesnapshot/element-takesnapshot.test.js
浏览文件 @
794ef1b6
...
...
@@ -2,7 +2,7 @@ const PAGE_PATH = "/pages/API/element-takesnapshot/element-takesnapshot";
describe
(
"
element-takesnapshot
"
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
)
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js
浏览文件 @
794ef1b6
const
PAGE_PATH
=
'
/pages/API/get-app-authorize-setting/get-app-authorize-setting
'
describe
(
'
ExtApi-GetAppAuthorizeSetting
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
)
{
describe
(
'
ExtApi-GetAppAuthorizeSetting
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
pages/API/get-app-base-info/get-app-base-info.test.js
浏览文件 @
794ef1b6
...
...
@@ -6,14 +6,11 @@ describe('ExtApi-GetAppBaseInfo', () => {
let
res
;
const
stringProperties
=
[
'
appId
'
,
'
appName
'
,
'
appVersion
'
,
'
appVersionCode
'
,
'
appLanguage
'
,
'
language
'
,
'
uniCompileVersion
'
,
'
uniPlatform
'
,
'
uniRuntimeVersion
'
,
'
language
'
,
'
uniCompile
r
Version
'
,
'
uniPlatform
'
,
'
uniRuntimeVersion
'
,
]
const
numberProperties
=
[
'
uniCompileVersionCode
'
,
'
uniRuntimeVersionCode
'
]
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
===
-
1
)
{
stringProperties
.
push
(
'
version
'
)
}
'
uniCompilerVersionCode
'
,
'
uniRuntimeVersionCode
'
]
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
...
...
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
浏览文件 @
794ef1b6
...
...
@@ -2,7 +2,7 @@ const PAGE_PATH =
"
/pages/API/get-element-by-id/get-element-by-id-multiple-root-node
"
;
let
page
;
describe
(
"
getElementByIdForMultipleRootNode
"
,
()
=>
{
describe
(
"
getElementByIdForMultipleRootNode
"
,
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
);
await
page
.
waitFor
(
'
view
'
);
...
...
@@ -16,7 +16,7 @@ describe("getElementByIdForMultipleRootNode", () => {
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
});
});
pages/API/get-element-by-id/get-element-by-id.test.js
浏览文件 @
794ef1b6
...
...
@@ -15,7 +15,7 @@ describe("getElementById", () => {
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
});
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
794ef1b6
...
...
@@ -2,7 +2,7 @@ const PAGE_PATH = '/pages/API/get-file-system-manager/get-file-system-manager'
describe
(
'
ExtApi-FileManagerTest
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
)
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
@@ -116,9 +116,11 @@ describe('ExtApi-FileManagerTest', () => {
await
btnReadDirButton
.
tap
()
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
]
"
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
b
\"
]
"
)
// 获取和对比 文件内容
const
btnReadFileButton
=
await
page
.
$
(
'
#btn-read-file
'
)
await
btnReadFileButton
.
tap
()
...
...
@@ -176,9 +178,11 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 2.txt 两个文件都存在
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
2.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
2.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
2.txt
\"
]
"
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
2.txt
\"
,
\"
b
\"
]
"
)
// 测试 rename
await
page
.
setData
({
...
...
@@ -195,10 +199,11 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 3.txt 两个文件都存在
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
3.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
fileListSuccess
.
sort
(
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
3.txt
\"
,
\"
b
\"
]
"
)
});
it
(
'
TEMP_PATH test
'
,
async
()
=>
{
...
...
@@ -281,8 +286,10 @@ describe('ExtApi-FileManagerTest', () => {
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
]
"
)
/**
...
...
@@ -406,13 +413,14 @@ describe('ExtApi-FileManagerTest', () => {
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
,
\"
提前创建的目录
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
,
\"
提前创建的目录
\"
]
"
)
await
page
.
setData
({
copyFromFile
:
"
a/
"
+
testDirName
+
"
/中文路径/张三/name/中文文件.mock
"
,
copyToFile
:
"
a/提前创建的目录/4.txt
"
})
...
...
@@ -735,6 +743,7 @@ describe('ExtApi-FileManagerTest', () => {
recursiveVal
:
true
,
copyToBasePath
:
globalRootPath
,
basePath
:
globalRootPath
,
globalTempPath
:
globalRootPath
,
rmDirFile
:
'
a
'
,
mkdirFile
:
'
a
'
,
unlinkFile
:
'
a/1.txt
'
,
...
...
@@ -800,7 +809,7 @@ describe('ExtApi-FileManagerTest', () => {
// 读取单个文件信息
let
statsRet
=
await
getData
(
'
statsRet
'
)
expect
(
statsRet
.
length
).
toEqual
(
1
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/1.txt
'
))
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/1.txt$
'
))
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
69
)
/**
...
...
@@ -828,7 +837,7 @@ describe('ExtApi-FileManagerTest', () => {
await
page
.
setData
({
// asset 只能正式版测试,这里只能模拟返回路径
basePath
:
''
,
copyFromFile
:
'
file:///android_asset/uni-uts/uni-prompt/toast_error.png
'
,
copyFromFile
:
'
static/test-image/logo.ico
'
,
copyToFile
:
'
a/m/3.txt
'
,
})
const
btnCopyFileButton
=
await
page
.
$
(
'
#btn-copy-file
'
)
...
...
@@ -847,16 +856,25 @@ describe('ExtApi-FileManagerTest', () => {
// 读取全部文件信息
statsRet
=
await
getData
(
'
statsRet
'
)
statsRet
.
sort
(
function
(
a
,
b
){
if
(
a
.
path
>
b
.
path
){
return
1
}
else
if
(
a
.
path
<
b
.
path
){
return
-
1
}
return
0
})
console
.
log
(
statsRet
)
expect
(
statsRet
.
length
).
toEqual
(
5
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a
'
))
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
0
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
.*/a$
'
))
//
expect(statsRet[0].stats.size).toEqual(0)
expect
(
statsRet
[
2
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/2.txt
'
))
expect
(
statsRet
[
2
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/2.txt$
'
))
expect
(
statsRet
[
2
].
stats
.
size
).
toEqual
(
10
)
expect
(
statsRet
[
4
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/m/3.txt
'
))
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
5842
)
expect
(
statsRet
[
4
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/m/3.txt$
'
))
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
156406
)
// 清理文件,避免影响其他测试用例
...
...
pages/API/get-system-info/get-system-info.test.js
浏览文件 @
794ef1b6
...
...
@@ -7,20 +7,15 @@ describe('ExtApi-GetSystemInfo', () => {
const
stringProperties
=
[
'
appId
'
,
'
appLanguage
'
,
'
appName
'
,
'
appVersion
'
,
'
appVersionCode
'
,
'
brand
'
,
'
deviceId
'
,
'
deviceBrand
'
,
'
deviceModel
'
,
'
deviceType
'
,
'
language
'
,
'
model
'
,
'
osName
'
,
'
osVersion
'
,
'
osLanguage
'
,
'
platform
'
,
'
system
'
,
'
ua
'
,
'
uniCompileVersion
'
,
'
model
'
,
'
osName
'
,
'
osVersion
'
,
'
osLanguage
'
,
'
platform
'
,
'
system
'
,
'
ua
'
,
'
uniCompile
r
Version
'
,
'
uniPlatform
'
,
'
uniRuntimeVersion
'
,
'
romName
'
,
'
romVersion
'
,
]
const
numberProperties
=
[
'
osAndroidAPILevel
'
,
'
devicePixelRatio
'
,
'
pixelRatio
'
,
'
screenWidth
'
,
'
screenHeight
'
,
'
statusBarHeight
'
,
'
windowWidth
'
,
'
windowHeight
'
,
'
windowTop
'
,
'
windowBottom
'
,
'
screenTop
'
,
'
uniCompileVersionCode
'
,
'
uniRuntimeVersionCode
'
]
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
===
-
1
)
{
stringProperties
.
push
(
'
version
'
)
}
'
uniCompilerVersionCode
'
,
'
uniRuntimeVersionCode
'
]
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
pages/API/get-system-setting/get-system-setting.test.js
浏览文件 @
794ef1b6
const
PAGE_PATH
=
'
/pages/API/get-system-setting/get-system-setting
'
describe
(
'
ExtApi-GetSystemSetting
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
)
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
web
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
@@ -18,10 +18,10 @@ describe('ExtApi-GetSystemSetting', () => {
it
(
'
Check GetSystemSetting
'
,
async
()
=>
{
for
(
const
key
in
res
)
{
const
value
=
res
[
key
];
if
(
res
[
'
bluetoothEnabled
'
]
==
undefined
)
{
expect
(
res
[
'
bluetoothError
'
]).
not
.
toBe
(
""
)
}
else
{
expect
(
res
[
'
bluetoothError
'
]
==
undefined
).
toBe
(
true
)
if
(
res
[
'
bluetoothEnabled
'
]
==
undefined
||
res
[
'
bluetoothEnabled
'
]
===
false
)
{
expect
(
res
[
'
bluetoothError
'
]).
not
.
toBe
(
""
)
}
else
{
expect
(
res
[
'
bluetoothError
'
]
==
undefined
).
toBe
(
true
)
}
if
(
res
[
'
wifiEnabled
'
]
==
undefined
)
{
...
...
pages/API/load-font-face/load-font-face.test.js
浏览文件 @
794ef1b6
...
...
@@ -7,13 +7,13 @@ describe("loadFontFace", () => {
await
page
.
waitFor
(
4000
);
});
it
(
"
parent screenshot
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
it
(
"
child screenshot
"
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
CHILD_PAGE_PATH
);
await
page
.
waitFor
(
3000
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
});
pages/API/modal/modal.test.js
浏览文件 @
794ef1b6
...
...
@@ -3,7 +3,7 @@
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isA
ndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
const
isA
pp
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
||
process
.
env
.
UNI_OS_NAME
===
"
ios
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/modal/modal
'
)
...
...
@@ -13,13 +13,14 @@ describe('API-loading', () => {
it
(
"
onload-modal-test
"
,
async
()
=>
{
if
(
isAndroid
)
{
if
(
isApp
)
{
await
page
.
waitFor
(
500
);
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -27,13 +28,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -53,13 +54,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -67,13 +68,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -94,13 +95,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -108,13 +109,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -135,13 +136,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -149,13 +150,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -176,13 +177,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -190,13 +191,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -217,12 +218,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -230,13 +231,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -257,12 +258,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -270,13 +271,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -297,12 +298,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -310,13 +311,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -337,12 +338,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -350,13 +351,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -377,13 +378,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -391,13 +392,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -418,13 +419,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -432,13 +433,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -459,13 +460,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -473,13 +474,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -500,13 +501,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -514,13 +515,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -541,13 +542,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -555,13 +556,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -582,13 +583,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -596,13 +597,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -624,12 +625,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -637,13 +638,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -664,13 +665,13 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -678,13 +679,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -705,12 +706,12 @@ describe('API-loading', () => {
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -718,13 +719,13 @@ describe('API-loading', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
pages/API/navigator/new-page/onLoad.test.js
浏览文件 @
794ef1b6
...
...
@@ -10,8 +10,8 @@ describe("onLoad", () => {
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
adjustData
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
it
(
"
navigateTo
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
...
...
@@ -22,7 +22,7 @@ describe("onLoad", () => {
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
});
it
(
"
navigateBack
"
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateBack
"
);
...
...
@@ -61,14 +61,14 @@ describe("onLoad", () => {
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
showToast
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
2140
,
},
});
expect
(
image
).
to
Match
ImageSnapshot
({
expect
(
image
).
to
Save
ImageSnapshot
({
failureThreshold
:
0.05
,
failureThresholdType
:
"
percent
"
,
});
...
...
@@ -79,17 +79,17 @@ describe("onLoad", () => {
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
showLoading
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
2140
,
},
});
expect
(
image
).
to
Match
ImageSnapshot
({
expect
(
image
).
to
Save
ImageSnapshot
({
failureThreshold
:
0.05
,
failureThresholdType
:
"
percent
"
,
});
});
});
it
(
"
showModal
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
...
...
@@ -97,14 +97,14 @@ describe("onLoad", () => {
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
showModal
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
2140
,
},
});
expect
(
image
).
to
Match
ImageSnapshot
({
expect
(
image
).
to
Save
ImageSnapshot
({
failureThreshold
:
0.05
,
failureThresholdType
:
"
percent
"
,
});
...
...
@@ -115,16 +115,16 @@ describe("onLoad", () => {
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
showActionSheet
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
2140
,
},
});
expect
(
image
).
to
Match
ImageSnapshot
({
expect
(
image
).
to
Save
ImageSnapshot
({
failureThreshold
:
0.05
,
failureThresholdType
:
"
percent
"
,
});
});
});
});
pages/API/nodes-info/nodes-info.test.js
浏览文件 @
794ef1b6
...
...
@@ -53,6 +53,11 @@ describe('nodes-info', () => {
expect
(
nodeInfo2
.
top
>
220
).
toBe
(
true
)
expect
(
Math
.
round
(
nodeInfo2
.
width
)).
toBe
(
RECT_WIDTH
)
expect
(
Math
.
round
(
nodeInfo2
.
height
)).
toBe
(
RECT_HEIGHT
)
})
it
(
'
get-node-info-child
'
,
async
()
=>
{
const
child
=
await
page
.
$
(
'
.node-child
'
)
const
childData
=
await
child
.
data
()
expect
(
childData
.
top
>
100
).
toBe
(
true
)
})
// #ifdef APP
...
...
pages/API/request-payment/reqeust-payment.test.js
浏览文件 @
794ef1b6
...
...
@@ -2,11 +2,17 @@ const PAGE_PATH =
"
/pages/API/request-payment/request-payment
"
;
describe
(
"
payment
"
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
)
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
===
'
true
'
)
{
it
(
'
web
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
it
(
'
ios
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
pages/API/request/request.test.js
浏览文件 @
794ef1b6
...
...
@@ -86,7 +86,7 @@ describe('ExtApi-Request', () => {
});
let
shouldTestCookie
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
shouldTestCookie
=
version
>
9
...
...
@@ -108,4 +108,10 @@ describe('ExtApi-Request', () => {
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
it
(
'
Check Get With Data
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_get_with_data
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
});
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
浏览文件 @
794ef1b6
...
...
@@ -19,14 +19,14 @@ describe('setNavigationBarColor', () => {
it
(
"
setNavigationBarColor1
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor1
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
it
(
"
setNavigationBarColor2
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor2
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
4
);
});
...
...
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
浏览文件 @
794ef1b6
...
...
@@ -19,13 +19,13 @@ describe("setNavigationBarColor", () => {
it
(
"
setNavigationBarNewTitle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarNewTitle
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
it
(
"
setNavigationBarLongTitle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarLongTitle
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
});
});
pages/API/toast/toast.test.js
浏览文件 @
794ef1b6
...
...
@@ -3,7 +3,7 @@
describe
(
'
API-toast
'
,
()
=>
{
let
page
;
const
isA
ndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
const
isA
pp
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
||
process
.
env
.
UNI_OS_NAME
===
"
ios
"
;
beforeAll
(
async
()
=>
{
...
...
@@ -16,14 +16,14 @@ describe('API-toast', () => {
it
(
"
onload-toast-test
"
,
async
()
=>
{
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
await
page
.
waitFor
(
500
);
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -31,13 +31,13 @@ describe('API-toast', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -47,14 +47,14 @@ describe('API-toast', () => {
const
btnToastDefaultButton
=
await
page
.
$
(
'
#btn-toast-default
'
)
await
btnToastDefaultButton
.
tap
()
await
page
.
waitFor
(
200
)
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -62,13 +62,13 @@ describe('API-toast', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -78,12 +78,12 @@ describe('API-toast', () => {
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-toast-duration
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
2000
)
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -91,13 +91,13 @@ describe('API-toast', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -105,12 +105,12 @@ describe('API-toast', () => {
const
btnToastErrorIconButton
=
await
page
.
$
(
'
#btn-toast-errorIcon
'
)
await
btnToastErrorIconButton
.
tap
()
await
page
.
waitFor
(
200
)
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -118,13 +118,13 @@ describe('API-toast', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -138,12 +138,12 @@ describe('API-toast', () => {
await
btnToastHideButton
.
tap
()
await
page
.
waitFor
(
1000
)
if
(
isA
ndroid
)
{
if
(
isA
pp
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
...
...
@@ -151,13 +151,13 @@ describe('API-toast', () => {
width
:
windowWidth
},
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
}
})
...
...
@@ -166,11 +166,11 @@ describe('API-toast', () => {
// const btnToastButton = await page.$('#btn-toast-postion-bottom')
// await btnToastButton.tap()
// await page.waitFor(200)
// if (isA
ndroid
) {
// if (isA
pp
) {
// const windowHeight = uni.getWindowInfo().windowHeight;
// const windowWidth = uni.getWindowInfo().windowWidth;
// const image = await program.screenshot({
//
adb
: true,
//
deviceShot
: true,
// area: {
// x: 0,
// y: 200,
...
...
@@ -178,13 +178,13 @@ describe('API-toast', () => {
// width:windowWidth
// },
// });
// expect(image).to
Match
ImageSnapshot();
// expect(image).to
Save
ImageSnapshot();
// }else{
// const image = await program.screenshot({
//
adb
: true,
//
deviceShot
: true,
// fullPage: true
// });
// expect(image).to
Match
ImageSnapshot()
// expect(image).to
Save
ImageSnapshot()
// }
// })
...
...
pages/API/upload-file/upload-file.test.js
浏览文件 @
794ef1b6
...
...
@@ -27,17 +27,17 @@ describe('ExtApi-UploadFile', () => {
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
let
shouldTestCookie
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
shouldTestCookie
=
version
>
9
...
...
@@ -59,4 +59,4 @@ describe('ExtApi-UploadFile', () => {
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
});
pages/CSS/background/background-image.test.js
0 → 100644
浏览文件 @
794ef1b6
describe
(
'
background-image-test
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/CSS/background/background-image
'
);
await
page
.
waitFor
(
600
);
});
it
(
'
background-image-screenshot
'
,
async
()
=>
{
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
});
it
(
'
background-image-select
'
,
async
()
=>
{
await
page
.
callMethod
(
'
updateBackgroundSelect
'
)
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
});
});
pages/CSS/overflow/overflow.test.js
浏览文件 @
794ef1b6
describe
(
'
component-native-overflow
'
,
()
=>
{
let
page
describe
(
'
component-native-overflow
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
//打开list-view测试页
page
=
await
program
.
reLaunch
(
'
/pages/CSS/overflow/overflow
'
)
await
page
.
waitFor
(
"
image
"
)
//打开list-view测试页
page
=
await
program
.
reLaunch
(
'
/pages/CSS/overflow/overflow
'
)
await
page
.
waitFor
(
"
image
"
)
})
//检测overflow设置hidden,visible
it
(
'
check_view_overflow
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
//安卓7模拟器不截图 导致闪退
...
...
@@ -20,6 +20,6 @@ describe('component-native-overflow', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
,
});
expect
(
image
).
to
Match
ImageSnapshot
();
})
expect
(
image
).
to
Save
ImageSnapshot
();
})
})
pages/CSS/text/font-family.test.js
浏览文件 @
794ef1b6
...
...
@@ -11,6 +11,6 @@ describe('css-font-family', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
});
});
pages/CSS/text/font-size.test.js
0 → 100644
浏览文件 @
794ef1b6
describe
(
'
css-font-size
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/CSS/text/font-size
'
);
});
it
(
'
screenshot
'
,
async
()
=>
{
await
page
.
callMethod
(
"
setFontSize
"
);
await
page
.
waitFor
(
100
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
});
});
pages/CSS/variable/variable.test.js
浏览文件 @
794ef1b6
...
...
@@ -9,6 +9,6 @@ describe('css-variable', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
});
});
pages/component/general-attribute/general-attribute.test.js
浏览文件 @
794ef1b6
...
...
@@ -8,8 +8,8 @@ describe('general attribute', () => {
await
page
.
waitFor
(
'
view
'
)
})
it
(
"
class & style
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
it
(
'
validateGeneralAttributes
'
,
async
()
=>
{
const
button
=
await
page
.
$
(
"
.btn-style
"
);
...
...
@@ -21,7 +21,7 @@ describe('general attribute', () => {
const
button
=
await
page
.
$
(
"
.btn-ref
"
);
await
button
.
tap
();
await
page
.
waitFor
(
500
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
})
pages/component/general-event/general-event.test.js
浏览文件 @
794ef1b6
...
...
@@ -10,7 +10,7 @@ describe('event trigger sequence', () => {
})
it
(
'
touch
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
await
el
.
touchstart
({
touches
:
[{
identifier
:
1
,
...
...
@@ -56,10 +56,10 @@ describe('event trigger sequence', () => {
})
it
(
'
longPress
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
await
el
.
longpress
()
const
data
=
await
page
.
data
()
expect
(
data
.
onLongPressTime
).
toBeGreaterThan
(
0
)
}
})
})
})
pages/component/image/image.test.js
浏览文件 @
794ef1b6
...
...
@@ -30,7 +30,7 @@ describe('component-native-image', () => {
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
true
)
})
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
it
(
'
check-cookie
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
,
...
...
@@ -55,7 +55,7 @@ describe('component-native-image', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
});
it
(
'
mode-screenshot
'
,
async
()
=>
{
...
...
@@ -65,6 +65,6 @@ describe('component-native-image', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
});
});
pages/component/input/input.test.js
浏览文件 @
794ef1b6
...
...
@@ -12,7 +12,7 @@ describe('component-native-input', () => {
// const image = await program.screenshot({
// fullPage: true
// })
// expect(image).to
Match
ImageSnapshot()
// expect(image).to
Save
ImageSnapshot()
// })
// 测试焦点及键盘弹起
it
(
'
focus
'
,
async
()
=>
{
...
...
@@ -147,10 +147,35 @@ describe('component-native-input', () => {
expect
(
await
(
await
page
.
$
(
'
#uni-input-cursor-color
'
)).
attribute
(
"
cursor-color
"
)).
toBe
(
"
red
"
)
})
it
(
"
maxlength
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-maxlength
'
);
let
str
=
""
;
for
(
let
i
=
0
;
i
<
200
;
i
++
){
str
+=
`
${
i
}
`
}
await
page
.
setData
({
inputMaxLengthValue
:
str
})
let
length
=
(
await
input
.
value
()).
length
expect
(
length
).
toBe
(
10
)
await
page
.
setData
({
inputMaxLengthValue
:
""
})
})
it
(
"
password and value order
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-password
'
);
let
length
=
(
await
input
.
value
()).
length
expect
(
length
).
toBe
(
6
)
await
page
.
setData
({
inputPasswordValue
:
""
})
})
it
(
"
afterAllTestScreenshot
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
})
});
pages/component/list-view/list-view-children-in-slot.test.js
浏览文件 @
794ef1b6
...
...
@@ -22,6 +22,7 @@ describe('list-view-children-in-slot', () => {
const
addBtn
=
await
page
.
$
(
'
#add-btn
'
)
await
addBtn
.
tap
()
await
page
.
waitFor
(
500
)
listItems
=
await
page
.
$$
(
'
list-item
'
)
expect
(
listItems
.
length
).
toBe
(
11
)
...
...
@@ -33,12 +34,12 @@ describe('list-view-children-in-slot', () => {
const
emptyBtn
=
await
page
.
$
(
'
#empty-btn
'
)
await
emptyBtn
.
tap
()
await
page
.
waitFor
(
500
)
listItems
=
await
page
.
$$
(
'
list-item
'
)
expect
(
listItems
.
length
).
toBe
(
3
)
await
addBtn
.
tap
()
await
page
.
waitFor
(
500
)
listItems
=
await
page
.
$$
(
'
list-item
'
)
expect
(
listItems
.
length
).
toBe
(
5
)
...
...
pages/component/list-view/list-view-multiplex.test.js
浏览文件 @
794ef1b6
describe
(
'
component-native-list-view
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
//打开list-view-multiplex测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/list-view/list-view-multiplex
'
)
await
page
.
waitFor
(
'
list-view
'
)
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it
(
'
check_list_item_multiplex
'
,
async
()
=>
{
await
page
.
callMethod
(
'
listViewScrollByY
'
,
5000
)
await
page
.
waitFor
(
400
)
await
page
.
callMethod
(
'
listViewScrollByY
'
,
100
)
describe
(
'
component-native-list-view
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
//打开list-view-multiplex测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/list-view/list-view-multiplex
'
)
await
page
.
waitFor
(
'
list-view
'
)
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it
(
'
check_list_item_multiplex
'
,
async
()
=>
{
await
page
.
callMethod
(
'
listViewScrollByY
'
,
5000
)
await
page
.
waitFor
(
400
)
await
page
.
callMethod
(
'
listViewScrollByY
'
,
100
)
})
//检测延迟显示listv-view后list-item是否正常显示
...
...
@@ -20,8 +20,8 @@ describe('component-native-list-view', () => {
return
await
page
.
data
(
'
list_show
'
)
===
true
;
});
await
page
.
waitFor
(
200
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
//检测修改item子元素后,item是否正常调整高度
...
...
@@ -31,7 +31,7 @@ describe('component-native-list-view', () => {
return
await
page
.
data
(
'
displayArrow
'
)
===
true
;
});
await
page
.
waitFor
(
600
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
})
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
})
pages/component/list-view/list-view-refresh.test.js
浏览文件 @
794ef1b6
describe
(
'
component-native-list-view-refresh
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
it
(
'
dummyTest
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
it
(
'
dummyTest
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
}
let
page
beforeAll
(
async
()
=>
{
//打开list-view测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/list-view/list-view-refresh
'
)
await
page
.
waitFor
(
600
)
//打开list-view测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/list-view/list-view-refresh
'
)
await
page
.
waitFor
(
600
)
})
it
(
'
check_list_view_refresh
'
,
async
()
=>
{
...
...
@@ -18,7 +18,7 @@ describe('component-native-list-view-refresh', () => {
});
//等待下拉刷新结束
await
page
.
waitFor
(
500
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
})
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
})
pages/component/list-view/list-view.test.js
浏览文件 @
794ef1b6
...
...
@@ -6,15 +6,6 @@ describe('component-native-list-view', () => {
await
page
.
waitFor
(
600
)
})
//检测竖向可滚动区域
it
(
'
check_scroll_height
'
,
async
()
=>
{
await
page
.
callMethod
(
'
change_scroll_y_boolean
'
,
true
)
await
page
.
callMethod
(
'
change_scroll_x_boolean
'
,
false
)
await
page
.
waitFor
(
600
)
const
value
=
await
page
.
callMethod
(
'
check_scroll_height
'
)
expect
(
value
).
toBe
(
true
)
})
//检测竖向scrolltop属性赋值
it
(
'
check_scroll_top
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
600
)
...
...
@@ -26,7 +17,7 @@ describe('component-native-list-view', () => {
})
//检测横向scrollLeft属性赋值
//检测横向scrollLeft属性赋值
备注:iOS不支持list-view横向滚动
it
(
'
check_scroll_left
'
,
async
()
=>
{
if
(
await
page
.
data
(
'
scroll_x_boolean
'
)
===
false
)
{
await
page
.
callMethod
(
'
change_scroll_x_boolean
'
,
true
)
...
...
@@ -45,7 +36,21 @@ describe('component-native-list-view', () => {
return
}
//检测横向可滚动区域
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
return
}
//检测竖向可滚动区域
it
(
'
check_scroll_height
'
,
async
()
=>
{
await
page
.
callMethod
(
'
change_scroll_y_boolean
'
,
true
)
await
page
.
callMethod
(
'
change_scroll_x_boolean
'
,
false
)
await
page
.
waitFor
(
600
)
const
value
=
await
page
.
callMethod
(
'
check_scroll_height
'
)
expect
(
value
).
toBe
(
true
)
})
//检测横向可滚动区域 备注:iOS不支持list-view横向滚动
it
(
'
check_scroll_width
'
,
async
()
=>
{
if
(
await
page
.
data
(
'
scroll_x_boolean
'
)
===
false
)
{
await
page
.
callMethod
(
'
change_scroll_x_boolean
'
,
true
)
...
...
@@ -59,7 +64,7 @@ describe('component-native-list-view', () => {
expect
(
value
).
toBe
(
true
)
})
//检测下拉刷新
//检测下拉刷新
备注:iOS本地测试结果正确,但是自动化测试结果错误
it
(
'
check_refresher
'
,
async
()
=>
{
if
(
await
page
.
data
(
'
scroll_y_boolean
'
)
===
false
)
{
await
page
.
callMethod
(
'
change_scroll_y_boolean
'
,
true
)
...
...
@@ -74,7 +79,7 @@ describe('component-native-list-view', () => {
expect
(
await
page
.
data
(
'
refresherrefresh
'
)).
toBe
(
true
)
})
//检测竖向scroll_into_view属性赋值
//检测竖向scroll_into_view属性赋值
备注:iOS本地测试结果正确,但是自动化测试结果错误
it
(
'
check_scroll_into_view_top
'
,
async
()
=>
{
if
(
await
page
.
data
(
'
scroll_y_boolean
'
)
===
false
)
{
await
page
.
callMethod
(
'
change_scroll_y_boolean
'
,
true
)
...
...
@@ -90,7 +95,7 @@ describe('component-native-list-view', () => {
expect
(
scrollTop
-
690
).
toBeGreaterThanOrEqual
(
0
)
})
//检测横向scroll_into_view属性赋值
//检测横向scroll_into_view属性赋值
备注:iOS不支持list-view横向滚动
it
(
'
check_scroll_into_view_left
'
,
async
()
=>
{
if
(
await
page
.
data
(
'
scroll_x_boolean
'
)
===
false
)
{
await
page
.
callMethod
(
'
change_scroll_x_boolean
'
,
true
)
...
...
pages/component/nested-scroll-body/nested-scroll-body.test.js
0 → 100644
浏览文件 @
794ef1b6
describe
(
'
component-native-nested-scroll-body
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
beforeAll
(
async
()
=>
{
//打开lnested-scroll-body测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/nested-scroll-body/nested-scroll-body
'
)
await
page
.
waitFor
(
600
)
})
//检测横向scroll_into_view属性赋值
it
(
'
check_scroll_into_view_left
'
,
async
()
=>
{
await
page
.
callMethod
(
'
testBodyScrollBy
'
,
400
)
await
page
.
waitFor
(
300
)
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
})
})
pages/component/nested-scroll-header/nested-scroll-header.test.js
0 → 100644
浏览文件 @
794ef1b6
describe
(
'
component-native-nested-scroll-header
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
beforeAll
(
async
()
=>
{
//打开lnested-scroll-header测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/nested-scroll-header/nested-scroll-header
'
)
await
page
.
waitFor
(
600
)
})
it
(
'
check_nested-scroll-header
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
})
})
pages/component/picker-view/picker-view.test.js
浏览文件 @
794ef1b6
...
...
@@ -65,7 +65,7 @@ describe('PickerView.uvue', () => {
})
it
(
'
reopen-picker-view-page
'
,
async
()
=>
{
await
program
.
switchTab
(
'
/
'
)
page
=
await
program
.
switchTab
(
'
/pages/tabBar/component
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
...
...
pages/component/scroll-view/scroll-view-props.test.js
浏览文件 @
794ef1b6
...
...
@@ -89,8 +89,8 @@ describe('component-native-scroll-view-props', () => {
showScrollbar
:
false
})
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
});
pages/component/scroll-view/scroll-view-refresher.test.js
浏览文件 @
794ef1b6
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-scroll-view-refresher
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/scroll-view/scroll-view-refresher
'
);
await
page
.
waitFor
(
300
);
});
it
(
'
scroll-view-refresher-screenshot
'
,
async
()
=>
{
//禁止滚动条
await
page
.
setData
({
showScrollbar
:
false
})
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
(
);
expect
(
image
).
to
MatchImageSnapshot
();
it
(
'
scroll-view-refresher-screenshot
'
,
async
()
=>
{
//禁止滚动条
await
page
.
setData
({
showScrollbar
:
false
})
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
});
expect
(
image
).
to
SaveImageSnapshot
();
})
it
(
'
check_refresher
'
,
async
()
=>
{
...
...
@@ -30,4 +30,4 @@ describe('component-native-scroll-view-refresher', () => {
expect
(
1
).
toBe
(
1
)
})
}
});
});
pages/component/scroll-view/scroll-view.test.js
浏览文件 @
794ef1b6
describe
(
'
component-native-scroll-view
'
,
()
=>
{
describe
(
'
component-native-scroll-view
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/scroll-view/scroll-view
'
);
...
...
@@ -12,7 +12,7 @@ describe('component-native-scroll-view', () => {
showScrollbar
:
false
})
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
});
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
});
});
pages/component/sticky-header/sticky-header.test.js
浏览文件 @
794ef1b6
...
...
@@ -8,7 +8,7 @@ describe('component-native-sticky-header', () => {
//检测吸顶效果
it
(
'
check_sticky_header
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
600
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
})
})
pages/component/sticky-section/sticky-section.test.js
浏览文件 @
794ef1b6
...
...
@@ -8,12 +8,12 @@ describe('component-native-sticky-section', () => {
//检测吸顶上推效果
it
(
'
check_sticky_section
'
,
async
()
=>
{
await
page
.
callMethod
(
'
listViewScrollByY
'
,
1000
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
})
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
return
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
===
'
true
'
)
{
return
}
it
(
'
check_goto_sticky_header
'
,
async
()
=>
{
...
...
@@ -23,14 +23,14 @@ describe('component-native-sticky-section', () => {
await
page
.
setData
({
scrolling
:
'
true
'
})
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
)
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
//跳转到id为C的StickyHeader位置
await
page
.
callMethod
(
'
gotoStickyHeader
'
,
'
C
'
)
}
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
scrolling
'
)
===
false
;
});
const
image
=
await
program
.
screenshot
();
expect
(
image
).
to
Match
ImageSnapshot
();
const
image
=
await
program
.
screenshot
(
{
fullPage
:
true
}
);
expect
(
image
).
to
Save
ImageSnapshot
();
})
})
})
pages/component/swiper/swiper.test.js
浏览文件 @
794ef1b6
jest
.
setTimeout
(
20000
);
jest
.
setTimeout
(
20000
);
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
data
=
await
page
.
data
()
...
...
@@ -29,39 +29,24 @@ describe('test swiper', () => {
*/
});
it
(
'
check autoplay loop
'
,
async
()
=>
{
await
page
.
setData
({
autoplaySelect
:
true
,
currentValChange
:
0
,
})
await
page
.
waitFor
(
600
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
waitFor
(
1600
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
1
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
2
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
setData
({
circularSelect
:
true
,
currentValChange
:
0
,
})
await
page
.
waitFor
(
600
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
waitFor
(
1600
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
1
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
2
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
setData
({
circularSelect
:
false
,
autoplaySelect
:
false
})
it
(
'
check autoplay loop
'
,
async
()
=>
{
await
page
.
setData
({
currentValChange
:
0
,
autoplaySelect
:
true
,
})
await
page
.
waitFor
(
2400
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
1
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
2
)
await
page
.
waitFor
(
2000
)
expect
(
await
getData
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
setData
({
autoplaySelect
:
false
})
await
page
.
waitFor
(
300
)
});
it
(
'
check current
'
,
async
()
=>
{
await
page
.
setData
({
currentVal
:
2
,
...
...
pages/component/text/text-props.test.js
浏览文件 @
794ef1b6
...
...
@@ -9,7 +9,7 @@ describe('text-props', () => {
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
})
it
(
'
empty text
'
,
async
()
=>
{
...
...
pages/component/video/video.test.js
浏览文件 @
794ef1b6
...
...
@@ -24,6 +24,20 @@ describe('component-native-video', () => {
expect
(
await
page
.
data
(
'
isPause
'
)).
toBe
(
true
);
});
it
(
'
test local source
'
,
async
()
=>
{
await
page
.
callMethod
(
'
downloadSource
'
);
await
page
.
waitFor
(
5000
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
localSrc
:
'
/static/test-video/2minute-demo.m3u8
'
});
await
page
.
waitFor
(
100
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
autoTest
:
false
});
});
it
(
'
test format
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
'
/pages/component/video/video-format
'
);
await
page
.
waitFor
(
1000
);
...
...
pages/component/web-view-local/web-view-local.test.js
浏览文件 @
794ef1b6
...
...
@@ -12,14 +12,14 @@ describe('component-native-web-view', () => {
});
it
(
'
screenshot
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
loadFinish
'
)
===
true
;
});
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
});
});
\ No newline at end of file
pages/component/web-view/web-view.test.js
浏览文件 @
794ef1b6
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-web-view
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/web-view/web-view
'
);
...
...
pages/pages.test.js
浏览文件 @
794ef1b6
...
...
@@ -38,7 +38,6 @@ const pages = [
// CSS
'
/pages/CSS/background/background-color
'
,
'
/pages/CSS/background/background-image
'
,
'
/pages/CSS/border/complex-border/complex-border
'
,
'
/pages/CSS/border/border-bottom
'
,
'
/pages/CSS/border/border-color
'
,
...
...
@@ -121,7 +120,7 @@ const pages = [
// '/pages/API/element-draw/element-draw',
]
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
)
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
// 规避 web 端不支持页面
pages
.
push
(
"
/pages/component/list-view/list-view
"
,
...
...
@@ -133,19 +132,27 @@ if (process.env.uniTestPlatformInfo.startsWith('android')) {
'
/pages/template/pull-zoom-image/pull-zoom-image
'
,
'
/pages/template/scroll-fold-nav/scroll-fold-nav
'
,
'
/pages/template/scroll-sticky/scroll-sticky
'
,
'
/pages/template/custom-refresher/custom-refresher
'
,
'
/pages/template/custom-tab-bar/custom-tab-bar
'
,
'
/pages/template/custom-refresher/custom-refresher
'
,
'
/pages/template/custom-tab-bar/custom-tab-bar
'
,
'
/pages/template/half-screen/half-screen
'
,
)
}
// 设置position: fixed的页面不能截取完整内容
const
notFullPages
=
[
'
/pages/CSS/layout/position
'
,
'
/pages/CSS/layout/z-index
'
]
}
// 设置position: fixed的页面不能截取完整内容
const
notFullPages
=
[
'
/pages/CSS/layout/position
'
,
'
/pages/CSS/layout/z-index
'
]
let
page
;
let
windowInfo
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
'
)
}
describe
(
"
page screenshot test
"
,
()
=>
{
beforeAll
(
async
()
=>
{
console
.
log
(
"
page screenshot test start
"
);
...
...
@@ -162,14 +169,36 @@ describe("page screenshot test", () => {
});
test
.
each
(
pages
)(
"
%s
"
,
async
()
=>
{
console
.
log
(
"
Taking screenshot:
"
,
pageIndex
,
pages
[
pageIndex
]);
let
fullPage
=
true
;
if
(
notFullPages
.
includes
(
pages
[
pageIndex
]))
{
fullPage
=
false
;
let
fullPage
=
true
;
if
(
notFullPages
.
includes
(
pages
[
pageIndex
]))
{
fullPage
=
false
;
}
const
screenshotParams
=
{
fullPage
}
const
image
=
await
program
.
screenshot
({
fullPage
:
fullPage
});
expect
(
image
).
toMatchImageSnapshot
();
if
(
!
fullPage
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
offsetY
=
'
0
'
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
android
'
))
{
offsetY
=
'
44
'
}
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
if
(
!
windowInfo
)
{
windowInfo
=
await
getWindowInfo
()
page
=
await
program
.
reLaunch
(
pages
[
pageIndex
]);
await
page
.
waitFor
(
1000
);
}
offsetY
=
`
${
windowInfo
.
safeAreaInsets
.
top
+
44
}
`
}
screenshotParams
.
offsetY
=
offsetY
}
const
image
=
await
program
.
screenshot
(
screenshotParams
);
expect
(
image
).
toSaveImageSnapshot
({
customSnapshotIdentifier
()
{
return
`__pages_test__/
${
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
).
substring
(
1
)}
`
}
})
await
page
.
waitFor
(
500
);
});
});
});
pages/template/list-news/list-news.test.js
浏览文件 @
794ef1b6
...
...
@@ -11,6 +11,6 @@ describe('template-list-news', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
to
Match
ImageSnapshot
()
expect
(
image
).
to
Save
ImageSnapshot
()
});
});
pages/template/navbar-lite/navbar-lite.test.js
浏览文件 @
794ef1b6
...
...
@@ -37,10 +37,10 @@ describe("setCustomNavigationBarColor", () => {
await
page
.
waitFor
(
1000
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
adbScreenShotArea
,
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
...
...
@@ -51,12 +51,12 @@ describe("setCustomNavigationBarColor", () => {
await
page
.
waitFor
(
1000
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
deviceShot
:
true
,
area
:
adbScreenShotArea
,
});
expect
(
image
).
to
Match
ImageSnapshot
();
expect
(
image
).
to
Save
ImageSnapshot
();
}
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
4
);
});
});
});
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
浏览文件 @
794ef1b6
...
...
@@ -8,7 +8,7 @@ const pages = [
"
pages/component/text/text-props
"
,
"
pages/component/progress/progress
"
,
"
pages/component/form/form
"
,
"
pages/component/button/button
"
,
"
pages/component/button/button
"
,
"
pages/component/button/buttonstatus
"
,
"
pages/component/radio/radio
"
,
"
pages/component/rich-text/rich-text
"
,
...
...
@@ -26,6 +26,7 @@ const pages = [
"
pages/component/video/video-format
"
,
"
pages/component/navigator/navigator
"
,
"
pages/component/navigator/navigate
"
,
"
pages/component/navigator/redirect
"
,
"
pages/component/general-attribute/general-attribute
"
,
"
pages/component/general-event/general-event
"
,
...
...
@@ -43,7 +44,6 @@ const pages = [
"
pages/API/navigator/navigator
"
,
"
pages/API/set-navigation-bar-color/set-navigation-bar-color
"
,
"
pages/API/set-navigation-bar-title/set-navigation-bar-title
"
,
"
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color
"
,
"
pages/API/navigator/new-page/new-page-1
"
,
"
pages/API/navigator/new-page/new-page-3
"
,
"
pages/API/pull-down-refresh/pull-down-refresh
"
,
...
...
@@ -69,7 +69,6 @@ const pages = [
"
pages/API/get-device-info/get-device-info
"
,
"
pages/API/get-app-base-info/get-app-base-info
"
,
"
pages/API/preview-image/preview-image
"
,
"
pages/API/save-image-to-photos-album/save-image-to-photos-album
"
,
"
pages/API/choose-image/choose-image
"
,
"
pages/API/get-network-type/get-network-type
"
,
"
pages/API/page-scroll-to/page-scroll-to
"
,
...
...
@@ -197,6 +196,7 @@ const pages = [
// "pages/API/element-takesnapshot/element-takesnapshot",
// "pages/API/get-system-setting/get-system-setting",
// "pages/API/get-app-authorize-setting/get-app-authorize-setting",
// "pages/API/save-image-to-photos-album/save-image-to-photos-album",
// 仅 web
// pages/template/browser-canvas/browser-canvas
...
...
@@ -237,16 +237,20 @@ const PAGE_PATH =
describe
(
"
shot-compare
"
,
()
=>
{
let
shouldCompareScreenShot
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
const
uniTestPlatformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
version
=
parseInt
(
uniTestPlatformInfo
.
split
(
"
"
)[
1
])
shouldCompareScreenShot
=
version
>
9
}
if
(
uniTestPlatformInfo
.
startsWith
(
'
ios
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
shouldCompareScreenShot
=
true
}
if
(
!
shouldCompareScreenShot
)
{
it
(
"
other platform not support
"
,
async
()
=>
{
expect
(
1
).
toBe
(
1
);
});
});
return
}
...
...
@@ -285,20 +289,22 @@ describe("shot-compare", () => {
const
isCustomNavigationBar
=
customNavigationPages
.
includes
(
pages
[
pageIndex
]);
const
{
statusBarHeight
,
safeArea
,
devicePixelRatio
}
=
await
page
.
data
();
const
screenshotParams
=
{
fullPage
:
true
,
adb
:
isNeedAdbScreenshot
,
//
adb
截图时跳过状态栏
deviceShot
:
isNeedAdbScreenshot
,
//
deviceShot
截图时跳过状态栏
area
:
{
x
:
0
,
y
:
statusBarHeight
*
devicePixelRatio
,
},
}
const
screenshotPath
=
`__webview_
_
${
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
)}
`
;
const
screenshotPath
=
`__webview_
comparison__/
${
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
)}
`
;
// web in webview screenshot
let
startTime
=
Date
.
now
();
// 加载依赖页面
if
(
childToParentPagesMap
.
get
(
pages
[
pageIndex
]))
{
await
page
.
setData
({
...
...
@@ -316,8 +322,7 @@ describe("shot-compare", () => {
isLoaded
:
false
,
isCustomNavigationBar
,
});
const
startTime
=
Date
.
now
();
startTime
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
...
...
@@ -327,11 +332,11 @@ describe("shot-compare", () => {
await
page
.
waitFor
(
3000
);
}
// web 端非
adb
截图时设置 offsetY 移除导航栏
// web 端非
deviceShot
截图时设置 offsetY 移除导航栏
const
webSnapshot
=
await
program
.
screenshot
({
...
screenshotParams
,
id
:
'
webview-screenshot-comparison
'
,
offsetY
:
`
${
isCustomNavigationBar
?
0
:
44
}
`
offsetY
:
`
${
isCustomNavigationBar
?
0
:
44
+
safeArea
.
top
}
`
});
expect
(
webSnapshot
).
toMatchImageSnapshot
({
customSnapshotIdentifier
()
{
...
...
@@ -355,4 +360,4 @@ describe("shot-compare", () => {
},
});
});
});
});
pages/webview-screenshot/webview-screenshot.test.js
浏览文件 @
794ef1b6
...
...
@@ -42,7 +42,6 @@ const pages = [
"
pages/API/navigator/navigator
"
,
"
pages/API/set-navigation-bar-color/set-navigation-bar-color
"
,
"
pages/API/set-navigation-bar-title/set-navigation-bar-title
"
,
"
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color
"
,
"
pages/API/navigator/new-page/new-page-1
"
,
"
pages/API/navigator/new-page/new-page-3
"
,
"
pages/API/pull-down-refresh/pull-down-refresh
"
,
...
...
@@ -67,10 +66,7 @@ const pages = [
"
pages/API/get-system-info/get-system-info
"
,
"
pages/API/get-device-info/get-device-info
"
,
"
pages/API/get-app-base-info/get-app-base-info
"
,
"
pages/API/get-system-setting/get-system-setting
"
,
"
pages/API/get-app-authorize-setting/get-app-authorize-setting
"
,
"
pages/API/preview-image/preview-image
"
,
"
pages/API/save-image-to-photos-album/save-image-to-photos-album
"
,
"
pages/API/choose-image/choose-image
"
,
"
pages/API/get-network-type/get-network-type
"
,
"
pages/API/page-scroll-to/page-scroll-to
"
,
...
...
@@ -196,6 +192,9 @@ const pages = [
// "pages/template/scroll-sticky/scroll-sticky",
// "pages/API/exit/exit",
// "pages/API/element-takesnapshot/element-takesnapshot",
// "pages/API/get-app-authorize-setting/get-app-authorize-setting",
// "pages/API/get-system-setting/get-system-setting",
// "pages/API/save-image-to-photos-album/save-image-to-photos-album",
// 仅 web
// pages/template/browser-canvas/browser-canvas
...
...
@@ -236,22 +235,33 @@ const PAGE_PATH =
describe
(
"
shot-compare
"
,
()
=>
{
let
shouldCompareScreenShot
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
let
version
=
process
.
env
.
uniTestPlatformInfo
version
=
parseInt
(
version
.
split
(
"
"
)[
1
])
const
uniTestPlatformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
version
=
parseInt
(
uniTestPlatformInfo
.
split
(
"
"
)[
1
])
shouldCompareScreenShot
=
version
>
9
}
if
(
uniTestPlatformInfo
.
startsWith
(
'
ios
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
shouldCompareScreenShot
=
true
}
if
(
!
shouldCompareScreenShot
)
{
it
(
"
other platform not support
"
,
async
()
=>
{
expect
(
1
).
toBe
(
1
);
});
});
return
}
let
page
=
null
;
let
pageIndex
=
0
;
let
baseSrc
=
""
;
beforeAll
(
async
()
=>
{
// 获取导航栏+状态栏高度
page
=
await
program
.
reLaunch
(
'
/pages/API/get-window-info/get-window-info
'
)
await
page
.
callMethod
(
'
getWindowInfo
'
)
// 获取设备像素比
page
=
await
program
.
reLaunch
(
'
/pages/API/get-device-info/get-device-info
'
)
await
page
.
callMethod
(
'
getDeviceInfo
'
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
);
await
page
.
waitFor
(
500
);
...
...
@@ -265,7 +275,6 @@ describe("shot-compare", () => {
});
beforeEach
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
);
await
page
.
waitFor
(
500
);
});
afterEach
(()
=>
{
...
...
@@ -276,21 +285,22 @@ describe("shot-compare", () => {
const
isNeedAdbScreenshot
=
needAdbScreenshot
(
pages
[
pageIndex
]);
const
isCustomNavigation
=
customNavigationPages
.
includes
(
pages
[
pageIndex
]);
const
{
heade
rHeight
,
statusBa
rHeight
,
devicePixelRatio
}
=
await
page
.
data
();
const
screenshotParams
=
{
fullPage
:
true
,
adb
:
isNeedAdbScreenshot
,
//
adb
截图时跳过状态栏
deviceShot
:
isNeedAdbScreenshot
,
//
deviceShot
截图时跳过状态栏
area
:
{
x
:
0
,
y
:
(
heade
rHeight
-
44
)
*
devicePixelRatio
,
y
:
(
statusBa
rHeight
-
44
)
*
devicePixelRatio
,
},
}
const
screenshotPath
=
`
webview-shot__
${
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
)}
`
;
const
screenshotPath
=
`
__webview-shot__/
${
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
)}
`
;
// web in webview screenshot
let
startTime
=
Date
.
now
();
// 加载依赖页面
if
(
childToParentPagesMap
.
get
(
pages
[
pageIndex
]))
{
await
page
.
setData
({
...
...
@@ -309,7 +319,7 @@ describe("shot-compare", () => {
needRemoveWebHead
:
!
isNeedAdbScreenshot
,
});
const
startTime
=
Date
.
now
();
startTime
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
...
...
@@ -319,15 +329,15 @@ describe("shot-compare", () => {
await
page
.
waitFor
(
3000
);
}
// web 端非
adb
截图时设置 offsetY 移除导航栏
// web 端非
deviceShot
截图时设置 offsetY 移除导航栏
const
webSnapshot
=
await
program
.
screenshot
({
...
screenshotParams
,
offsetY
:
`
${
isCustomNavigation
?
0
:
headerHeight
}
`
offsetY
:
`
${
isCustomNavigation
?
0
:
statusBarHeight
+
44
}
`
});
expect
(
webSnapshot
).
to
Match
ImageSnapshot
({
expect
(
webSnapshot
).
to
Save
ImageSnapshot
({
customSnapshotIdentifier
()
{
return
screenshotPath
;
},
});
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录