Questions tagged [vows]

Asynchronous behaviour driven development for Node.

Asynchronous tests are first class citizens in vows:

// connection-test.js

var vows = require('vows'),
    assert = require('assert');

// Create a Test Suite
vows.describe('connection api').addBatch({
    'when connecting': {
        topic: function () {
            var self = this;
            socket.connect(/* ... */);
            socket.on('connect', function(){
                self.callback(this);
            });
        },
        'a bidirectional channel is open': function (socket) {
            assert.isNotNull(socket);
            socket.send('hello');
        }
    }
}).run(); // Run it

Run the tests:

vows test/connection-test.js --spec

See http://vowsjs.org for documentation and examples.

62 questions
3
votes
3 answers

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…
Fernando Correia
  • 21,803
  • 13
  • 83
  • 116
3
votes
2 answers

Using Vows to test Mongoose models

Fairly new to the whole node.js community, and I'm having trouble with my unit tests on my first app. The problem is they pass, but they never actually run the assertions in the callbacks. As I understand it, mongoose (the library I'm using to…
3
votes
2 answers

Async testing with vows using the http.get library in Node.js

I'm having a doozie of a time trying to get a basic http test to work with vows. I think I've followed the async example from vows http://vowsjs.org/#-writing-asynchronous-tests and substitued the appropriate calls, but I must be missing…
William
  • 6,338
  • 4
  • 32
  • 36
3
votes
2 answers

How to create a data driven test in Node.js

In Node.js unit tests, what is the way to create data driven unit tests? For Example, I've a common function / method, which I want to re-use in multiple unit tests with different sets of data. I tried looking into nodeunit, vows, whiskey, qunit,…
user1460887
  • 245
  • 1
  • 2
  • 10
3
votes
1 answer

I can't run test with "vows test/*" command on windows. How to use it? node.js

I've installed vows as module of my project and I've added the path "node_modules\vows\bin" to my environment path variable of windows vista. note: I've also renamed "node_modules\vows\bin\vows" to vows.exe, because without the extension I get this…
Totty.js
  • 15,563
  • 31
  • 103
  • 175
2
votes
1 answer

In vows, is there a `beforeEach` / `setup` feature?

Vows has an undocumented teardown feature, but I cannot see any way to setup stuff before each test (a.k.a. beforeEach). One would think it would be possible to cheat and use the topic, but a topic is only run once (like teardown), whereas I would…
Thomas Watson
  • 6,507
  • 5
  • 33
  • 43
2
votes
1 answer

What is the best setup to stub functionality when testing node.js apps?

I'm new to Node.js and in general new to testing frameworks / methods in Javascript. So far I'm thinking of giving vows a try. Specifically, I'd like to be able to stub / mock my data sources. I'm considering two situations: Stub out the whole…
gregsilin
  • 287
  • 1
  • 7
2
votes
2 answers

In Vows.js how do you revert back to the original topic after going through an asynchronous callback?

Say I have the following sequence: vows.describe('Example').addBatch({ 'An example' : { topic: new Example(), 'with an async method' : function(example) { example.asyncMethod(this.callback); }, 'will do some…
Chance
  • 11,043
  • 8
  • 61
  • 84
2
votes
1 answer

Vows with Async nested topics - scope problem

I want my vow to have access to outerDocs and innerDocs from my topics but it doesn't. 'ASYNC TOPIC': { topic: function() { aModel.find({}, this.callback); }, 'NESTED ASYNC TOPIC': { topic: function(outerDocs) { …
Roxicus
  • 109
  • 1
  • 7
2
votes
2 answers

Vows.js - Number of args this.callback returns to topic versus vow

From the vows site: "When this.callback is called, it passes on the arguments it received to the test functions, one by one, as if the values were returned by the topic function itself." In other words if we're using the request library to handle…
David EGP
  • 6,799
  • 1
  • 18
  • 7
2
votes
1 answer

REST API testing using vows, tobi and node.js

I am trying to combine the examples here, here to write a vows test for my node.js / express app that: Creates a new user object Checks the response was sane Uses the returned _id to test looking up the newly created user Again uses the _id to test…
g-eorge
  • 3,326
  • 2
  • 16
  • 10
2
votes
1 answer

Reusing MongoDB connection in node

This is the error I get: [Error: db object already connecting, open cannot be called multiple times]. I have a global mongo object in this vows test. mongo = new mongo.Db(config.api.apiTest, new mongo.Server('localhost', 27017, {}), {native_parser:…
Jonathan
  • 8,453
  • 9
  • 51
  • 74
2
votes
2 answers

Testing Bluebird Promises with Nodejs Vows (BDD)

I'm having trouble with how to properly structure a test for my Promise-returning API with Vows, e.g. topic:function() { return myfunc() { /* returns a Bluebird Promise */ } }, 'this should keep its promise':function(topic) { var myfunc =…
eppineda
  • 667
  • 3
  • 19
1
vote
1 answer

unit testing in javascript: how do you mock? - a (hard for me) example

I just rewrote backbone-mongodb to be really compatible with backbone. The original solution had nice vows for testing, and I would like my code to get tested as well, but simply have no idea how to do it. Here is an example, I would like to…
Akasha
  • 2,162
  • 1
  • 29
  • 47
1
vote
2 answers

node.js, testing a mongodb save and load

Perhaps I'm just having trouble figuring out the callbackyness, but I can't figure out a way to test a save and load in node.js. My test is this: vows.describe('Saving').addBatch({ 'Single item can be saved':{ topic:function () { …
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406