Pergunta

I'm trying to setup a new node.js project (something with express and stuff). But before I get anything, I want to setup testing. Since I'm completely new to TDD with node.js, I'm having trouble setting this up.

Can some kind soul tell me why is this little test passing? It doesn't matter if I put the correct URL, whatever. It just passes.

var assert=require('assert');
var Browser = require("zombie");
var browser = new Browser();
describe('Home page', function () {
   describe ('title', function () {
        it ('should have a title', function () {
            browser.visit ("http://no-such-site.com/").
            then(function (){
                assert.equal(browser.text("title"), "Whatever goes here");
            }).
            fail(function(err) {
                console.log("Failed with error: ", error);
            });
        });
   });
});
Foi útil?

Solução

You forgot the done parameter to your it function.

var assert=require('assert');
var Browser = require("zombie");
var browser = new Browser();
describe('Home page', function () {
  describe ('title', function () {
    it ('should have a title', function (done) {
        browser.visit ("http://no-such-site.com/").
        then(function (){
            assert.equal(browser.text("title"), "Whatever goes here");
            done(); 
        }).
        fail(function(err) {
            console.log("Failed with error: ", error);
            done(err);
        });
    });
  });
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top