Seb*_*itz 5 continuous-integration unit-testing mocha.js node.js
我有适用于当前应用程序的测试套件。
有时我会引入错误,并导致引发未捕获的异常。
手动运行单元测试时,我可以看到错误。但是,当我将其与我们的CI系统集成时,该过程仍然返回0,就好像一切正常。
由于存在积极的退出代码,因此我们无法检测到错误。我究竟做错了什么?
感谢nodeJS域,我终于解决了这个问题:
这是我的 test/server.coffee,我在其中设置测试:
d = require("domain").create()
# set up error handling to exit with error code on uncaught exceptions
d.on "error", (err) ->
console.log "Uncaught Exception:", err.message
console.log err.stack
process.exit(1)
before (done) ->
d.run ->
# bootstrap application
done()
Run Code Online (Sandbox Code Playgroud)
这会捕获所有错误、打印跟踪并以退出状态 1 退出。
| 归档时间: |
|
| 查看次数: |
1360 次 |
| 最近记录: |