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) { ...@@ -129,7 +129,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
129 } else if (isArray(this._events[type])) { 129 } else if (isArray(this._events[type])) {
130 130
131 // If we've already got an array, just append. 131 // If we've already got an array, just append.
132 this._events[type].push(listener); 132 this._events[type]['fail' === type ? 'unshift' : 'push'](listener);
133 133
134 // Check for listener leak 134 // Check for listener leak
135 if (!this._events[type].warned) { 135 if (!this._events[type].warned) {
...@@ -151,7 +151,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { ...@@ -151,7 +151,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
151 } 151 }
152 } else { 152 } else {
153 // Adding the second element, need to change to array. 153 // Adding the second element, need to change to array.
154 this._events[type] = [this._events[type], listener]; 154 this._events[type] = 'fail' === type ? [listener, this._events[type]] : [this._events[type], listener];
155 } 155 }
156 156
157 return this; 157 return this;
......
1 /* global casper */
2
3 casper.test.on('fail', function doSomething() {
4 'use strict';
5 casper.echo('fail event fired!');
6 });
7 casper.test.begin('hook', 0, function(t) {
8 'use strict';
9 t.done();
10 });
...@@ -391,6 +391,7 @@ class TestCommandOutputTest(CasperExecTestBase): ...@@ -391,6 +391,7 @@ class TestCommandOutputTest(CasperExecTestBase):
391 self.assertCommandOutputContains('test %s --fail-fast' % folder_path, [ 391 self.assertCommandOutputContains('test %s --fail-fast' % folder_path, [
392 '# test 1', 392 '# test 1',
393 '# test 2', 393 '# test 2',
394 'fail event fired!',
394 '--fail-fast: aborted all remaining tests', 395 '--fail-fast: aborted all remaining tests',
395 'FAIL 2 tests executed', 396 'FAIL 2 tests executed',
396 '1 passed', 397 '1 passed',
......