blob: e2cd27379c0f5fb07a85363ed571412b052fbe5b [file] [log] [blame]
Robert Gindacf288e52012-10-15 11:13:52 -07001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5'use strict';
6
Mike Frysingerd9900db2019-03-03 04:10:46 -05007/**
8 * @fileoverview Test framework setup when run inside the browser.
9 */
Robert Gindacf288e52012-10-15 11:13:52 -070010
Mike Frysingerd9900db2019-03-03 04:10:46 -050011// Setup the mocha framework.
12mocha.setup('bdd');
13mocha.checkLeaks();
14
15// Add a global shortcut to the assert API.
16const assert = chai.assert;
17
18// Catch any random errors before the test runner runs.
19let earlyError = null;
Joel Hockey0f933582019-08-27 18:01:51 -070020/** Catch any errors. */
Mike Frysingerd9900db2019-03-03 04:10:46 -050021window.onerror = function() {
22 earlyError = Array.from(arguments);
23};
24
Joel Hockey0f933582019-08-27 18:01:51 -070025/** Run the test framework once everything is finished. */
Robert Gindacf288e52012-10-15 11:13:52 -070026window.onload = function() {
Robert Gindacf288e52012-10-15 11:13:52 -070027 hterm.defaultStorage = new lib.Storage.Memory();
28
Mike Frysingerd9900db2019-03-03 04:10:46 -050029 lib.init(() => {
30 mocha.run();
Robert Gindacf288e52012-10-15 11:13:52 -070031
Mike Frysingerd9900db2019-03-03 04:10:46 -050032 if (earlyError !== null) {
33 assert.fail(`uncaught exception detected:\n${earlyError.join('\n')}\n`);
34 }
35 });
Robert Gindacf288e52012-10-15 11:13:52 -070036};