[英]Output data from Vows test
我有一個如下的測試文件:
// Dependencies
var Vows = require("vows")
, Request = require("request")
, Assert = require("assert")
, MyLib = require("../../lib/")
;
// Globals
var sServer = new MyLib({
root: __dirname + "/../fixtures"
})
, suite = Vows.describe("...")
, TEST_PORT = 8080
, TEST_SERVER = "http://localhost:" + TEST_PORT
, server
, callback
;
suite.addBatch({
"once an http server is listening with a callback": {
topic: function() {
server = require("http").createServer(function (req, res) {
// output some data
sServer.serve(req, res);
}).listen(TEST_PORT, this.callback)
},
"should be listening": function() {
Assert.isTrue(true);
}
}
}).addBatch({
"streaming a 404 page": {
topic: function() {
request.get(TEST_SERVER + "/not-found", this.callback);
},
"should respond with 404": function(error, response, body) {
Assert.equal(response.statusCode, 404);
},
"should respond with the streamed content": function(error, response, body) {
Assert.equal(body, "Custom 404 Stream.");
}
}
}).export(module);
這在某個地方崩潰了,我想輸出一些數據。 我試圖做console.log
和process.stdout.write(...)
兩者都無法正常工作。
我使用npm test
,在我的package.json
文件中有vows --spec --isolate
。
那么,使用Vows測試時如何輸出數據?
您應該能夠使用stderr將其輸出到誓言進度所在的位置:
process.stderr.write("something\n");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.