cloudObject.test.js 1.3 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.io/collocation/auto/hbuilderx-extension/index

describe('pages/cloudObject/cloudObject.vue', () => {
	let page;
	beforeAll(async () => {
A
Anne_LXM 已提交
6
		page = await program.switchTab('/pages/cloudObject/cloudObject')
A
Anne_LXM 已提交
7
		await page.waitFor('view');
study夏羽's avatar
study夏羽 已提交
8 9 10 11 12 13 14 15 16
	});
	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')
A
Anne_LXM 已提交
17
		expect(addData).toHaveLength(24);
study夏羽's avatar
study夏羽 已提交
18 19 20 21 22 23 24 25 26 27 28 29
	})
	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()=>{
A
Anne_LXM 已提交
30
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
31 32 33 34 35 36 37 38 39 40
		const getTenData = await page.callMethod('get')
		expect(getTenData.data.length).toBeGreaterThanOrEqual(1);
	})
	it('使用公用模块',async()=>{
		expect.assertions(1);
		const useCommon = await page.callMethod('useCommon')
		const record = {"secret":"abcdefg","version":"1.0.0"}
		expect(useCommon).toEqual(record);
	})
});