堆
使用流星客户端集成测试摩卡+速度(0.5.3)。 让我们假设我已经安装包自动发布 。
问题
如果MongoDB的文档从服务器插入时,客户端摩卡测试不会等待订阅同步,导致断言失败。
代码示例
服务器端Accounts.onCreateUser
钩:
Accounts.onCreateUser(function (options, user) {
Profiles.insert({
'userId': user._id,
'profileName': options.username
});
return user;
});
客户端摩卡测试:
beforeEach(function (done) {
Accounts.createUser({
'username' : 'cucumber',
'email' : 'cucumber@cucumber.com',
'password' : 'cucumber' //encrypted automatically
});
Meteor.loginWithPassword('cucumber@cucumber.com', 'cucumber');
Meteor.flush();
done();
});
describe("Profile", function () {
it("is created already when user sign up", function(){
chai.assert.equal(Profiles.find({}).count(), 1);
});
});
题
我如何才能让摩卡等待我的个人资料文件进行的方式向客户避免了摩卡超时(从服务器创建的)?