Skip to content

Commit 7a4dc06

Browse files
committed
tests: change runner to a module
Chai 5 only supports ES6 modules now, so if we want to upgrade past version 4, we have to change our test runners to modules first. Change-Id: I4d0c8cd425b29e5692cac14af1db2757b869f5d4 Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/6204313 Reviewed-by: Joel Hockey <[email protected]> Tested-by: kokoro <[email protected]>
1 parent a6c25c1 commit 7a4dc06

File tree

10 files changed

+16
-22
lines changed

10 files changed

+16
-22
lines changed

hterm/html/hterm_test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script src='../../node_modules/mocha/mocha.js'></script>
99

1010
<!-- initialize the test framework; this must come first -->
11-
<script src='../js/hterm_test.js'></script>
11+
<script type='module' src='../js/hterm_test.js'></script>
1212

1313
<script type='module' src='../js/hterm_tests.js'></script>
1414
<script type='module' src='../js/hterm_accessibility_reader_tests.js'></script>

hterm/js/hterm_test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// NB: This file is not loaded as a module because it modifies global scope.
6-
'use strict';
7-
85
/**
96
* @fileoverview Test framework setup when run inside the browser.
107
*/
@@ -14,7 +11,7 @@ mocha.setup('bdd');
1411
mocha.checkLeaks();
1512

1613
// Add a global shortcut to the assert API.
17-
const assert = chai.assert;
14+
globalThis['assert'] = chai.assert;
1815

1916
// Catch any random errors before the test runner runs.
2017
let earlyError = null;

libdot/externs/chai.js

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ chai.config;
2525
*/
2626
chai.assert = function(expression, message) {};
2727

28+
/**
29+
* Shortcut that we always export in our test runner.
30+
*
31+
* @const
32+
*/
33+
var assert = chai.assert;
34+
2835
/**
2936
* @param {*} actual
3037
* @param {*} expected

libdot/html/lib_test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script src='../../node_modules/mocha/mocha.js'></script>
99

1010
<!-- initialize the test framework; this must come first -->
11-
<script src='../js/lib_test.js'></script>
11+
<script type="module" src='../js/lib_test.js'></script>
1212

1313
<!-- libdot js tests -->
1414
<script type='module' src='../js/lib_codec_tests.js'></script>

libdot/js/lib_test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// NB: This file is not loaded as a module because it modifies global scope.
6-
'use strict';
7-
85
/**
96
* @fileoverview Test framework setup when run inside the browser.
107
*/
@@ -14,7 +11,7 @@ mocha.setup('bdd');
1411
mocha.checkLeaks();
1512

1613
// Add a global shortcut to the assert API.
17-
const assert = chai.assert;
14+
globalThis['assert'] = chai.assert;
1815

1916
// Catch any random errors before the test runner runs.
2017
let earlyError = null;

nassh/html/nassh_test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script src='../../node_modules/mocha/mocha.js'></script>
99

1010
<!-- initialize the test framework; this must come first -->
11-
<script src='../js/nassh_test.js'></script>
11+
<script type='module' src='../js/nassh_test.js'></script>
1212
<script src='../js/chrome_mock_for_test.js'></script>
1313

1414
<!-- All the unittests go below here. -->

nassh/js/nassh_test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// NB: This file is not loaded as a module because it modifies global scope.
6-
'use strict';
7-
85
/**
96
* @fileoverview Test framework setup when run inside the browser.
107
*/
@@ -14,7 +11,7 @@ mocha.setup('bdd');
1411
mocha.checkLeaks();
1512

1613
// Add a global shortcut to the assert API.
17-
const assert = chai.assert;
14+
globalThis['assert'] = chai.assert;
1815

1916
// Catch any random errors before the test runner runs.
2017
let earlyError = null;

terminal/js/terminal_test_preload.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
'use strict';
6-
75
/**
86
* @fileoverview Test framework setup when run inside the browser.
97
*/
108

119
// Add a global shortcut to the assert API.
12-
const assert = chai.assert;
10+
globalThis['assert'] = chai.assert;

wasi-js-bindings/test/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script src='../../node_modules/mocha/mocha.js'></script>
99

1010
<!-- Initialize the test framework; this must come first. -->
11-
<script src='runner.js'></script>
11+
<script type='module' src='runner.js'></script>
1212

1313
<!-- All the test modules. -->
1414
<script type='module' src='argv.js'></script>

wasi-js-bindings/test/runner.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
'use strict';
6-
75
/**
86
* @fileoverview WASI main test runner.
97
*/
@@ -18,7 +16,7 @@ chai.config.showDiff = true;
1816
chai.config.truncateThreshold = 0;
1917

2018
// Add a global shortcut to the assert API.
21-
const assert = chai.assert;
19+
globalThis['assert'] = chai.assert;
2220

2321
// Catch any random errors before the test runner runs.
2422
let earlyError = null;

0 commit comments

Comments
 (0)