Commit 1f1d0872 1f1d087229c603131cf34e5fcbe2228735b834d4 by Nicolas Perriault

fixed #294 - Automatically fail test on any runtime error or timeout

1 parent 26ee5cf5
......@@ -47,6 +47,7 @@ The whole [CapserJS test suite](https://github.com/n1k0/casperjs/tree/master/tes
### Bugfixes & enhancements
- fixed [#294](https://github.com/n1k0/casperjs/issues/294) - Automatically fail test on any runtime error or timeout
- fixed [#281](https://github.com/n1k0/casperjs/issues/281) - `Casper.evaluate()` should take an array as context not object
- fixed [#266](https://github.com/n1k0/casperjs/issues/266) - Fix `tester` module and its self tests
- fixed [#268](https://github.com/n1k0/casperjs/issues/266) - Wrong message on step timeout
......
Subproject commit 9ddb0c6eb79d0c6b176d7bf41187e06b2e8fc708
Subproject commit ea64d9917aaf7268a86b9fad010203615a29b9e0
......
......@@ -121,6 +121,23 @@ var Tester = function Tester(casper, options) {
}
}
});
// casper events
this.casper.on('error', function onCasperError(msg, backtrace) {
var line = 0;
if (!utils.isString(msg) && msg.indexOf(this.SKIP_MESSAGE) === -1) {
try {
line = backtrace[0].line;
} catch (e) {}
}
this.test.uncaughtError(msg, this.test.currentTestFile, line);
this.test.done();
});
this.casper.on('step.error', function onStepError(e) {
this.test.uncaughtError(e, this.test.currentTestFile);
this.test.done();
});
};
// Tester class is an EventEmitter
......@@ -672,23 +689,6 @@ Tester.prototype.configure = function configure() {
this.casper.options.onWaitTimeout = function test_onWaitTimeout(timeout) {
tester.fail(f("Wait timeout occured (%dms)", timeout));
};
// events
this.casper.on('error', function(msg, backtrace) {
if (!utils.isString(msg) && msg.indexOf(this.SKIP_MESSAGE) === -1) {
var line = 0;
try {
line = backtrace[0].line;
} catch (e) {}
tester.uncaughtError(msg, tester.currentTestFile, line);
}
tester.done();
});
this.casper.on('step.error', function onStepError(e) {
tester.uncaughtError(e, tester.currentTestFile);
tester.done();
});
};
/**
......