Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-starter
提交
351f872b
U
uni-starter
项目概览
DCloud
/
uni-starter
通知
4690
Star
229
Fork
210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
351f872b
编写于
5月 29, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test:screenshot
上级
17bff4fc
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
43 addition
and
63 deletion
+43
-63
jest.config.js
jest.config.js
+1
-3
pages/grid/grid.test.js
pages/grid/grid.test.js
+5
-7
pages/list/list.test.js
pages/list/list.test.js
+11
-12
pages/list/search/search.test.js
pages/list/search/search.test.js
+1
-5
pages/pages.test.js
pages/pages.test.js
+5
-9
pages/ucenter/about/about.test.js
pages/ucenter/about/about.test.js
+1
-4
pages/ucenter/settings/settings.test.js
pages/ucenter/settings/settings.test.js
+6
-3
pages/ucenter/ucenter.test.js
pages/ucenter/ucenter.test.js
+6
-12
testSequencer.js
testSequencer.js
+1
-1
uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js
uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js
+6
-7
未找到文件。
jest.config.js
浏览文件 @
351f872b
const
path
=
require
(
'
path
'
);
module
.
exports
=
{
testTimeout
:
50000
,
reporters
:
[
'
default
'
],
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
...
...
pages/grid/grid.test.js
浏览文件 @
351f872b
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
const
PAGE_PATH
=
'
/pages/grid/grid
'
jest
.
setTimeout
(
15000
)
jest
.
setTimeout
(
20000
)
describe
(
'
grid
'
,
()
=>
{
let
page
,
hasLogin
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
switchTab
(
PAGE_PATH
)
page
=
await
program
.
switchTab
(
'
/pages/grid/grid
'
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
检测宫格
'
,
async
()
=>
{
console
.
log
(
"
page
"
,
page
)
if
(
process
.
env
.
UNI_PLATFORM
===
"
mp-weixin
"
){
await
page
.
waitFor
(
5000
)
}
else
{
await
page
.
waitFor
(
2000
)
}
})
it
(
'
检测宫格
'
,
async
()
=>
{
hasLogin
=
await
page
.
data
(
'
hasLogin
'
)
let
gridList
=
await
page
.
data
(
'
gridList
'
)
console
.
log
(
"
gridList
"
,
gridList
.
length
,
hasLogin
)
...
...
pages/list/list.test.js
浏览文件 @
351f872b
const
PAGE_PATH
=
'
/pages/list/list
'
describe
(
'
list
'
,
()
=>
{
let
page
,
containsVite
,
isApp
,
currentPage
;
let
page
,
containsVite
,
isApp
;
containsVite
=
process
.
env
.
UNI_CLI_PATH
.
includes
(
'
uniapp-cli-vite
'
)
isApp
=
process
.
env
.
UNI_PLATFORM
.
includes
(
'
app
'
)
if
(
containsVite
&&
isApp
)
{
...
...
@@ -10,7 +9,7 @@ describe('list', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
switchTab
(
PAGE_PATH
)
page
=
await
program
.
switchTab
(
'
/pages/list/list
'
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
setData
({
'
isTest
'
:
true
...
...
@@ -23,13 +22,13 @@ describe('list', () => {
console
.
log
(
'
getTitle:
'
,
getTitle
);
expect
(
getTitle
.
title
).
toBe
(
'
阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务
'
)
})
it
(
'
点击搜索跳转详情页
'
,
async
()
=>
{
const
items
=
await
page
.
$
(
'
.uni-list-item
'
)
await
items
.
tap
()
await
page
.
waitFor
(
3000
)
await
page
.
waitFor
(
'
view
'
)
currentPage
=
await
program
.
currentPage
()
console
.
log
(
'
currentPage:
'
,
currentPage
);
expect
(
currentPage
.
path
).
toBe
(
'
pages/list/detail
'
)
})
//
it('点击搜索跳转详情页', async () => {
//
const items = await page.$('.uni-list-item')
//
await items.tap()
//
await page.waitFor(3000)
//
await page.waitFor('view')
//
currentPage = await program.currentPage()
//
console.log('currentPage: ', currentPage);
//
expect(currentPage.path).toBe('pages/list/detail')
//
})
})
\ No newline at end of file
pages/list/search/search.test.js
浏览文件 @
351f872b
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
const
PAGE_PATH
=
'
/pages/list/search/search
'
describe
(
'
search
'
,
()
=>
{
let
page
,
containsVite
,
isApp
;
containsVite
=
process
.
env
.
UNI_CLI_PATH
.
includes
(
'
uniapp-cli-vite
'
)
...
...
@@ -12,8 +9,7 @@ describe('search', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
console
.
log
(
'
pageStack
'
,
await
program
.
pageStack
())
page
=
await
program
.
reLaunch
(
'
/pages/list/search/search
'
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
搜索发现-显示-隐藏
'
,
async
()
=>
{
...
...
pages/pages.test.js
浏览文件 @
351f872b
let
pageIndex
=
0
const
pages
=
[
'
/uni_modules/uni-id-pages/pages/login/login-withpwd
'
'
/uni_modules/uni-id-pages/pages/login/login-withpwd
'
,
'
/pages/grid/grid
'
]
let
page
;
...
...
@@ -25,12 +26,7 @@ describe('page screenshot test', () => {
console
.
log
(
"
page screenshot test finish
"
);
});
test
.
each
(
pages
)(
'
%s
'
,
async
()
=>
{
// const image = await program.screenshot();
// expect(image).toMatchImageSnapshot();
// await page.waitFor(500);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
await
page
.
waitFor
(
500
);
})
...
...
pages/ucenter/about/about.test.js
浏览文件 @
351f872b
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
const
PAGE_PATH
=
'
/pages/ucenter/about/about
'
describe
(
'
about
'
,
()
=>
{
let
page
;
if
(
process
.
env
.
UNI_PLATFORM
===
"
mp-weixin
"
){
...
...
@@ -10,7 +7,7 @@ describe('about', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
page
=
await
program
.
reLaunch
(
'
/pages/ucenter/about/about
'
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
appName
'
,
async
()
=>
{
...
...
pages/ucenter/settings/settings.test.js
浏览文件 @
351f872b
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
jest
.
setTimeout
(
30000
);
const
PAGE_PATH
=
'
/pages/ucenter/settings/settings
'
describe
(
'
settings
'
,
()
=>
{
let
page
,
hasLogin
;
if
(
process
.
env
.
uniTestPlatformInfo
==
'
ios_simulator 13.7
'
)
{
...
...
@@ -10,7 +8,7 @@ describe('settings', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
page
=
await
program
.
navigateTo
(
'
/pages/ucenter/settings/settings
'
)
await
page
.
waitFor
(
'
view
'
)
hasLogin
=
await
page
.
callMethod
(
'
hasLoginTest
'
)
console
.
log
(
"
登录状态
"
,
hasLogin
)
...
...
@@ -33,6 +31,11 @@ describe('settings', () => {
expect
((
await
el
.
$$
(
'
.mt10
'
)).
length
).
toBe
(
2
)
}
})
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
await
page
.
waitFor
(
500
);
})
it
(
'
退出登录
'
,
async
()
=>
{
const
bottomEl
=
await
page
.
$
(
'
.bottom-back-text
'
)
expect
(
await
bottomEl
.
text
()).
toBe
(
'
退出登录
'
)
...
...
pages/ucenter/ucenter.test.js
浏览文件 @
351f872b
jest
.
setTimeout
(
30000
);
const
PAGE_PATH
=
'
/pages/ucenter/ucenter
'
describe
(
'
ucenter
'
,
()
=>
{
let
page
,
platform
,
hasLogin
;
platform
=
process
.
env
.
UNI_PLATFORM
...
...
@@ -11,7 +10,7 @@ describe('ucenter', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
switchTab
(
PAGE_PATH
)
page
=
await
program
.
switchTab
(
'
/pages/ucenter/ucenter
'
)
await
page
.
waitFor
(
'
view
'
)
hasLogin
=
await
page
.
callMethod
(
'
hasLoginTest
'
)
console
.
log
(
"
登录状态
"
,
hasLogin
,
platform
)
...
...
@@ -57,14 +56,9 @@ describe('ucenter', () => {
console
.
log
(
"
签到失败
"
);
}
})
// it('screenshot',async()=>{
// await program.screenshot({
// path: "static/screenshot/ucenter.png"
// })
// const image = await program.screenshot({
// fullPage: true
// })
// expect(image).toSaveImageSnapshot();
// await page.waitFor(500);
// })
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
await
page
.
waitFor
(
500
);
})
})
\ No newline at end of file
testSequencer.js
浏览文件 @
351f872b
const
Sequencer
=
require
(
"
@jest/test-sequencer
"
).
default
;
const
sortTestFilenames
=
[
"
list.test.js
"
,
"
search.test.js
"
,
"
grid
.test.js
"
,
"
about.test.js
"
,
"
register.test.js
"
,
"
login-withpwd.test.js
"
,
"
userinfo.test.js
"
,
"
ucenter.test.js
"
,
"
settings.test.js
"
,
"
pages.test.js
"
];
const
sortTestFilenames
=
[
"
grid.test.js
"
,
"
list.test.js
"
,
"
search
.test.js
"
,
"
about.test.js
"
,
"
register.test.js
"
,
"
login-withpwd.test.js
"
,
"
userinfo.test.js
"
,
"
ucenter.test.js
"
,
"
settings.test.js
"
,
"
pages.test.js
"
];
class
CustomSequencer
extends
Sequencer
{
sort
(
tests
)
{
// 测试例排序
...
...
uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js
浏览文件 @
351f872b
...
...
@@ -29,11 +29,10 @@ describe('userinfo', () => {
console
.
log
(
"
update--nickname---2
"
,
userInfo
.
nickname
)
expect
(
userInfo
.
nickname
).
toBe
(
nickname
)
})
it
(
"
screenshot
"
,
async
()
=>
{
await
program
.
screenshot
({
path
:
"
static/screenshot/userinfo.png
"
// 默认项目根目录
})
await
page
.
waitFor
(
500
)
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
await
page
.
waitFor
(
500
);
})
// it("头像", async () => {
// const imgs = [
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录