I have a test file like below:
// 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);
Somewhere this crashes, and I want to output some data. I tried to do console.log
and process.stdout.write(...)
. Both don't work as I expected.
I run the test using npm test
, having vows --spec --isolate
in my package.json
file.
So, how can I output data when using Vows tests?
You should be able to output to the same place as the vows progress using stderr:
process.stderr.write("something\n");