2017-01-28 133 views
0

我正在运行此测试(简化),其失败如预期...但尽管失败,它仍然等待完整的20秒超时。我如何让它立即失败?摩卡/梦魇测试失败,但仍然等待超时

it("should fail before timeout", function (done) { 
     var nightmare = new Nightmare({ show: true }) 
     .goto(url) 
     .evaluate(function() { 
     }) 
     .then(function (result) { 
      // this point is reached, and then the test just waits 
      // 20 seconds before finally failing 
      throw "Fail" 
     }) 
    }) 

回答

0

这是使用mocha的错误。应该调用Error对象来代替抛出,then。 (也用throw new Error("Fail")代替throw "Fail"