blob: 59a8ca466798bcf0ad33ca989612d844a1582801 [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;
20window.onerror = function() {
21 earlyError = Array.from(arguments);
22};
23
24// Run the test framework once everything is finished.
Robert Gindacf288e52012-10-15 11:13:52 -070025window.onload = function() {
Robert Gindacf288e52012-10-15 11:13:52 -070026 hterm.defaultStorage = new lib.Storage.Memory();
27
Mike Frysingerd9900db2019-03-03 04:10:46 -050028 lib.init(() => {
29 mocha.run();
Robert Gindacf288e52012-10-15 11:13:52 -070030
Mike Frysingerd9900db2019-03-03 04:10:46 -050031 if (earlyError !== null) {
32 assert.fail(`uncaught exception detected:\n${earlyError.join('\n')}\n`);
33 }
34 });
Robert Gindacf288e52012-10-15 11:13:52 -070035};