As I was suggested on chat here, I am using Node-supervisor - a supervisor for node apps, to which I say what to watch and restart the app automatically when it changes.
How to test express app headless with Mocha and Zombie.js
Question
I am trying to run some Mocha/Zombie.js tests on my new node.js (express) app.
Now I want to do it without having to restart the node app.
Now, I have a working test, something like this:
var assert=require('assert')
, Browser = require("zombie")
;
var browser = new Browser();
browser.site = "http://domain.com";
browser.silent = false;
describe('Home page', function(){
describe ('Page title', function(){
it('should open a home page', function(done){
browser.visit('/').
then(function(done){
assert.equal(browser.text("title"), "My page title");
done();
}).fail(function(err){
done(err);
});
});
});
});
So, when the test fails, I change the page title, reload the app and then re-run the test so it passes.
I know I can do something like:
var server = require('../server');
var browser = new Browser();
I just don't know how, and I can't see from Mocha and Zombie example pages.
How do I tell the browser.visit to visit the server and not the real deployed web page?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow