Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ const buildPackageRestrictedImports = (packageName, root, allowRootImports = tru
]),
];

const mochaPluginOverride = baseline.overrides.find((override) =>
override.extends?.includes('plugin:mocha/recommended'),
);

module.exports = {
...baseline,
plugins: [
Expand Down Expand Up @@ -187,7 +191,19 @@ module.exports = {
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
},
overrides: [
...baseline.overrides,
...baseline.overrides.filter(
(override) => !override.extends?.includes('plugin:mocha/recommended'),
),
{
...mochaPluginOverride,
extends: [],
rules: Object.entries(mochaPluginOverride.rules).reduce((acc, [key, value]) => {
if (!key.includes('mocha')) {
Comment on lines +198 to +201
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly altering the test rules to avoid the need for eslint-plugin-mocha`, while monorepo still "mandates" it. 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully can be ditched once we move to flat config

Copy link
Member

@Janpot Janpot Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yeah, let's do a big overhaul once we go to flat config

cc @brijeshb42 just for visibility on this eslint config file. Could give ideas on how we optimally abstract our shared flat configs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I already have some ideas for it.

acc[key] = value;
}
return acc;
}, {}),
},
{
files: [
// matching the pattern of the test runner
Expand Down
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
"@babel/preset-typescript": "catalog:",
"@mui/internal-docs-utils": "^2.0.1",
"@mui/internal-scripts": "^2.0.9",
"@types/chai": "catalog:",
"@types/chance": "catalog:",
"@types/d3-scale": "catalog:",
"@types/d3-scale-chromatic": "^3.1.0",
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/utils/postProcessImport.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically the main "noisy" change - relying on the bundled chai imported from vitest/globals.

import adapterDependencies from './adapter-dependencies.json';
import { ADAPTER_TO_LIBRARY, postProcessImport } from './postProcessImport';

Expand Down
12 changes: 10 additions & 2 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
"skipLibCheck": true,
"esModuleInterop": true,
"incremental": true,
"types": ["@mui/internal-test-utils/initMatchers", "chai-dom", "mocha"]
"types": ["@mui/internal-test-utils/initMatchers", "vitest/globals"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note that this will add the globals to all docs code, even non-tests. Ideally we have separate tsconfigs for tests and docs, perhaps explicitly importing them in test files could already remove a bit of this friction?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. 👍
It wouldn't hurt to have separate configs for sure. 💯

Copy link
Member Author

@JCQuintas JCQuintas Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what we had with mocha as well 🤷

I would be in favour of removing the globals and explicitly importing them, but mui/material code would cry

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'm also for importing them explicitly

},
"include": ["next-env.d.ts", "next.config.mjs", "docs-env.d.ts", "src", "pages/**/*.ts*", "data"],
"include": [
"next-env.d.ts",
"next.config.mjs",
"docs-env.d.ts",
"src",
"pages/**/*.ts*",
"data",
"../test/utils/addChaiAssertions.ts"
],
"exclude": ["docs/.next", "docs/export", "pages/playground"]
}
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@
"@playwright/test": "catalog:",
"@types/babel__core": "^7.20.5",
"@types/babel__traverse": "^7.20.7",
"@types/chai": "catalog:",
"@types/chai-dom": "^1.11.3",
"@types/fs-extra": "^11.0.4",
"@types/lodash": "catalog:",
"@types/mocha": "^10.0.10",
"@types/node": "^24.0.1",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
Expand All @@ -126,7 +124,6 @@
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"babel-plugin-transform-react-remove-prop-types": "catalog:",
"babel-plugin-transform-replace-expressions": "^0.2.0",
"chai": "catalog:",
"chai-dom": "^1.12.1",
"compression-webpack-plugin": "^11.1.0",
"concurrently": "^9.1.2",
Expand All @@ -146,7 +143,6 @@
"eslint-plugin-jsdoc": "^50.8.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-material-ui": "workspace:^",
"eslint-plugin-mocha": "^10.5.0",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-compiler": "19.0.0-beta-ebf51a3-20250411",
Expand Down
3 changes: 1 addition & 2 deletions packages/x-charts-premium/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"types": [
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"chai-dom",
"mocha",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mocha is no more in the context of mui-x. 🎉

"vitest/globals",
"node"
],
"noImplicitAny": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { sharedLicenseStatuses } from '@mui/x-license/useLicenseVerifier/useLicenseVerifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-promise-executor-return */
/* eslint-disable no-await-in-loop */
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen, fireEvent, act } from '@mui/internal-test-utils';
import { describeSkipIf, isJSDOM, testSkipIf } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';
import * as sinon from 'sinon';
import { BarChartPro } from './BarChartPro';

Expand All @@ -19,7 +18,7 @@ const getAxisTickValues = (axis: 'x' | 'y'): string[] => {
return axisData as string[];
};

describeSkipIf(isJSDOM)('<BarChartPro /> - Zoom', () => {
describe.skipIf(isJSDOM)('<BarChartPro /> - Zoom', () => {
const { render } = createRenderer();

const barChartProps = {
Expand Down Expand Up @@ -157,7 +156,7 @@ describeSkipIf(isJSDOM)('<BarChartPro /> - Zoom', () => {

// Technically it should work, but it's not working in the test environment
// https://github.com/pmndrs/use-gesture/discussions/430
testSkipIf(true)('should zoom on pinch', async () => {
it.skipIf(true)('should zoom on pinch', async () => {
const { user } = render(<BarChartPro {...barChartProps} />, options);

expect(screen.queryByText('A')).not.to.equal(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { sharedLicenseStatuses } from '@mui/x-license/useLicenseVerifier/useLicenseVerifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { calculateZoomEnd, calculateZoomStart, calculateZoomFromPointImpl } from './zoom-utils';
import { ZoomData } from '../../models';

Expand Down
5 changes: 2 additions & 3 deletions packages/x-charts-pro/src/FunnelChart/FunnelChart.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, describeConformance, screen } from '@mui/internal-test-utils';
import { Unstable_FunnelChart as FunnelChart } from '@mui/x-charts-pro/FunnelChart';
import { describeSkipIf, isJSDOM } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';

const config = {
series: [{ data: [{ value: 200 }, { value: 100 }] }],
Expand Down Expand Up @@ -44,7 +43,7 @@ describe('FunnelChart', () => {
expect(screen.getByText('No data to display')).toBeVisible();
});

describeSkipIf(isJSDOM)('gap', () => {
describe.skipIf(isJSDOM)('gap', () => {
it('should properly distance sections based on gap', async () => {
render(<FunnelChart {...config} gap={13} />);
const paths = document.querySelectorAll<HTMLElement>('path.MuiFunnelSection-root');
Expand Down
11 changes: 5 additions & 6 deletions packages/x-charts-pro/src/FunnelChart/checkClickEvent.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer } from '@mui/internal-test-utils';
import { spy } from 'sinon';
import { Unstable_FunnelChart as FunnelChart } from '@mui/x-charts-pro/FunnelChart';
import { testSkipIf, isJSDOM } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';

const config = {
series: [
Expand Down Expand Up @@ -50,7 +49,7 @@ describe('FunnelChart - click event', () => {

describe('onAxisClick', () => {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
testSkipIf(isJSDOM)('should provide the right context as second argument', async () => {
it.skipIf(isJSDOM)('should provide the right context as second argument', async () => {
const onAxisClick = spy();
const { user } = render(
<div
Expand Down Expand Up @@ -94,7 +93,7 @@ describe('FunnelChart - click event', () => {
});

// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
testSkipIf(isJSDOM)(
it.skipIf(isJSDOM)(
'should provide the right context as second argument with layout="horizontal"',
async () => {
const onAxisClick = spy();
Expand Down Expand Up @@ -145,7 +144,7 @@ describe('FunnelChart - click event', () => {
);

// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
testSkipIf(isJSDOM)(
it.skipIf(isJSDOM)(
'should provide the correct axis values when using category axis',
async () => {
const onAxisClick = spy();
Expand Down Expand Up @@ -210,7 +209,7 @@ describe('FunnelChart - click event', () => {
});

// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
testSkipIf(isJSDOM)('should provide the right context as second argument', async () => {
it.skipIf(isJSDOM)('should provide the right context as second argument', async () => {
const onItemClick = spy();
const { user } = render(
<div
Expand Down
1 change: 0 additions & 1 deletion packages/x-charts-pro/src/Heatmap/Heatmap.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { sharedLicenseStatuses } from '@mui/x-license/useLicenseVerifier/useLicenseVerifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { sharedLicenseStatuses } from '@mui/x-license/useLicenseVerifier/useLicenseVerifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-promise-executor-return */
/* eslint-disable no-await-in-loop */
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, fireEvent, act } from '@mui/internal-test-utils';
import { describeSkipIf, isJSDOM } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';
import * as sinon from 'sinon';
import { LineChartPro } from './LineChartPro';

Expand All @@ -19,7 +18,7 @@ const getAxisTickValues = (axis: 'x' | 'y'): string[] => {
return axisData as string[];
};

describeSkipIf(isJSDOM)('<LineChartPro /> - Zoom', () => {
describe.skipIf(isJSDOM)('<LineChartPro /> - Zoom', () => {
const { render } = createRenderer();

const lineChartProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { LicenseInfo } from '@mui/x-license';
import { sharedLicenseStatuses } from '@mui/x-license/useLicenseVerifier/useLicenseVerifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-promise-executor-return */
/* eslint-disable no-await-in-loop */
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, fireEvent, act } from '@mui/internal-test-utils';
import { describeSkipIf, isJSDOM } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';
import * as sinon from 'sinon';
import { ScatterChartPro } from './ScatterChartPro';

Expand All @@ -19,7 +18,7 @@ const getAxisTickValues = (axis: 'x' | 'y'): string[] => {
return axisData as string[];
};

describeSkipIf(isJSDOM)('<ScatterChartPro /> - Zoom', () => {
describe.skipIf(isJSDOM)('<ScatterChartPro /> - Zoom', () => {
const { render } = createRenderer();

const scatterChartProps = {
Expand Down
2 changes: 0 additions & 2 deletions packages/x-charts-pro/src/hooks/useFunnelSeries.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { renderHook, RenderHookResult } from '@mui/internal-test-utils';
import { expect } from 'chai';
import * as React from 'react';
import { useFunnelSeries, useFunnelSeriesContext } from './useFunnelSeries';
import {
Expand Down Expand Up @@ -41,7 +40,6 @@ describe('useFunnelSeriesContext', () => {
});
});

// eslint-disable-next-line mocha/max-top-level-suites
describe('useFunnelSeries', () => {
it('should return the specific funnel series when a single seriesId is provided', () => {
const { result } = renderHook(() => useFunnelSeries('1'), options);
Expand Down
2 changes: 0 additions & 2 deletions packages/x-charts-pro/src/hooks/useHeatmapSeries.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { renderHook, RenderHookResult } from '@mui/internal-test-utils';
import { expect } from 'chai';
import * as React from 'react';
import { useHeatmapSeries, useHeatmapSeriesContext } from './useHeatmapSeries';
import { Heatmap } from '../Heatmap';
Expand Down Expand Up @@ -48,7 +47,6 @@ describe('useHeatmapSeriesContext', () => {
});
});

// eslint-disable-next-line mocha/max-top-level-suites
describe('useHeatmapSeries', () => {
it('should return the specific heatmap series when a single seriesId is provided', () => {
const { result } = renderHook(() => useHeatmapSeries('1'), options);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { calculateZoom } from './calculateZoom';

describe('calculateZoom', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { ZoomData } from '@mui/x-charts/internals';
import { initializeZoomData } from './useChartProZoom';

Expand Down
3 changes: 1 addition & 2 deletions packages/x-charts-pro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"types": [
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"chai-dom",
"mocha",
"vitest/globals",
"node"
],
"noImplicitAny": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';

/*
* This test verifies that these modules and types are exported correctly
Expand Down
1 change: 0 additions & 1 deletion packages/x-charts-vendor/src/tests/d3-scale.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';

import {
scaleLinear,
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts-vendor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["mocha"]
"types": ["vitest/globals"]
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"],
"exclude": ["es", "lib", "jest.config.ts"]
Expand Down
7 changes: 3 additions & 4 deletions packages/x-charts/src/BarChart/BarChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import * as React from 'react';
import { createRenderer } from '@mui/internal-test-utils/createRenderer';
import { describeConformance } from 'test/utils/describeConformance';
import { BarChart, barElementClasses } from '@mui/x-charts/BarChart';
import { expect } from 'chai';
import { screen } from '@mui/internal-test-utils';
import { isJSDOM, testSkipIf } from 'test/utils/skipIf';
import { isJSDOM } from 'test/utils/skipIf';

describe('<BarChart />', () => {
const { render } = createRenderer();
Expand Down Expand Up @@ -49,7 +48,7 @@ describe('<BarChart />', () => {
);

// svg.createSVGPoint not supported by JSDom https://github.com/jsdom/jsdom/issues/300
testSkipIf(isJSDOM)(
it.skipIf(isJSDOM)(
'should hide tooltip if the item the tooltip was showing is removed',
async () => {
const { setProps, user } = render(
Expand Down Expand Up @@ -79,7 +78,7 @@ describe('<BarChart />', () => {
);

// svg.createSVGPoint not supported by JSDom https://github.com/jsdom/jsdom/issues/300
testSkipIf(isJSDOM)(
it.skipIf(isJSDOM)(
'should hide tooltip if the series of the item the tooltip was showing is removed',
async () => {
const { setProps, user } = render(
Expand Down
Loading
Loading