Skip to content

Commit 134b18b

Browse files
Change testing framework from Mocha to Jest (#719)
Also bumps node versions in CI from [12, 14, 16] to [14, 16, 18, 20].
1 parent 24fb75a commit 134b18b

21 files changed

+1874
-1593
lines changed

Diff for: .github/workflows/build-and-run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# run this job for every combination of given matrix variables
1919
strategy:
2020
matrix:
21-
node-version: [12.x, 14.x, 16.x]
21+
node-version: [14.x, 16.x, 18.x, 20.x]
2222

2323
steps:
2424

Diff for: build_helpers/test-globals.js

-32
This file was deleted.

Diff for: jest.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
moduleFileExtensions: ['js', 'jsx'],
3+
moduleDirectories: ['node_modules'],
4+
5+
testRegex: ['.*-test.js'],
6+
7+
testEnvironment: 'jsdom',
8+
9+
setupFiles: ['<rootDir>/jest.setup.js'],
10+
};

Diff for: jest.setup.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = async function () {
2+
// NOTE (pradeep): Can this be synced with the definitions in webpack configs?
3+
globalThis.__DEV__ = true;
4+
};

Diff for: package.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
"@rollup/plugin-multi-entry": "^4.1.0",
3737
"@rollup/plugin-node-resolve": "^13.1.3",
3838
"@rollup/plugin-replace": "^4.0.0",
39-
"@types/chai": "^4.2.10",
40-
"@types/mocha": "^7.0.2",
4139
"@webpack-cli/serve": "^1.6.1",
4240
"aphrodite": "2.4.0",
4341
"autoprefixer": "^10.4.2",
@@ -46,7 +44,6 @@
4644
"babel-plugin-rewire": "1.2.0",
4745
"babel-plugin-syntax-trailing-function-commas": "^6.8.0",
4846
"bundle-loader": "0.5.6",
49-
"chai": "4.2.0",
5047
"css-loader": "^5.2.7",
5148
"eslint": "7",
5249
"eslint-config-prettier": "6.10.0",
@@ -57,15 +54,13 @@
5754
"global": "^4.4.0",
5855
"html-loader": "0.5.5",
5956
"husky": "^4.2.3",
60-
"jsdom": "^19.0.0",
57+
"jest": "^29.7.0",
58+
"jest-environment-jsdom": "^29.7.0",
6159
"less": "3.10.3",
6260
"less-loader": "5.0.0",
6361
"lint-staged": "^10.0.8",
6462
"marked": "4.0.10",
6563
"mini-css-extract-plugin": "^0.8.0",
66-
"mocha": "^6.1.4",
67-
"mocha-loader": "5.1.5",
68-
"mocha-webpack": "2.0.0-beta.0",
6964
"null-loader": "3.0.0",
7065
"postcss": "^8.4.12",
7166
"postcss-custom-properties": "^12.1.4",
@@ -80,7 +75,6 @@
8075
"rollup": "^2.70.1",
8176
"rollup-plugin-postcss": "^4.0.2",
8277
"rollup-plugin-terser": "^7.0.2",
83-
"sinon": "9.0.2",
8478
"style-loader": "1.0.0",
8579
"terser-webpack-plugin": "4.2.3",
8680
"url-loader": "2.1.0",
@@ -97,9 +91,8 @@
9791
"publish-site": "./build_helpers/publishStaticSite.sh",
9892
"publish-package": "./build_helpers/publishPackage.sh",
9993
"publish-beta": "./build_helpers/publishPackage.sh --beta",
100-
"test": "mocha-webpack --webpack-config webpack.config-test.js \"test/**/*-test.js\" --require build_helpers/test-globals.js",
101-
"test:watch": "mocha-webpack --webpack-config webpack.config-test.js --watch \"test/**/*-test.js\" --require build_helpers/test-globals.js",
102-
"test:server": "webpack-dev-server --config webpack.config-test.js --hot"
94+
"test": "jest",
95+
"test:watch": "jest --watch"
10396
},
10497
"repository": {
10598
"type": "git",

0 commit comments

Comments
 (0)