Skip to content

Commit 993ebc0

Browse files
AMoo-Mikiashwin-pc
andauthored
Alias and bump mocha (#4874)
Cherry-pick 9377fbb from #2711 and: * Update to `mocha@^10.1.0`, aliased as `mocha-next` * Update to `eslint-plugin-mocha@^10.1.0`, aliased as `eslint-plugin-mocha-next` * Update to `@types/mocha@^10.0.1`, aliased as `@types/mocha-next` Signed-off-by: Miki <miki@amazon.com> Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
1 parent 9eb1ca3 commit 993ebc0

File tree

15 files changed

+218
-313
lines changed

15 files changed

+218
-313
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
108108
`;
109109

110110
const allMochaRulesOff = {};
111-
Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => {
112-
allMochaRulesOff['mocha/' + k] = 'off';
111+
Object.keys(require('eslint-plugin-mocha-next').rules).forEach((k) => {
112+
allMochaRulesOff['mocha-next/' + k] = 'off';
113113
});
114114

115115
module.exports = {

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
99

1010
- Bump `joi` to v14 to avoid the possibility of prototype poisoning in a nested dependency ([#3952](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3952))
1111
- Bump `node-sass` to a version that uses a newer `libsass` ([#4649](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4649))
12+
- [WS-2021-0638][Security] bump mocha to 10.1.0 ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))
13+
1214

1315
### 📈 Features/Enhancements
1416

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
"**/semver": "^7.5.3",
102102
"**/set-value": "^4.1.0",
103103
"**/xml2js": "^0.5.0",
104-
"**/yaml": "^2.2.2"
104+
"**/yaml": "^2.2.2",
105+
"**/eslint-plugin-mocha-next/mocha": "npm:mocha@^10.1.0"
105106
},
106107
"workspaces": {
107108
"packages": [
@@ -305,7 +306,7 @@
305306
"@types/lru-cache": "^5.1.0",
306307
"@types/markdown-it": "^0.0.7",
307308
"@types/minimatch": "^2.0.29",
308-
"@types/mocha": "^7.0.2",
309+
"@types/mocha-next": "npm:@types/mocha@^10.0.1",
309310
"@types/mock-fs": "^4.10.0",
310311
"@types/moment-timezone": "^0.5.12",
311312
"@types/mustache": "^0.8.31",
@@ -377,7 +378,7 @@
377378
"eslint-plugin-import": "^2.25.4",
378379
"eslint-plugin-jest": "^26.1.1",
379380
"eslint-plugin-jsx-a11y": "^6.2.3",
380-
"eslint-plugin-mocha": "^6.2.2",
381+
"eslint-plugin-mocha-next": "npm:eslint-plugin-mocha@^10.1.0",
381382
"eslint-plugin-no-unsanitized": "^3.0.2",
382383
"eslint-plugin-node": "^11.0.0",
383384
"eslint-plugin-prefer-object-spread": "^1.2.1",
@@ -419,7 +420,7 @@
419420
"load-grunt-config": "^4.0.1",
420421
"load-json-file": "^6.2.0",
421422
"markdown-it": "^12.3.2",
422-
"mocha": "^7.2.0",
423+
"mocha-next": "npm:mocha@^10.1.0",
423424
"mock-fs": "^4.12.0",
424425
"monaco-editor": "~0.17.0",
425426
"ms-chromium-edge-driver": "^0.4.3",

packages/opensearch-eslint-config-opensearch-dashboards/javascript.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
files: ['**/*.js'],
4141
parser: require.resolve('babel-eslint'),
4242

43-
plugins: ['mocha', 'babel', 'import', 'no-unsanitized', 'prefer-object-spread'],
43+
plugins: ['mocha-next', 'babel', 'import', 'no-unsanitized', 'prefer-object-spread'],
4444

4545
settings: {
4646
'import/resolver': {
@@ -111,8 +111,8 @@ module.exports = {
111111
'valid-typeof': 'error',
112112
yoda: 'off',
113113

114-
'mocha/handle-done-callback': 'error',
115-
'mocha/no-exclusive-tests': 'error',
114+
'mocha-next/handle-done-callback': 'error',
115+
'mocha-next/no-exclusive-tests': 'error',
116116

117117
'import/no-unresolved': ['error', { amd: true, commonjs: true }],
118118
'import/named': 'error',

packages/opensearch-eslint-config-opensearch-dashboards/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"eslint-plugin-eslint-comments": "^3.2.0",
2929
"eslint-plugin-import": "^2.25.4",
3030
"eslint-plugin-jest": "^26.1.1",
31-
"eslint-plugin-mocha": "^6.2.2",
31+
"eslint-plugin-mocha-next": "npm:eslint-plugin-mocha@^10.1.0",
3232
"eslint-plugin-no-unsanitized": "^3.0.2",
3333
"eslint-plugin-prefer-object-spread": "^1.2.1",
3434
"eslint-plugin-react": "^7.17.0",

packages/osd-test/src/functional_test_runner/integration/failure_hooks.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('failure hooks', function () {
5555
{
5656
flag: '$FAILING_TEST$',
5757
assert(lines) {
58+
expect(lines.shift()).to.match(/\$FAILING_TEST\$/);
5859
expect(lines.shift()).to.match(/global before each/);
5960
expect(lines.shift()).to.match(/info\s+testFailure\s+\$FAILING_TEST_ERROR\$/);
6061
expect(lines.shift()).to.match(/info\s+testFailureAfterDelay\s+\$FAILING_TEST_ERROR\$/);

packages/osd-test/src/functional_test_runner/lib/mocha/filter_suites_by_tags.test.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
import { format } from 'util';
3232

33-
import Mocha from 'mocha';
34-
import { create as createSuite } from 'mocha/lib/suite';
35-
import Test from 'mocha/lib/test';
33+
import Mocha from 'mocha-next';
34+
import { create as createSuite } from 'mocha-next/lib/suite';
35+
import Test from 'mocha-next/lib/test';
3636

3737
import { filterSuitesByTags } from './filter_suites_by_tags';
3838

@@ -111,8 +111,8 @@ it('only runs hooks of parents and tests in level1a', async () => {
111111
"suite: ",
112112
"suite: level 1",
113113
"suite: level 1 level 1a",
114-
"hook: \\"before each\\" hook: rootBeforeEach",
115-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
114+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
115+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
116116
"test: level 1 level 1a test 1a",
117117
]
118118
`);
@@ -130,8 +130,8 @@ it('only runs hooks of parents and tests in level1b', async () => {
130130
"suite: ",
131131
"suite: level 1",
132132
"suite: level 1 level 1b",
133-
"hook: \\"before each\\" hook: rootBeforeEach",
134-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
133+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
134+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
135135
"test: level 1 level 1b test 1b",
136136
]
137137
`);
@@ -149,12 +149,12 @@ it('only runs hooks of parents and tests in level1a and level1b', async () => {
149149
"suite: ",
150150
"suite: level 1",
151151
"suite: level 1 level 1a",
152-
"hook: \\"before each\\" hook: rootBeforeEach",
153-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
152+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
153+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
154154
"test: level 1 level 1a test 1a",
155155
"suite: level 1 level 1b",
156-
"hook: \\"before each\\" hook: rootBeforeEach",
157-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
156+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
157+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
158158
"test: level 1 level 1b test 1b",
159159
]
160160
`);
@@ -173,8 +173,8 @@ it('only runs level1a if including level1 and excluding level1b', async () => {
173173
"suite: ",
174174
"suite: level 1",
175175
"suite: level 1 level 1a",
176-
"hook: \\"before each\\" hook: rootBeforeEach",
177-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
176+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
177+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
178178
"test: level 1 level 1a test 1a",
179179
]
180180
`);
@@ -193,8 +193,8 @@ it('only runs level1b if including level1 and excluding level1a', async () => {
193193
"suite: ",
194194
"suite: level 1",
195195
"suite: level 1 level 1b",
196-
"hook: \\"before each\\" hook: rootBeforeEach",
197-
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
196+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
197+
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
198198
"test: level 1 level 1b test 1b",
199199
]
200200
`);
@@ -212,7 +212,7 @@ it('only runs level2 if excluding level1', async () => {
212212
"suite: ",
213213
"suite: level 2",
214214
"suite: level 2 level 2a",
215-
"hook: \\"before each\\" hook: rootBeforeEach",
215+
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 2a\\"",
216216
"test: level 2 level 2a test 2a",
217217
]
218218
`);

packages/osd-test/src/functional_test_runner/lib/mocha/reporter/reporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import { format } from 'util';
3232

33-
import Mocha from 'mocha';
33+
import Mocha from 'mocha-next';
3434
import { ToolingLogTextWriter } from '@osd/dev-utils';
3535
import moment from 'moment';
3636

packages/osd-test/src/functional_test_runner/lib/mocha/setup_mocha.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
import Mocha from 'mocha';
31+
import Mocha from 'mocha-next';
3232
import { relative } from 'path';
3333
import { REPO_ROOT } from '@osd/utils';
3434

src/dev/mocha/__tests__/junit_report_generation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { readFileSync } from 'fs';
3434
import { fromNode as fcb } from 'bluebird';
3535
import { parseString } from 'xml2js';
3636
import del from 'del';
37-
import Mocha from 'mocha';
37+
import Mocha from 'mocha-next';
3838
import expect from '@osd/expect';
3939
import { getUniqueJunitReportPath } from '@osd/test';
4040

src/dev/mocha/auto_junit_reporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
import mocha from 'mocha';
31+
import mocha from 'mocha-next';
3232
import { setupJUnitReportGeneration } from './junit_report_generation';
3333

3434
const MochaSpecReporter = mocha.reporters.spec;

src/dev/mocha/run_mocha_cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ export function runMochaCli() {
101101
}
102102

103103
if (runInBand) {
104-
require('mocha/bin/_mocha');
104+
require('mocha-next/bin/_mocha');
105105
} else {
106-
require('mocha/bin/mocha');
106+
require('mocha-next/bin/mocha');
107107
}
108108
}

test/mocha_decorations.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
import { Suite } from 'mocha';
31+
import { Suite } from 'mocha-next';
3232

3333
type Tags =
3434
| 'ciGroup1'

test/visual_regression/services/visual_testing/visual_testing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030

3131
import { postSnapshot } from '@percy/sdk-utils';
32-
import { Test } from 'mocha';
32+
import { Test } from 'mocha-next';
3333

3434
import { testSubjSelector } from '@osd/test-subj-selector';
3535

0 commit comments

Comments
 (0)