Skip to content

Commit e8c4c99

Browse files
committed
chai: update to v5
This version only ships ES6 modules, so we need to tweak how it's imported & used. Change-Id: I2f1ea444d072dc815717f69170e1951010383f54 Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/6217759 Reviewed-by: Joel Hockey <[email protected]> Tested-by: kokoro <[email protected]>
1 parent 42c323a commit e8c4c99

File tree

15 files changed

+30
-20
lines changed

15 files changed

+30
-20
lines changed

hterm/html/hterm_test.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset='utf-8'/>
55

66
<!-- npm modules -->
7-
<script src='../../node_modules/chai/chai.js'></script>
87
<script src='../../node_modules/mocha/mocha.js'></script>
98

109
<!-- initialize the test framework; this must come first -->

hterm/js/hterm_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
/**
66
* @fileoverview Test framework setup when run inside the browser.
7+
* @suppress {moduleLoad} closure compiler can't handle node_modules/.
78
*/
89

10+
import {assert} from '../../node_modules/chai/chai.js';
11+
912
// Setup the mocha framework.
1013
mocha.setup('bdd');
1114
mocha.checkLeaks();
1215

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

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

hterm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@rollup/plugin-node-resolve": "~15",
32-
"chai": "~4",
32+
"chai": "~5",
3333
"eslint": "~8",
3434
"mocha": "~11",
3535
"mocha-headless-chrome": "~4",

libdot/bin/node

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import libdot
1616
# The hash of the node_modules that we maintain.
1717
# Allow a long line for easy automated updating.
1818
NODE_MODULES_HASH = (
19-
"f54d402945ab7d7be9cc882249ace797e392b24abbbf3ea20feeb6b71d6c4ea8"
19+
"d384bf88a099d6b1f1140c8eefee178d1b6923fda2fe8d0a9f0055a44acd171f"
2020
)
2121

2222
# In sync with Chromium's DEPS file because it's easier to use something that

libdot/html/lib_test.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset='utf-8'/>
55

66
<!-- npm modules -->
7-
<script src='../../node_modules/chai/chai.js'></script>
87
<script src='../../node_modules/mocha/mocha.js'></script>
98

109
<!-- initialize the test framework; this must come first -->

libdot/js/lib_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
/**
66
* @fileoverview Test framework setup when run inside the browser.
7+
* @suppress {moduleLoad} closure compiler can't handle node_modules/.
78
*/
89

10+
import {assert} from '../../node_modules/chai/chai.js';
11+
912
// Setup the mocha framework.
1013
mocha.setup('bdd');
1114
mocha.checkLeaks();
1215

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

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

libdot/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "./bin/load_tests"
2727
},
2828
"devDependencies": {
29-
"chai": "~4",
29+
"chai": "~5",
3030
"eslint": "~8",
3131
"mocha": "~11",
3232
"mocha-headless-chrome": "~4",

nassh/html/nassh_test.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset='utf-8'/>
55

66
<!-- npm modules -->
7-
<script src='../../node_modules/chai/chai.js'></script>
87
<script src='../../node_modules/mocha/mocha.js'></script>
98

109
<!-- initialize the test framework; this must come first -->

nassh/js/nassh_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
/**
66
* @fileoverview Test framework setup when run inside the browser.
7+
* @suppress {moduleLoad} closure compiler can't handle node_modules/.
78
*/
89

10+
import {assert} from '../../node_modules/chai/chai.js';
11+
912
// Setup the mocha framework.
1013
mocha.setup('bdd');
1114
mocha.checkLeaks();
1215

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

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

nassh/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"devDependencies": {
3232
"@rollup/plugin-node-resolve": "~15",
3333
"@rollup/plugin-terser": "~0",
34-
"chai": "~4",
34+
"chai": "~5",
3535
"eslint": "~8",
3636
"http-server": "~14",
3737
"license-checker": "~25",

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@rollup/plugin-terser": "~0",
2727
"@rollup/plugin-url": "~8",
2828
"@rollup/plugin-yaml": "~4",
29-
"@types/chai": "~4",
29+
"@types/chai": "~5",
3030
"@types/chrome": "~0",
3131
"@types/filesystem": "~0",
3232
"@types/filewriter": "~0",
@@ -35,7 +35,7 @@
3535
"@types/punycode": "~2",
3636
"@types/trusted-types": "~2",
3737
"asn1js": "~2",
38-
"chai": "~4",
38+
"chai": "~5",
3939
"csso": ">=5",
4040
"csso-cli": ">=4",
4141
"eslint": "~8",

terminal/html/terminal_test.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
<link rel="icon" href="../images/empty.svg" type="image/svg+xml">
77

88
<!-- npm modules -->
9-
<script src='../../node_modules/chai/chai.js'></script>
109
<script src='../../node_modules/mocha/mocha.js'></script>
1110

1211
<!-- Initialize the test framework first. -->
13-
<script src='../js/terminal_test_preload.js'></script>
12+
<script type='module' src='../js/terminal_test_preload.js'></script>
1413
<script type='module' src='../js/terminal_test.js'></script>
1514

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

terminal/js/terminal_test_preload.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
/**
66
* @fileoverview Test framework setup when run inside the browser.
7+
* @suppress {moduleLoad} closure compiler can't handle node_modules/.
78
*/
89

10+
import {assert} from '../../node_modules/chai/chai.js';
11+
912
// Add a global shortcut to the assert API.
10-
globalThis['assert'] = chai.assert;
13+
globalThis['assert'] = assert;

wasi-js-bindings/test/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset='utf-8'/>
55

66
<!-- npm modules -->
7-
<script src='../../node_modules/chai/chai.js'></script>
87
<script src='../../node_modules/mocha/mocha.js'></script>
98

109
<!-- Initialize the test framework; this must come first. -->

wasi-js-bindings/test/runner.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44

55
/**
66
* @fileoverview WASI main test runner.
7+
* @suppress {moduleLoad} closure compiler can't handle node_modules/.
78
*/
89

10+
import {assert, config} from '../../node_modules/chai/chai.js';
11+
912
// Setup the mocha framework.
1013
mocha.setup('bdd');
1114
mocha.checkLeaks();
1215

1316
// Make failure output more useful.
14-
chai.config.includeStack = true;
15-
chai.config.showDiff = true;
16-
chai.config.truncateThreshold = 0;
17+
config.includeStack = true;
18+
config.showDiff = true;
19+
config.truncateThreshold = 0;
1720

1821
// Add a global shortcut to the assert API.
19-
globalThis['assert'] = chai.assert;
22+
globalThis['assert'] = assert;
2023

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

0 commit comments

Comments
 (0)