在过去的几个星期里,我在摆弄Node.js和Mocha。碰巧遇到以下问题。Node.js和https发布请求的故事
我尝试测试一个https发布请求,但结果不是我所期望的。 我可以选择测试超时,或通过(当它应该失败)。
您能否给我一些提示/提示可能出错?
var chai = require('chai');
var https = require('https');
var options = {
\t \t hostname: "google.com",
\t \t method: "POST"
};
describe("Connection tests", function(){
\t it("should return 404", function(done){
\t \t https.request(options, function(res) {
\t \t console.log('STATUS: ' + res.statusCode);
\t \t chai.expect(res.statusCode).to.equal(404);
\t \t done(); //if done is here it times out.
\t \t });
//done - if done is here it returns success instead failure.
\t });
});
[敲打键盘上的头加剧]谢谢指出我的白痴! – Gregion