Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WS-2021-0638][Security] Alias and bump mocha to v10.1.0 #4874

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
`;

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

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- 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))
- Bump `node-sass` to a version that uses a newer `libsass` ([#4649](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4649))
- [WS-2021-0638][Security] bump mocha to 10.1.0 ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))


### 📈 Features/Enhancements

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
"**/semver": "^7.5.3",
"**/set-value": "^4.1.0",
"**/xml2js": "^0.5.0",
"**/yaml": "^2.2.2"
"**/yaml": "^2.2.2",
"**/eslint-plugin-mocha-next/mocha": "npm:mocha@^10.1.0"
},
"workspaces": {
"packages": [
Expand Down Expand Up @@ -305,7 +306,7 @@
"@types/lru-cache": "^5.1.0",
"@types/markdown-it": "^0.0.7",
"@types/minimatch": "^2.0.29",
"@types/mocha": "^7.0.2",
"@types/mocha-next": "npm:@types/mocha@^10.0.1",
"@types/mock-fs": "^4.10.0",
"@types/moment-timezone": "^0.5.12",
"@types/mustache": "^0.8.31",
Expand Down Expand Up @@ -377,7 +378,7 @@
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-mocha-next": "npm:eslint-plugin-mocha@^10.1.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
Expand Down Expand Up @@ -419,7 +420,7 @@
"load-grunt-config": "^4.0.1",
"load-json-file": "^6.2.0",
"markdown-it": "^12.3.2",
"mocha": "^7.2.0",
"mocha-next": "npm:mocha@^10.1.0",
"mock-fs": "^4.12.0",
"monaco-editor": "~0.17.0",
"ms-chromium-edge-driver": "^0.4.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
files: ['**/*.js'],
parser: require.resolve('babel-eslint'),

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

settings: {
'import/resolver': {
Expand Down Expand Up @@ -111,8 +111,8 @@ module.exports = {
'valid-typeof': 'error',
yoda: 'off',

'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
'mocha-next/handle-done-callback': 'error',
'mocha-next/no-exclusive-tests': 'error',

'import/no-unresolved': ['error', { amd: true, commonjs: true }],
'import/named': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-mocha-next": "npm:eslint-plugin-mocha@^10.1.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('failure hooks', function () {
{
flag: '$FAILING_TEST$',
assert(lines) {
expect(lines.shift()).to.match(/\$FAILING_TEST\$/);
expect(lines.shift()).to.match(/global before each/);
expect(lines.shift()).to.match(/info\s+testFailure\s+\$FAILING_TEST_ERROR\$/);
expect(lines.shift()).to.match(/info\s+testFailureAfterDelay\s+\$FAILING_TEST_ERROR\$/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

import { format } from 'util';

import Mocha from 'mocha';
import { create as createSuite } from 'mocha/lib/suite';
import Test from 'mocha/lib/test';
import Mocha from 'mocha-next';
import { create as createSuite } from 'mocha-next/lib/suite';
import Test from 'mocha-next/lib/test';

import { filterSuitesByTags } from './filter_suites_by_tags';

Expand Down Expand Up @@ -111,8 +111,8 @@ it('only runs hooks of parents and tests in level1a', async () => {
"suite: ",
"suite: level 1",
"suite: level 1 level 1a",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
"test: level 1 level 1a test 1a",
]
`);
Expand All @@ -130,8 +130,8 @@ it('only runs hooks of parents and tests in level1b', async () => {
"suite: ",
"suite: level 1",
"suite: level 1 level 1b",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
"test: level 1 level 1b test 1b",
]
`);
Expand All @@ -149,12 +149,12 @@ it('only runs hooks of parents and tests in level1a and level1b', async () => {
"suite: ",
"suite: level 1",
"suite: level 1 level 1a",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
"test: level 1 level 1a test 1a",
"suite: level 1 level 1b",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
"test: level 1 level 1b test 1b",
]
`);
Expand All @@ -173,8 +173,8 @@ it('only runs level1a if including level1 and excluding level1b', async () => {
"suite: ",
"suite: level 1",
"suite: level 1 level 1a",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1a\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1a\\"",
"test: level 1 level 1a test 1a",
]
`);
Expand All @@ -193,8 +193,8 @@ it('only runs level1b if including level1 and excluding level1a', async () => {
"suite: ",
"suite: level 1",
"suite: level 1 level 1b",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: level 1 \\"before each\\" hook: level1BeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 1b\\"",
"hook: level 1 \\"before each\\" hook: level1BeforeEach for \\"test 1b\\"",
"test: level 1 level 1b test 1b",
]
`);
Expand All @@ -212,7 +212,7 @@ it('only runs level2 if excluding level1', async () => {
"suite: ",
"suite: level 2",
"suite: level 2 level 2a",
"hook: \\"before each\\" hook: rootBeforeEach",
"hook: \\"before each\\" hook: rootBeforeEach for \\"test 2a\\"",
"test: level 2 level 2a test 2a",
]
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import { format } from 'util';

import Mocha from 'mocha';
import Mocha from 'mocha-next';
import { ToolingLogTextWriter } from '@osd/dev-utils';
import moment from 'moment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import Mocha from 'mocha';
import Mocha from 'mocha-next';
import { relative } from 'path';
import { REPO_ROOT } from '@osd/utils';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/mocha/__tests__/junit_report_generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { readFileSync } from 'fs';
import { fromNode as fcb } from 'bluebird';
import { parseString } from 'xml2js';
import del from 'del';
import Mocha from 'mocha';
import Mocha from 'mocha-next';
import expect from '@osd/expect';
import { getUniqueJunitReportPath } from '@osd/test';

Expand Down
2 changes: 1 addition & 1 deletion src/dev/mocha/auto_junit_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import mocha from 'mocha';
import mocha from 'mocha-next';
import { setupJUnitReportGeneration } from './junit_report_generation';

const MochaSpecReporter = mocha.reporters.spec;
Expand Down
4 changes: 2 additions & 2 deletions src/dev/mocha/run_mocha_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
}

if (runInBand) {
require('mocha/bin/_mocha');
require('mocha-next/bin/_mocha');

Check warning on line 104 in src/dev/mocha/run_mocha_cli.js

View check run for this annotation

Codecov / codecov/patch

src/dev/mocha/run_mocha_cli.js#L104

Added line #L104 was not covered by tests
} else {
require('mocha/bin/mocha');
require('mocha-next/bin/mocha');
}
}
2 changes: 1 addition & 1 deletion test/mocha_decorations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { Suite } from 'mocha';
import { Suite } from 'mocha-next';

type Tags =
| 'ciGroup1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

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

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

Expand Down
Loading
Loading