我正在尝试教自己与流星进行测试,但是在线上有很多冲突和过时的信息,很难解决我需要做的事情。
我目前的情况是我使用了最新的流星版本(以及Imports文件夹结构)。
我已经在全球安装了黑猩猩,并创建了A/Tests目录。
我的第一个测试是使用黑猩猩/摩卡咖啡填充表格,并尝试将某些内容插入数据库。我还使用Xolvio/Backdoor软件包,然后像So
一样运行黑猩猩 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 );
}
});
});
});
});
这引发了一个错误,客户端是未定义的
但是,如果我添加
import { Clients } from '/imports/api/clients/clients.js';
我得到此错误 Error: Cannot find module '/imports/api/clients/clients.js'
我在做什么错?我应该使用黑猩猩吗?任何帮助真的将不胜感激,因为我发现流星指南对此感到非常清楚!
谢谢
您需要使用这样的需要:
require('/imports/api/clients/clients').Clients
请参阅此处的示例。