Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7ebe4d31
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7ebe4d31
编写于
1月 30, 2024
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prompt 增加自动化测试示例
上级
4a04f3f6
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
1481 addition
and
21 deletion
+1481
-21
pages/API/action-sheet/action-sheet.test.js
pages/API/action-sheet/action-sheet.test.js
+540
-0
pages/API/action-sheet/action-sheet.uvue
pages/API/action-sheet/action-sheet.uvue
+15
-8
pages/API/loading/loading.test.js
pages/API/loading/loading.test.js
+42
-0
pages/API/loading/loading.uvue
pages/API/loading/loading.uvue
+4
-0
pages/API/modal/modal.test.js
pages/API/modal/modal.test.js
+702
-0
pages/API/modal/modal.uvue
pages/API/modal/modal.uvue
+5
-1
pages/API/toast/toast.test.js
pages/API/toast/toast.test.js
+161
-0
pages/API/toast/toast.uvue
pages/API/toast/toast.uvue
+12
-12
未找到文件。
pages/API/action-sheet/action-sheet.test.js
0 → 100644
浏览文件 @
7ebe4d31
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isAndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/action-sheet/action-sheet
'
)
await
page
.
waitFor
(
200
);
});
it
(
"
onload-action-sheet-test
"
,
async
()
=>
{
if
(
isAndroid
)
{
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
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-0
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-0-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-0-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-0-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
current
:
1
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-2
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
current
:
2
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-2-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-2-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-2-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
width
:
windowWidth
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
});
pages/API/action-sheet/action-sheet.uvue
浏览文件 @
7ebe4d31
...
...
@@ -25,7 +25,7 @@
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="actionSheetTap">弹出action sheet</button>
<button class="uni-btn-v" type="default" @tap="actionSheetTap"
id="btn-action-sheet-show"
>弹出action sheet</button>
</view>
</view>
</view>
...
...
@@ -42,6 +42,7 @@
itemColorCustom: false,
itemContentLarge: false,
itemNumLargeSelect: false,
showErrorToast:true,
items: [{
value: '标题',
name: '有标题'
...
...
@@ -65,6 +66,10 @@
})
},
methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
radioChange(e : UniRadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) {
...
...
@@ -128,11 +133,13 @@
},
fail: (e) => {
console.log(e);
if(this.showErrorToast){
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
}
})
}
},
...
...
pages/API/loading/loading.test.js
0 → 100644
浏览文件 @
7ebe4d31
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isAndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/loading/loading
'
)
await
page
.
waitFor
(
200
);
});
// it("onload-loading-test", async () => {
// if (isAndroid) {
// 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,
// area: {
// x: 0,
// y: windowHeight / 2 + 120,
// height: windowHeight / 2,
// width:windowWidth
// },
// });
// expect(image).toMatchImageSnapshot();
// }else{
// const image = await program.screenshot({
// adb: true,
// fullPage: true
// });
// expect(image).toMatchImageSnapshot()
// }
// })
});
pages/API/loading/loading.uvue
浏览文件 @
7ebe4d31
...
...
@@ -67,6 +67,10 @@
}, 2000);
},
methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
radioChange(e : UniRadioGroupChangeEvent) {
const selected = this.items.find((item) : boolean => {
...
...
pages/API/modal/modal.test.js
0 → 100644
浏览文件 @
7ebe4d31
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isAndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/modal/modal
'
)
await
page
.
waitFor
(
200
);
});
it
(
"
onload-modal-test
"
,
async
()
=>
{
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-0
"
,
async
()
=>
{
await
page
.
setData
({
current
:
0
,
showCancelSelect
:
false
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-1
"
,
async
()
=>
{
await
page
.
setData
({
current
:
1
,
showCancelSelect
:
false
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
false
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-confirmText
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
true
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-confirmText-editable-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
true
,
editableSelect
:
true
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-confirmText-editable-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
false
,
confirmTextSelect
:
true
,
editableSelect
:
true
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-editable-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
true
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
false
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-editable-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
false
,
editableSelect
:
true
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
false
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-confirmText-placeholder
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
true
,
editableSelect
:
false
,
placeholderTextSelect
:
true
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-confirmText
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
true
,
editableSelect
:
false
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
modal-test-current-2-showCancel-cancelText-confirmText-editable
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
showCancelSelect
:
true
,
cancelTextSelect
:
true
,
confirmTextSelect
:
true
,
editableSelect
:
true
,
placeholderTextSelect
:
false
,
})
const
btnModalButton
=
await
page
.
$
(
'
#btn-modal-show
'
)
await
btnModalButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isAndroid
)
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
});
pages/API/modal/modal.uvue
浏览文件 @
7ebe4d31
...
...
@@ -37,7 +37,7 @@
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="modalTap">
<button class="uni-btn-v" type="default" @tap="modalTap"
id="btn-modal-show"
>
modal测试
</button>
</view>
...
...
@@ -87,6 +87,10 @@
})
},
methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
showCancelChange: function (e : UniSwitchChangeEvent) {
this.showCancelSelect = e.detail.value
},
...
...
pages/API/toast/toast.test.js
0 → 100644
浏览文件 @
7ebe4d31
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-toast
'
,
()
=>
{
let
page
;
const
isAndroid
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/toast/toast
'
)
await
page
.
waitFor
(
600
);
});
it
(
"
onload-toast-test
"
,
async
()
=>
{
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
btn-toast-default-1
"
,
async
()
=>
{
const
btnToastDefaultButton
=
await
page
.
$
(
'
#btn-toast-default
'
)
await
btnToastDefaultButton
.
tap
()
await
page
.
waitFor
(
200
)
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
btn-toast-duration-1
"
,
async
()
=>
{
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-toast-duration
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
2000
)
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
btn-toast-errorIcon-1
"
,
async
()
=>
{
const
btnToastErrorIconButton
=
await
page
.
$
(
'
#btn-toast-errorIcon
'
)
await
btnToastErrorIconButton
.
tap
()
await
page
.
waitFor
(
200
)
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
it
(
"
btn-toast-loading-1
"
,
async
()
=>
{
const
btnToastLoadingButton
=
await
page
.
$
(
'
#btn-toast-loading
'
)
await
btnToastLoadingButton
.
tap
()
await
page
.
waitFor
(
200
)
const
btnToastHideButton
=
await
page
.
$
(
'
#btn-toast-hide
'
)
await
btnToastHideButton
.
tap
()
await
page
.
waitFor
(
200
)
if
(
isAndroid
)
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
area
:
{
x
:
0
,
y
:
200
,
},
});
expect
(
image
).
toMatchImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
adb
:
true
,
fullPage
:
true
});
expect
(
image
).
toMatchImageSnapshot
()
}
})
// it("btn-toast-postion-bottom-1", async () => {
// const btnToastButton = await page.$('#btn-toast-postion-bottom')
// await btnToastButton.tap()
// await page.waitFor(200)
// if (isAndroid) {
// const windowHeight = uni.getWindowInfo().windowHeight;
// const windowWidth = uni.getWindowInfo().windowWidth;
// const image = await program.screenshot({
// adb: true,
// area: {
// x: 0,
// y: 200,
// height: windowHeight,
// width:windowWidth
// },
// });
// expect(image).toMatchImageSnapshot();
// }else{
// const image = await program.screenshot({
// adb: true,
// fullPage: true
// });
// expect(image).toMatchImageSnapshot()
// }
// })
});
pages/API/toast/toast.uvue
浏览文件 @
7ebe4d31
...
...
@@ -3,17 +3,17 @@
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap">点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError">点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button>
<button class="uni-btn-v" type="default" @tap="toast1Tap"
id="btn-toast-default"
>点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError"
id="btn-toast-errorIcon"
>点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap"
id="btn-toast-duration"
>点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap"
id="btn-toast-loading"
>点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<button class="uni-btn-v" type="default" @tap="toast5Tap">点击显示无图标的居底toast</button>
<button class="uni-btn-v" type="default" @tap="toast5Tap"
id="btn-toast-postion-bottom"
>点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast">点击隐藏toast</button>
<button class="uni-btn-v" type="default" @tap="hideToast"
id="btn-toast-hide"
>点击隐藏toast</button>
</view>
<text>{{exeRet}}</text>
</view>
...
...
@@ -41,7 +41,7 @@
uni.showToast({
title: "默认",
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
@@ -53,7 +53,7 @@
title: "默认",
icon: 'error',
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
@@ -65,7 +65,7 @@
title: "duration 3000",
duration: 3000,
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
@@ -78,7 +78,7 @@
icon: "loading",
duration: 5000,
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
@@ -90,7 +90,7 @@
title: "logo",
image: "/static/uni.png",
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
@@ -103,7 +103,7 @@
title: "显示一段轻提示",
position: 'bottom',
success: (res) => {
this.exeRet = "success:" + JSON.stringify(res)
+ new Date()
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录