Web サービスの次の基本的なテストがあります。
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
しかし、1 つのテストが失敗した場合 (たとえば、予想される 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 コールバック内にある場合にのみ表示されます...