vowsjs / vows

Asynchronous BDD & continuous testing for node.js
http://vowsjs.org
Apache License 2.0
1.56k stars 165 forks source link

Output data from Vows test #316

Closed IonicaBizau closed 6 years ago

IonicaBizau commented 10 years ago

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?


I already tried the workaround from #70 that didn't work for me...

I also asked this StackOverflow question.

indexzero commented 10 years ago

The short answer is that because of --isolate we suppress the stdout output. Try using console.error for now, but we should be doing something better here.

IonicaBizau commented 10 years ago

Yes, I followed the workaround from this answer.

IonicaBizau commented 9 years ago

Is there any progress on this?

evanp commented 6 years ago

So, this should probably be OK in 1.x.

I'm going to close this for now.