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
0
votes
1 answer

When coding some tests for a grunt plugin, how to alter dynamically the configuration used by grunt.tasks(...)

I writing a grunt plugin. In my tests written with vows I want to alter some config object defined in my gruntfile before calling grunt.tasks(["my_task"], {}, function(){ // do something} ) The goal is to execute some task I have defined in my…
J2AN
  • 29
  • 7
0
votes
1 answer

How to debug hanging api-easy (or vows) tests?

I'm using api-easy to implement end-to-end tests for a REST api. The library itself is quite nice, but debugging failing tests is harder than I had expected, but maybe I'm not using the right approach. I had this problem: The test sent a "GET" to a…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
0
votes
1 answer

How can I make vows wait 60s for a callback to happen

I've written some code that connects to an FTP server and lists a very long directory. It can take 40+ seconds to get a response. I've written some code to start testing this but I get Errored >> callback not fired. Is there a way to instruct Vows…
marc2112
  • 153
  • 1
  • 7
0
votes
1 answer

using require.config in a vows file

I'm trying to setup require like it's set in the index.html document so that there aren't any problems... for some reason vowsjs is complaining about require.config... maybe it's using an old requirejs version? vows…
obimod
  • 797
  • 10
  • 26
0
votes
1 answer

How can this function be tested with vows?

How can the following function, intended to add routes to express.js app based on an object hierarchy, be tested using vows.js cleanly without breaking vows' separation of the topic and the vow? var addRoutes = function(routeObject, app, path) { …
alexbirkett
  • 2,604
  • 2
  • 26
  • 30
0
votes
1 answer

grunt.js throws error when using grunt-vows

I'm using grunt-vows (https://github.com/CMTegner/grunt-vows) in the following gruntfile: module.exports = function(grunt) { // Project configuration. grunt.loadNpmTasks("grunt-vows"); grunt.initConfig({ vows: { all: { …
danwoods
  • 4,889
  • 11
  • 62
  • 90
0
votes
1 answer

What is wrong with my usage of vows.js sub-topics?

For some reason, I can't seem to get vows.js sub-topics working in my real test-suite, but they work fine in a example file... can you spot my problem? This works: vows.describe('An Education in Vows').addBatch({ 'when I write an asynchronous…
bhazzard
  • 361
  • 2
  • 10
0
votes
2 answers

Vows JS Testing for Undefined

I'm trying to use vows js to create unit tests. I am having trouble when the "topic" is `undefined'. Please see the example below: var vows = require('vows'), assert = require('assert'); function giveMeUndefined(){ return…
arb
  • 7,753
  • 7
  • 31
  • 66
0
votes
1 answer

How to test HTTP server in flatiron

I am using the simple as possible web server straight off of the flatiron website and wanted to experiment testing it with vows. I can get the tests to pass but the test never exits. I assume this is because I the flatiron server never shuts down.…
rancidfishbreath
  • 3,944
  • 2
  • 30
  • 44
0
votes
2 answers

Setting PATH on Makefile - Node.js

I want to use api-easy to test my REST app. I have it in the dependences inside the package.json, so when I run npm install it's installed in ./node_modules I'm trying to add the api-easy to the path like this question. Since I'm using a Makefile I…
Federico Lenzi
  • 1,632
  • 4
  • 18
  • 34
0
votes
1 answer

vows unit test got executed multiple times when the included app server uses nodejs cluster.fork

My app server uses node.js cluster API cluster.fork() to fork multiple child processes. This works fine. However, when I try to use vows for unit test, the test also got run multiple times because of the call to cluster.fork() inside my app server;…
haijin
  • 938
  • 2
  • 11
  • 17
0
votes
1 answer

Strange error when I use vows in node.js

I'm trying to start my node.js project with BDD using vows. Then I got this strange error. I was trying to write a small route testing for express with vows and here is my original code, node_server.prototype.mainpage = function(callback) { …
Brandon Gao
  • 623
  • 5
  • 9
0
votes
1 answer

Configuring $.ajax with backbone on node for testing with vows

(Edited to greatly simplify) On node I have the following server.js file. var Backbone = require('backbone'); var Tweet = Backbone.Model.extend({}); var Tweets = Backbone.Collection.extend({ model : Tweet, url: function () { return…
DanielEli
  • 3,393
  • 5
  • 29
  • 36
0
votes
1 answer

I'm trying to wrap my head around variable scoping in Node.js and Vows

As an exercise in TDD in Node.js, I'm trying to implement a very simple "database" that stores things as flat files. Here's the very beginning of the DB module code: var fs = require( 'fs' ); exports.create = function( path, readycallback ) { …
Curtis
  • 3,931
  • 1
  • 19
  • 26
0
votes
1 answer

Nodejs: Unable to get response body when working with vows and nodejs http module

I am playing around vows and nodejs. var vows = require('vows'); var http = require('http'); var suite = vows.describe('testing'); var host = 'www.google.com', port = '80', path = '/', method = 'GET'; suite.addBatch({ 'A context': { …