diff --git a/zephyr/tests/frontend/common.js b/zephyr/tests/frontend/common.js index 148ce6e29c..5f22970e9d 100644 --- a/zephyr/tests/frontend/common.js +++ b/zephyr/tests/frontend/common.js @@ -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');