繁体   English   中英

从Vows测试输出数据

[英]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.logprocess.stdout.write(...) 两者都无法正常工作。

我使用npm test ,在我的package.json文件中有vows --spec --isolate

那么,使用Vows测试时如何输出数据?

您应该能够使用stderr将其输出到誓言进度所在的位置:

process.stderr.write("something\n");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM