I am using Mocha programatically as described here:
https://github.com/visionmedia/mocha/wiki/Using-mocha-programmatically
Very similarly to how the examples are written:
test-runner.js:
var Mocha = require('mocha');
var mocha = new Mocha();
mocha.addFile('spec.js');
mocha.run(function() {});
Inside the test spec, I am spinning up a headless browser to run the test on a specific url:
spec.js:
var Browser = new Browser();
browser.visit(url, function(){});
Is there a way to pass the desired url from test-runner.js to spec.js?
In your spec file, you can require a module that contains the configurations for those tests:
This config module could also be set from the initial mocha tests (e.g.):
Check out this related SO regarding node modules being singletons.