我正在尝试自学使用 Meteor 进行测试,但网上有太多相互矛盾和过时的信息,真的很难弄清楚我需要做什么。
我目前的情况是我有一个应用程序使用最新的 Meteor 版本(和导入文件夹结构)。
我已经全局安装了 chimp 并创建了一个/tests 目录。
我的第一个测试是使用 chimp/mocha 填写表格并尝试向数据库中插入一些内容。我也在使用 xolvio/backdoor 包并像这样运行 chimp
chimp --ddp=http://localhost:3000 --mocha --path=tests
这是我的测试代码:
describe('Chimp Mocha', function() {
describe( 'Create a Client', function() {
it( 'should fill in add client form', function() {
browser.setValue('#clientName', 'Test')
.setValue('#clientEmail', 'test@test.com')
.selectByValue('#numberTeamMembers', '25')
.submitForm('#createClient')
});
it( 'should check the collections for new client data', function() {
let getClient = server.execute( function() {
return Clients.findOne({ name: 'Test' });
});
expect( getClient.name ).to.equal( 'Test' );
});
after( function() {
server.execute( function() {
let client = Clients.findOne( { name: 'Test' } );
if ( client ) {
Clients.remove( client._id );
}
});
});
});
});
这是抛出客户未定义的错误
但是,如果我添加
从“/imports/api/clients/clients.js”导入{客户端};
我得到这个错误Error: Cannot find module '/imports/api/clients/clients.js'
我做错了什么?我应该使用黑猩猩吗?任何帮助将不胜感激,因为我发现 Meteor 指南对此不是很清楚!
谢谢
最佳答案
关于testing - 需要有关在 Meteor.js 中使用 Chimp.js/Mocha 进行测试的建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40824956/