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

Commit 088a581

Browse files
eddiemongejuliemr
authored andcommitted
feat(runner): add a callback for when the tests are done
Add an onCleanUp callback to be able to hook into when all the tests have been run. Conflicts: referenceConf.js
1 parent 9fab249 commit 088a581

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/runner.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,28 @@ var addConfig = function(additionalConfig) {
8484
var cleanUp = function(runner) {
8585
var passed = runner.results().failedCount == 0;
8686
var exitCode = passed ? 0 : 1;
87+
var exit = function(exitCode) {
88+
if (typeof config.onCleanUp === 'function') {
89+
config.onCleanUp(exitCode);
90+
}
91+
process.exit(exitCode);
92+
};
8793
if (sauceAccount) {
8894
sauceAccount.updateJob(sessionId, {'passed': passed}, function(err) {
8995
if (err) {
9096
throw new Error(
9197
"Error updating Sauce pass/fail status: " + util.inspect(err)
9298
);
9399
}
94-
process.exit(exitCode);
100+
exit(exitCode);
95101
});
96102
} else if (server) {
97103
util.puts('Shutting down selenium standalone server.');
98104
server.stop().then(function() {
99-
process.exit(exitCode);
105+
exit(exitCode);
100106
});
101107
} else {
102-
process.exit(exitCode);
108+
exit(exitCode);
103109
}
104110
};
105111

referenceConf.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,20 @@ exports.config = {
120120
includeStackTrace: true,
121121
// Default time to wait in ms before a test fails.
122122
defaultTimeoutInterval: 30000
123-
}
123+
},
124124

125125
// ----- Options to be passed to mocha -----
126126
//
127127
// See the full list at http://visionmedia.github.io/mocha/
128128
mochaOpts: {
129129
ui: 'bdd',
130130
reporter: 'list'
131-
}
131+
},
132+
133+
// ----- The cleanup step -----
134+
//
135+
// A callback function called once the tests have finished running and
136+
// the webdriver instance has been shut down. It is passed the exit code
137+
// (0 if the tests passed or 1 if not).
138+
onCleanUp: function() {}
132139
};

0 commit comments

Comments
 (0)