繁体   English   中英

QUnit测试挂起

[英]QUnit test hangs

我是qunit和JS测试的新手。 被测试的代码执行了动画(slideDown),该动画必须在我声明之前完成。 看起来很简单,但是我似乎无法正常工作。

asyncTest('my test', function() {
  setTimeout(function() {
    // assert something here
    start();
  }, 1000);
});

永远不会调用该回调,并且测试将挂起。

我也尝试了其他各种方法。 例如:

test('my test', function() {
  expect(1);
  stop(1000);
  // assert something here
  start();
});

我可以看到startstop都被调用了,并且test调用结束了,但是仍然挂起。

万一重要,这是我的设置:

setup: function() {
  this.server = sinon.fakeServer.create();
  this.server.respondWith([200, { 'Content-Type': 'text/html' }, new_items()]);
  // invoke the actual system under test
  this.server.respond();
}

听起来像锡诺河假计时器(http://sinonjs.org/docs/#clock)。 设置超时后调用this.clock.tick(1001)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM