我正在試着教自己測試流星,但是在線上有這麼多衝突和過時的信息,我很難搞清楚我需要做什麼。需要關於在Meteor.js中使用Chimp.js/Mocha進行測試的建議
我目前的情況是,我有一個應用程序使用最新的Meteor版本(和進口文件夾結構)。
我安裝了全局chimp並創建了一個/ tests目錄。
我的第一個測試是使用黑猩猩/摩卡填寫表格並嘗試插入一些東西到數據庫。我還使用了xolvio /後門程序包和像這樣
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', '[email protected]')
.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'
我做錯了什麼?我應該使用黑猩猩嗎?任何幫助真的會被讚賞,因爲我沒有找到流星指南非常明確這一點!
感謝
嘿,感謝您的幫助 - 對黑猩猩也很好! – Sean