Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat(runner): add a callback for when the tests are done
Browse files Browse the repository at this point in the history
Add an onCleanUp callback to be able to hook into when all the tests
have been run.

Conflicts:
	referenceConf.js
  • Loading branch information
eddiemonge authored and juliemr committed Jan 22, 2014
1 parent 9fab249 commit 088a581
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,28 @@ var addConfig = function(additionalConfig) {
var cleanUp = function(runner) {
var passed = runner.results().failedCount == 0;
var exitCode = passed ? 0 : 1;
var exit = function(exitCode) {
if (typeof config.onCleanUp === 'function') {
config.onCleanUp(exitCode);
}
process.exit(exitCode);
};
if (sauceAccount) {
sauceAccount.updateJob(sessionId, {'passed': passed}, function(err) {
if (err) {
throw new Error(
"Error updating Sauce pass/fail status: " + util.inspect(err)
);
}
process.exit(exitCode);
exit(exitCode);
});
} else if (server) {
util.puts('Shutting down selenium standalone server.');
server.stop().then(function() {
process.exit(exitCode);
exit(exitCode);
});
} else {
process.exit(exitCode);
exit(exitCode);
}
};

Expand Down
11 changes: 9 additions & 2 deletions referenceConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,20 @@ exports.config = {
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 30000
}
},

// ----- Options to be passed to mocha -----
//
// See the full list at http://visionmedia.github.io/mocha/
mochaOpts: {
ui: 'bdd',
reporter: 'list'
}
},

// ----- The cleanup step -----
//
// A callback function called once the tests have finished running and
// the webdriver instance has been shut down. It is passed the exit code
// (0 if the tests passed or 1 if not).
onCleanUp: function() {}
};

0 comments on commit 088a581

Please sign in to comment.