Search code examples
node.jsvows

How to use a different reporter with Vows' run() method?


Vows has a run() method that runs the test under node, without using the vows command.

At https://github.com/cloudhead/vows/blob/master/lib/vows/suite.js we can see that this method takes an option parameter which allows to specify a reporter other than the default:

this.run = function (options, callback) {
    var that = this, start;

    options = options || {};

    for (var k in options) { this.options[k] = options[k] }

    this.matcher  = this.options.matcher  || this.matcher;
    this.reporter = this.options.reporter || this.reporter;

What value is supposed to be passed in the options object to select a different reporter, for instance the spec reporter?


Solution

  • Try:

    var spec = require("vows/lib/vows/reporters/spec");
    // ...
    vows.describe("My Tests").addBatch({ /* some batch */ }).run({reporter:spec});
    

    This was the simplest way that worked for me.