meteorjs:laika客户端和服务器测试超时

时间:2013-06-12 00:46:23

标签: tdd meteor laika

我正在为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)

2 个答案:

答案 0 :(得分:2)

我和laika有类似的问题,节点为0.10.10。我切换到节点0.10.4,超时消失了。

我不知道你的情况是否与我的情况完全相同,但值得一试。

答案 1 :(得分:0)

可能是mongodb是你的瓶颈。

以这种方式启动mongodb:

  

mongod --smallfiles --noprealloc --nojournal

我能够在默认的5000ms超时下运行laika测试。 但是,如果您在慢速计算机上运行此功能,则可以简单地更改laika默认超时:

  

laika -t 10000

根据我的经验,它与nodejs的版本无关。但是,在mac os x版本中存在一些问题,即在空闲时将cpu设置在30%到60%左右。