fixed #294 - Automatically fail test on any runtime error or timeout
Showing
3 changed files
with
19 additions
and
18 deletions
... | @@ -47,6 +47,7 @@ The whole [CapserJS test suite](https://github.com/n1k0/casperjs/tree/master/tes | ... | @@ -47,6 +47,7 @@ The whole [CapserJS test suite](https://github.com/n1k0/casperjs/tree/master/tes |
47 | 47 | ||
48 | ### Bugfixes & enhancements | 48 | ### Bugfixes & enhancements |
49 | 49 | ||
50 | - fixed [#294](https://github.com/n1k0/casperjs/issues/294) - Automatically fail test on any runtime error or timeout | ||
50 | - fixed [#281](https://github.com/n1k0/casperjs/issues/281) - `Casper.evaluate()` should take an array as context not object | 51 | - fixed [#281](https://github.com/n1k0/casperjs/issues/281) - `Casper.evaluate()` should take an array as context not object |
51 | - fixed [#266](https://github.com/n1k0/casperjs/issues/266) - Fix `tester` module and its self tests | 52 | - fixed [#266](https://github.com/n1k0/casperjs/issues/266) - Fix `tester` module and its self tests |
52 | - fixed [#268](https://github.com/n1k0/casperjs/issues/266) - Wrong message on step timeout | 53 | - fixed [#268](https://github.com/n1k0/casperjs/issues/266) - Wrong message on step timeout | ... | ... |
... | @@ -121,6 +121,23 @@ var Tester = function Tester(casper, options) { | ... | @@ -121,6 +121,23 @@ var Tester = function Tester(casper, options) { |
121 | } | 121 | } |
122 | } | 122 | } |
123 | }); | 123 | }); |
124 | |||
125 | // casper events | ||
126 | this.casper.on('error', function onCasperError(msg, backtrace) { | ||
127 | var line = 0; | ||
128 | if (!utils.isString(msg) && msg.indexOf(this.SKIP_MESSAGE) === -1) { | ||
129 | try { | ||
130 | line = backtrace[0].line; | ||
131 | } catch (e) {} | ||
132 | } | ||
133 | this.test.uncaughtError(msg, this.test.currentTestFile, line); | ||
134 | this.test.done(); | ||
135 | }); | ||
136 | |||
137 | this.casper.on('step.error', function onStepError(e) { | ||
138 | this.test.uncaughtError(e, this.test.currentTestFile); | ||
139 | this.test.done(); | ||
140 | }); | ||
124 | }; | 141 | }; |
125 | 142 | ||
126 | // Tester class is an EventEmitter | 143 | // Tester class is an EventEmitter |
... | @@ -672,23 +689,6 @@ Tester.prototype.configure = function configure() { | ... | @@ -672,23 +689,6 @@ Tester.prototype.configure = function configure() { |
672 | this.casper.options.onWaitTimeout = function test_onWaitTimeout(timeout) { | 689 | this.casper.options.onWaitTimeout = function test_onWaitTimeout(timeout) { |
673 | tester.fail(f("Wait timeout occured (%dms)", timeout)); | 690 | tester.fail(f("Wait timeout occured (%dms)", timeout)); |
674 | }; | 691 | }; |
675 | |||
676 | // events | ||
677 | this.casper.on('error', function(msg, backtrace) { | ||
678 | if (!utils.isString(msg) && msg.indexOf(this.SKIP_MESSAGE) === -1) { | ||
679 | var line = 0; | ||
680 | try { | ||
681 | line = backtrace[0].line; | ||
682 | } catch (e) {} | ||
683 | tester.uncaughtError(msg, tester.currentTestFile, line); | ||
684 | } | ||
685 | tester.done(); | ||
686 | }); | ||
687 | |||
688 | this.casper.on('step.error', function onStepError(e) { | ||
689 | tester.uncaughtError(e, tester.currentTestFile); | ||
690 | tester.done(); | ||
691 | }); | ||
692 | }; | 692 | }; |
693 | 693 | ||
694 | /** | 694 | /** | ... | ... |
-
Please register or sign in to post a comment