mirror of https://github.com/zulip/zulip.git
tests.js: Fail if we get a JavaScript error in the page's context
(imported from commit 2f1299ff660b8948ac1451e5724c1f198c7a4e29)
This commit is contained in:
parent
4a9d65c758
commit
c4e9d95420
|
@ -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"]');
|
||||
|
|
Loading…
Reference in New Issue