我正在试用meteor的laika测试框架。来自homepage的第二个示例使用了observe(),我认为它没有正确观察。
suite('Posts', function() {
test('using both client and server', function(done, server, client) {
server.eval(function() {
Posts.find().observe({
added: addedNewPost
});
function addedNewPost(post) {
emit('post', post);
}
}).once('post', function(post) {
assert.equal(post.title, 'hello title');
done();
});
client.eval(function() {
Posts.insert({title: 'hello title'});
});
});
});我总是被暂停。增加超时时间无济于事。我不知道我做错了什么,也不知道如何获得更详细的输出。在测试中使用对console.log()的调用什么也得不到。
输出:
1) Posts using both client and the server:
Error: timeout of 2000ms exceeded
at null.<anonymous> (/usr/local/share/npm/lib/node_modules/laika/node_modules/mocha/lib/runnable.js:165:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)发布于 2013-06-15 21:33:29
我在laika上遇到过类似的问题,node为0.10.10。我切换到节点0.10.4,超时消失了。
我不知道你的情况和我的情况是否完全一样,但值得一试。
发布于 2014-06-08 04:48:11
mongodb可能是您的瓶颈。
这样启动mongodb:
神灵--小文件--noprealloc -nojournal
我能够在默认的5000ms超时时间下运行laika测试。然而,如果你在一台速度很慢的计算机上运行,你可以简单地更改laika的默认超时:
laika -t 10000
根据我的经验,这与nodejs的版本无关。然而,在mac os x版本中有一些问题,在空闲状态下将cpu设置为大约30%的60%+。
https://stackoverflow.com/questions/17056068
复制相似问题