tests: Move casper.page.onError setup outside casper.start().

This has no functional impact, it's just for clarity.

(imported from commit 2ec1948929df120a3a410324412912ec062b8500)
This commit is contained in:
Tim Abbott 2013-03-06 10:42:13 -05:00
parent e63033f8b1
commit 0c62dcc9f6
1 changed files with 15 additions and 17 deletions

View File

@ -1,8 +1,21 @@
// Set default viewport size to something reasonable
casper.page.viewportSize = {width: 1280, height: 768 };
// Fail if we get a JavaScript error in the page's context.
// Based on the example at http://phantomjs.org/release-1.5.html
//
// casper.on('error') doesn't work (it never gets called) so we
// set this at the PhantomJS level.
casper.page.onError = function (msg, trace) {
casper.test.error(msg);
casper.echo('Traceback:');
trace.forEach(function (item) {
casper.echo(' ' + item.file + ':' + item.line);
});
casper.exit(1);
};
// Capture screens from all fails
// Capture screens from all failures
var casper_failure_count = 1;
casper.test.on('fail', function failure() {
if (casper_failure_count <= 10) {
@ -16,22 +29,7 @@ var common = (function () {
var exports = {};
exports.log_in = function () {
casper.start('http://localhost:9981/accounts/login', function () {
// Fail if we get a JavaScript error in the page's context.
// Based on the example at http://phantomjs.org/release-1.5.html
//
// casper.on('error') doesn't work (it never gets called) so we
// set this at the PhantomJS level. We do it inside 'start' so
// that we know we have a page object.
casper.page.onError = function (msg, trace) {
casper.test.error(msg);
casper.echo('Traceback:');
trace.forEach(function (item) {
casper.echo(' ' + item.file + ':' + item.line);
});
casper.exit(1);
};
});
casper.start('http://localhost:9981/accounts/login');
casper.then(function () {
casper.test.info('Logging in');