Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uniCloud
提交
7a56fb42
H
hello-uniCloud
项目概览
DCloud
/
hello-uniCloud
通知
294
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uniCloud
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7a56fb42
编写于
12月 01, 2023
作者:
A
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add testSequencer.js
上级
a0e68140
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
73 addition
and
18 deletion
+73
-18
pages/user-info/detail.test.js
pages/user-info/detail.test.js
+23
-0
pages/user-info/edit.test1.js
pages/user-info/edit.test1.js
+9
-18
pages/user-info/list.test.js
pages/user-info/list.test.js
+25
-0
testSequencer.js
testSequencer.js
+16
-0
未找到文件。
pages/user-info/detail.test
1
.js
→
pages/user-info/detail.test.js
浏览文件 @
7a56fb42
describe
(
'
pages/user-info/detail.vue
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page
=
await
program
.
reLaunch
(
'
/pages/user-info/detail
'
)
await
page
.
waitFor
(
'
view
'
)
// page = await program.navigateTo('/pages/user-info/detail')
page
=
await
program
.
currentPage
()
await
page
.
waitFor
(
'
view
'
)
// console.log('page: ',page);
})
it
(
'
点击修改
'
,
async
()
=>
{
const
getId
=
await
page
.
data
(
'
_id
'
)
console
.
log
(
"
getId:
"
,
getId
);
expect
.
assertions
(
1
);
// expect.assertions(1);
const
getQuery
=
await
page
.
query
console
.
log
(
'
getQuery:
'
,
getQuery
);
expect
(
getQuery
).
not
.
toBeUndefined
();
const
handleUpdate
=
await
page
.
callMethod
(
'
handleUpdate
'
)
})
it
(
'
点击删除
'
,
async
()
=>
{
const
handleDelete
=
await
page
.
callMethod
(
'
handleDelete
'
)
await
page
.
callMethod
(
'
handleUpdate
'
)
await
page
.
waitFor
(
1000
)
console
.
log
(
'
currentPage
'
,
await
program
.
currentPage
())
// console.log('query',await page.query)
expect
((
await
program
.
currentPage
()).
path
).
toBe
(
'
pages/user-info/edit
'
)
})
// it('点击删除',async()=>{
// const handleDelete = await page.callMethod('handleDelete')
// })
})
\ No newline at end of file
pages/user-info/edit.test1.js
浏览文件 @
7a56fb42
describe
(
'
pages/user-info/detail.vue
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page
=
await
program
.
reLaunch
(
'
/pages/user-info/edit?id=601d044ac9e7be0001cc00b8
'
)
await
page
.
waitFor
(
'
view
'
)
// page = await program.navigateTo('/pages/user-info/edit?id=601d044ac9e7be0001cc00b8')
page
=
await
program
.
currentPage
()
console
.
log
(
'
page:
'
,
page
);
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
修改表单内容
'
,
async
()
=>
{
const
getQuery
=
await
page
.
query
console
.
log
(
'
getQuery:
'
,
getQuery
);
let
username
=
"
林小明加
"
let
weight
=
51
let
mobile
=
"
17766666666
"
let
email
=
"
1076998866@qq.com
"
let
url
=
"
https://dcloud.io/
"
const
setForm
=
await
page
.
setData
({
await
page
.
setData
({
"
formData
"
:
{
"
username
"
:
username
,
"
gender
"
:
1
,
...
...
@@ -34,27 +32,20 @@ describe('pages/user-info/detail.vue', () => {
}
})
await
page
.
waitFor
(
1000
)
//console.log(await page.data('formData'), "setForm---");
//姓名只能输入中文
//expect(username).toMatch(/^[\u4e00-\u9fa5]+/);
expect
(
username
).
toMatch
(
/^
[\u
4e00-
\u
9fa5
]
+/
);
//手机号校验
expect
(
mobile
).
toMatch
(
/^1
[
3|4|5|7|8
][
0-9
]{9}
$/
);
//var re=/\w+@[a-z0-9]+\.[a-z]{2,4}/
expect
(
email
).
toMatch
(
/
\w
+@
[
a-z0-9
]
+
\.[
a-z
]{2,4}
/
);
//url验证
const
urlEx
=
/^
((
ht|f
)
tps
?)
:
\/\/[\w\-]
+
(\.[\w\-]
+
)
+
([\w\-\.
,@?^=%&:
\/
~
\+
#
]
*
[\w\-\@
?^=%&
\/
~
\+
#
])?
$/
;
expect
(
url
).
toMatch
(
urlEx
);
//体重要大于50 小于或等于500
expect
(
weight
).
toBeGreaterThan
(
50
)
expect
(
weight
).
toBeLessThanOrEqual
(
500
)
await
page
.
callMethod
(
'
submit
'
)
const
res
=
await
page
.
callMethod
(
'
submit
'
)
console
.
log
(
'
res:
'
,
res
);
})
})
\ No newline at end of file
pages/user-info/list.test
1
.js
→
pages/user-info/list.test.js
浏览文件 @
7a56fb42
// jest.setTimeout(20000)
describe
(
'
pages/user-info/list.vue
'
,
()
=>
{
let
page
let
page
,
currentPage
;
beforeAll
(
async
()
=>
{
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page
=
await
program
.
reLaunch
(
'
/pages/user-info/list
'
)
page
=
await
program
.
navigateTo
(
'
/pages/user-info/list
'
)
await
page
.
waitFor
(
'
view
'
)
page
=
await
program
.
currentPage
()
})
// beforeEach(async()=>{
// jest.setTimeout(20000)
// return false
// })
it
(
'
点击fab跳转到添加页
'
,
async
()
=>
{
await
page
.
callMethod
(
'
fabClick
'
)
currentPage
=
await
program
.
currentPage
()
expect
(
currentPage
.
path
).
toBe
(
'
pages/user-info/add
'
)
await
program
.
navigateBack
()
})
it
(
'
点击第一条
'
,
async
()
=>
{
const
items
=
await
page
.
$$
(
'
.uni-list-item
'
)
// console.log('items: ',items);
await
items
[
0
].
tap
()
await
page
.
waitFor
(
500
)
currentPage
=
await
program
.
currentPage
()
// console.log('currentPage:---3 ',currentPage);
expect
(
currentPage
.
path
).
toBe
(
'
pages/user-info/detail
'
)
// await program.navigateBack()
// console.log('currentPage',await program.currentPage())
})
/* it('点击某一条',async()=>{
const getDataList = await page.data('dataList')
console.log("getDataList: ",getDataList);
for (var i = 0; i < getDataList.length; i++) {
console.log("getDataList[i]: ",getDataList[i]);
}
const uId = getDataList[0]._id
console.log("uId: ",uId);
if(uId){
const handleItemClick = await page.callMethod('handleItemClick',uId)
}
}) */
it
(
'
点击fab跳转到添加页
'
,
async
()
=>
{
const
fabClick
=
await
page
.
callMethod
(
'
fabClick
'
)
})
})
\ No newline at end of file
testSequencer.js
0 → 100644
浏览文件 @
7a56fb42
const
Sequencer
=
require
(
"
@jest/test-sequencer
"
).
default
;
const
sortTestFilenames
=
[
"
add.test.js
"
,
"
list.test.js
"
,
"
detail.test.js
"
,
"
edit.test.js
"
];
class
CustomSequencer
extends
Sequencer
{
sort
(
tests
)
{
// 测试例排序
const
copyTests
=
Array
.
from
(
tests
);
const
sortTests
=
sortTestFilenames
.
map
((
filename
)
=>
{
return
copyTests
.
find
((
test
)
=>
test
.
path
.
endsWith
(
filename
));
})
.
filter
(
Boolean
);
console
.
log
(
sortTests
);
return
[...
new
Set
([...
sortTests
,
...
copyTests
])];
}
}
module
.
exports
=
CustomSequencer
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录