Jasmine runner for RingoJS environment

60 views
Skip to first unread message

jc...@migrate.io

unread,
Apr 26, 2013, 8:48:25 PM4/26/13
to rin...@googlegroups.com
I "finished" my Jasmine test runner. It is wired up with my Maven builds so there are a couple hard coded directories in there, but it is working nicely.

require.paths.push( module.resolve( '../../main/webapp/WEB-INF/api' ) );
require.paths.push( module.resolve( '../../main/webapp/WEB-INF/lib' ) );

var fs = require( 'fs' );
var baseDir = fs.workingDirectory() + 'src/test/js';

load( baseDir + '/jasmine/jasmine-1.3.1.js' );
load( baseDir + '/jasmine/jasmine.terminal_reporter.js' );
load( baseDir + '/jasmine/jasmine.junit_reporter.js' );

fs.listTree( baseDir ).forEach( function ( file ) {
    var f = baseDir + '/' + file;
    if ( fs.isFile( f ) && /.+Spec\.js$/g.test( file ) ) load( f );
} );


var jasmineEnv = jasmine.getEnv();

var reporter = new jasmine.TerminalReporter( {
    verbosity : 3,
    color : true
} );
jasmineEnv.addReporter( reporter );

jasmineEnv.addReporter(
    new jasmine.JUnitXmlReporter( fs.workingDirectory() + 'target/surefire-reports/' )
);

var done = function () {
    print( 'Calling done' );
    if ( reporter.hasErrors() ) require( 'system' ).exit( -1 );
};

var oldCallback = jasmineEnv.currentRunner().finishCallback;

jasmineEnv.currentRunner().finishCallback = function () {
    oldCallback.apply( this, arguments );
    done();
};

jasmineEnv.execute();

I would like to do what Karma does and watch for modified files and re-run all of the tests when this happens. I have used load(path) to load my tests. If I change a test and save it, I can detect that change. But how do I "unload" my previously loaded test files and load in new ones?

James Cook

unread,
May 8, 2013, 12:48:32 PM5/8/13
to rin...@googlegroups.com
Anyone have any ideas on my prior question regarding the 'unloading' of a javascript file?

Basically, I use the load( url ) command, but I need a way to tell the engine to unload( url ), or a way to clear it of any loaded scripts.

Does this exist?
Reply all
Reply to author
Forward
0 new messages