Commit b62c37d9 b62c37d9932b5d350519eade6f58aa7dedfcead4 by Nicolas Perriault

Merge pull request #923 from tdd/master

Fixed #687 casper.test fail event no longer fired using the --fail-fast option
2 parents c509d5ea 48becb30
......@@ -129,7 +129,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
} else if (isArray(this._events[type])) {
// If we've already got an array, just append.
this._events[type].push(listener);
this._events[type]['fail' === type ? 'unshift' : 'push'](listener);
// Check for listener leak
if (!this._events[type].warned) {
......@@ -151,7 +151,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
}
} else {
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
this._events[type] = 'fail' === type ? [listener, this._events[type]] : [this._events[type], listener];
}
return this;
......
/* global casper */
casper.test.on('fail', function doSomething() {
'use strict';
casper.echo('fail event fired!');
});
casper.test.begin('hook', 0, function(t) {
'use strict';
t.done();
});
......@@ -391,6 +391,7 @@ class TestCommandOutputTest(CasperExecTestBase):
self.assertCommandOutputContains('test %s --fail-fast' % folder_path, [
'# test 1',
'# test 2',
'fail event fired!',
'--fail-fast: aborted all remaining tests',
'FAIL 2 tests executed',
'1 passed',
......