提交 7a56fb42 编写于 作者: A Anne_LXM

add testSequencer.js

上级 a0e68140
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
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(/^[\u4e00-\u9fa5]+/);
//手机号校验
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
// 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
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.
先完成此消息的编辑!
想要评论请 注册