在過去的幾個星期裏,我在擺弄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