diff --git a/zephyr/tests/frontend/tests.js b/zephyr/tests/frontend/tests.js index 3d5f14d812..e9b00163d2 100644 --- a/zephyr/tests/frontend/tests.js +++ b/zephyr/tests/frontend/tests.js @@ -120,6 +120,21 @@ function un_narrow() { // Start of test script. casper.start('http://localhost:9981/', 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.test.assertHttpStatus(302); casper.test.assertUrlMatch(/^http:\/\/[^\/]+\/accounts\/home/, 'Redirected to /accounts/home'); casper.click('a[href^="/accounts/login"]');