cloudObject.test.js 1.5 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.io/collocation/auto/hbuilderx-extension/index

describe('pages/cloudObject/cloudObject.vue', () => {

	let page;
	beforeAll(async () => {
		page = await program.reLaunch('/pages/cloudObject/cloudObject')
		await page.waitFor(500);
	});
	
	it('云对象-检查标题',async()=>{
		expect.assertions(1);
		const title = await page.$('.title')
		expect(await title.text()).toBe('基础示例-云对象');
	})

	it('新增一条数据',async()=>{
		expect.assertions(1);
		const addData = await page.callMethod('add')
		expect(addData).toBeDefined();
	})
	
	it('删除一条数据',async()=>{
		expect.assertions(1);
		const removeData = await page.callMethod('remove')
		expect(removeData).toBe('成功删除unicloud-test内第一条数据');
	}) 
	
	it('修改数据',async()=>{
		expect.assertions(1);
		const updateData = await page.callMethod('update')
		expect(updateData).toBeDefined();
	})
	
	it('查询前10条数据',async()=>{
		// expect.assertions(1);
		const getTenData = await page.callMethod('get')
		console.log("getTenData.data.length: ",getTenData.data.length);
		// expect(getTenData.length).not.toBeUndefined();
		expect(getTenData.data.length).toBeGreaterThanOrEqual(1);
		// expect(getTenData.length).toBeDefined();
		
	})
	
	it('使用公用模块',async()=>{
		expect.assertions(1);
		const useCommon = await page.callMethod('useCommon')
		const record = {"secret":"abcdefg","version":"1.0.0"}
		expect(useCommon).toEqual(record);
	})
	
});