使用uniapp自带自动化测试插件创建并运行测试用例后提示
ReferenceError: uniCloud is not defined
在添加
const uniCloud = require('@dcloudio/uni-cloud');
后报错
errMsg: 'uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间'
但是我已经关联了云空间并且通过右键项目uni-app运行自动化测试的方式进行测试
以下是源码
const uniCloud = require('@dcloudio/uni-cloud');
function sum(a,b){
return a+b
}
describe("sum test", () => {
it('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
test('cloud database connection', () => {
const db=uniCloud.database();
let count=db.collection('opendb-mall-goods').count();
expect(count).toBeGreaterThan(0);
});
})
1 个回复
DCloud_HB_WDL
uniapp自动化测试插件,已更新,请升级。
https://ext.dcloud.net.cn/plugin?id=5708