2017-01-28 179 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"