Created
April 5, 2012 09:32
-
-
Save stas/2309500 to your computer and use it in GitHub Desktop.
Phantom Nodify Mocha Runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app_libs = '/relative/path/to/your/other/js/libs/'; | |
var nodify = '..' + app_libs + '/phantomjs-nodify/nodify.js'; | |
phantom.injectJs(nodify); | |
nodify.run( | |
function() { | |
var fs = require('fs'); | |
require.paths.push(fs.workingDirectory + app_libs); | |
/** | |
* Load common libs | |
*/ | |
console.log('~~~~~~~~~~~~~~~~~~~~~~~~'); | |
require('jquery-1.7.1.min.js'); | |
console.log("jQuery version: %s", jQuery().jquery); | |
require('ember-0.9.5.min.js'); | |
console.log("Ember.js version: %s", Ember.VERSION); | |
require('ember-routing.js'); | |
// Add require.js support | |
var rjs = require('requirejs') | |
global.requirejs = rjs.requirejs; | |
global.define = rjs.define; | |
global.requirejs_modules = { | |
jquery: jQuery, | |
ember: Ember | |
}; | |
// Add global expect support and load chai spies. | |
global.chai = require('chai/chai.js'); | |
global.expect = chai.expect; | |
// Make sure you commented lines 283-292 in sinnon.js before | |
global.sinon = require('sinon/sinon'); | |
global.sinon.spy = require('sinon/sinon/spy'); | |
console.log(process.versions); | |
console.log('~~~~~~~~~~~~~~~~~~~~~~~~'); | |
require('mocha'); | |
phantom.exit(0); | |
} | |
); | |
// Run like this | |
// ~$ phantomjs <path_to_this_file> -u bdd -R list <path/to/js/tests> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment