gpt4 book ai didi

javascript - Jasmine Node 中未显示失败的测试

转载 作者:行者123 更新时间:2023-11-29 22:15:19 24 4
gpt4 key购买 nike

我对网络服务进行了以下基本测试:

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 的 repo (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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com