我对网络服务进行了以下基本测试:
var request = require('http'),
url = 'http://localhost:1337/';
describe('webservice', function() {
it('should respond to /ping', function(done) {
request.get(url + 'ping', function(res) {
expect(res.statusCode).toBe(200);
res.on('data', function(body) {
var json = JSON.parse(body);
expect(json.message).toBe("Hi, I'm alive");
expect(json.date).toBeDefined();
done();
});
});
});
});
这似乎工作正常:
$ jasmine-node --verbose tests/ping/
webservice
should respond to /ping
Finished in 0.032 seconds
1 test, 3 assertions, 0 failures
但是,如果我使一个测试失败(例如,更改预期的 json 消息),我会收到以下错误:
$ jasmine-node --verbose --coffee tests/ping/
StreamWrap: Aborting due to unwrap failure at ../src/stream_wrap.cc:125
Aborted (core dumped)
知道我做错了什么吗?
(此外,我的 js 中出现的任何错误,测试都会默默失败,没有任何线索表明发生了什么,js 错误就消失了)
更新:仅当失败的测试位于 request.get 回调内部时才会出现错误...
最佳答案
Herman 是对的,我在 github 的存储库 ( https://github.com/mhevery/jasmine-node ) 中提交了一个问题,并与 @tebriel 一起发现这是 v0.10.0 的问题
这是票:https://github.com/mhevery/jasmine-node/issues/211
在 0.9.9 版本之前都可以正常工作,唯一失败的版本似乎是 v0.10.0
还有一个提交修复了它,因此我们预计它会在下一个版本中修复
--
编辑:我可以确认 Node v0.10.1 已解决此问题
关于javascript - 失败的测试未显示在 jasmine-node 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15469980/