Skip to content

Commit

Permalink
[test] Use test-utils from npm (#12880)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Cherniavskyi <[email protected]>
Co-authored-by: Lukas <[email protected]>
  • Loading branch information
3 people authored May 29, 2024
1 parent 44daee5 commit 7269ea0
Show file tree
Hide file tree
Showing 197 changed files with 722 additions and 816 deletions.
3 changes: 0 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const defaultAlias = {
'@mui-internal/api-docs-builder': resolveAliasPath(
'./node_modules/@mui/monorepo/packages/api-docs-builder',
),
'@mui-internal/test-utils': resolveAliasPath(
'./node_modules/@mui/monorepo/packages/test-utils/src',
),
docs: resolveAliasPath('./node_modules/@mui/monorepo/docs'),
test: resolveAliasPath('./test'),
packages: resolveAliasPath('./packages'),
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@types/luxon": "^3.4.2",
"@types/moment-hijri": "^2.1.4",
"@types/moment-jalaali": "^0.7.9",
"@types/react-dom": "18.2.19",
"@types/react-dom": "18.2.25",
"@types/react-router-dom": "^5.3.3",
"@types/stylis": "^4.2.6",
"@types/webpack-bundle-analyzer": "^4.7.0",
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"size:why": "pnpm size:snapshot --analyze --accurateBundles",
"tc": "node test/cli.js",
"test": "node scripts/test.mjs",
"test:coverage": "cross-env NODE_ENV=test TZ=UTC BABEL_ENV=coverage nyc mocha --exclude '**/node_modules/**' && nyc report -r lcovonly",
"test:coverage": "cross-env NODE_OPTIONS=--max-old-space-size=4096 NODE_ENV=test TZ=UTC BABEL_ENV=coverage nyc mocha --exclude '**/node_modules/**' && nyc report -r lcovonly",
"test:coverage:html": "cross-env NODE_ENV=test TZ=UTC BABEL_ENV=coverage nyc mocha --exclude '**/node_modules/**' && nyc report --reporter=html",
"test:coverage:inspect": "cross-env NODE_ENV=test TZ=UTC BABEL_ENV=coverage mocha --inspect-brk --exclude '**/node_modules/**' ",
"test:karma": "cross-env NODE_ENV=test TZ=UTC karma start test/karma.conf.js",
Expand Down Expand Up @@ -88,25 +88,27 @@
"@mnajdova/enzyme-adapter-react-18": "^0.2.0",
"@mui/icons-material": "^5.15.14",
"@mui/internal-markdown": "^1.0.3",
"@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
"@mui/material": "^5.15.14",
"@mui/monorepo": "github:mui/material-ui#70327ca89c820bd60683dda36532c775be134a4d",
"@mui/utils": "^5.15.14",
"@next/eslint-plugin-next": "14.2.3",
"@octokit/plugin-retry": "^6.0.1",
"@octokit/rest": "^20.1.1",
"@playwright/test": "^1.44.1",
"@testing-library/react": "^14.3.1",
"@testing-library/react": "^15.0.7",
"@types/babel__core": "^7.20.5",
"@types/chai": "^4.3.16",
"@types/chai-dom": "^1.11.3",
"@types/enzyme": "3.10.12",
"@types/fs-extra": "^11.0.4",
"@types/karma": "^6.3.8",
"@types/lodash": "^4.17.4",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.33",
"@types/prettier": "^2.7.3",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@types/react-dom": "^18.2.25",
"@types/react-test-renderer": "^18.3.0",
"@types/requestidlecallback": "^0.3.7",
"@types/sinon": "^10.0.20",
Expand Down Expand Up @@ -153,7 +155,7 @@
"glob-gitignore": "^1.0.14",
"globby": "^14.0.1",
"html-webpack-plugin": "^5.6.0",
"jsdom": "23.1.0",
"jsdom": "24.1.0",
"jss": "^10.10.0",
"jss-plugin-template": "^10.10.0",
"jss-rtl": "^0.3.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/x-charts-pro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["mocha", "node", "@mui/material/themeCssVarsAugmentation"],
"types": [
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"chai-dom",
"mocha",
"node"
],
"noImplicitAny": false
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/x-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
}
},
"devDependencies": {
"@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
"@react-spring/core": "^9.7.3",
"@react-spring/shared": "^9.7.3",
"@types/d3-color": "^3.1.3",
Expand Down
10 changes: 8 additions & 2 deletions packages/x-charts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["mocha", "node", "@mui/material/themeCssVarsAugmentation"]
"types": [
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"chai-dom",
"mocha",
"node"
]
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"]
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts", "../../test/utils/init.ts"]
}
6 changes: 3 additions & 3 deletions packages/x-codemod/src/codemod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import childProcess from 'child_process';
import { promises as fs } from 'fs';
import path from 'path';
import yargs, { CommandModule } from 'yargs';
import yargs, { ArgumentsCamelCase, CommandModule } from 'yargs';

const jscodeshiftPackage = require('jscodeshift/package.json');

Expand Down Expand Up @@ -86,7 +86,7 @@ interface HandlerArgv extends Flags {
paths: string[];
}

function run(argv: yargs.ArgumentsCamelCase<HandlerArgv>) {
function run(argv: ArgumentsCamelCase<HandlerArgv>) {
const { codemod, paths, _: other, jscodeshift, parser } = argv;

return runTransform(
Expand All @@ -97,7 +97,7 @@ function run(argv: yargs.ArgumentsCamelCase<HandlerArgv>) {
);
}

yargs
yargs(process.argv.slice(2))
.command({
command: '$0 <codemod> <paths...>',
describe: 'Applies a `@mui/x-codemod` to the specified paths',
Expand Down
10 changes: 6 additions & 4 deletions packages/x-codemod/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": [
"mocha",
"node",
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"dayjs/plugin/utc.d.ts",
"chai-dom",
"dayjs/plugin/timezone.d.ts",
"moment-timezone"
"dayjs/plugin/utc.d.ts",
"mocha",
"moment-timezone",
"node"
],
"noImplicitAny": false
},
Expand Down
9 changes: 8 additions & 1 deletion packages/x-data-grid-generator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["react", "mocha", "node", "@mui/material/themeCssVarsAugmentation"]
"types": [
"@mui/internal-test-utils/initMatchers",
"@mui/material/themeCssVarsAugmentation",
"chai-dom",
"mocha",
"node",
"react"
]
},
"include": ["src/**/*"]
}
1 change: 1 addition & 0 deletions packages/x-data-grid-premium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"react-dom": "^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
"@types/prop-types": "^15.7.12",
"date-fns": "^2.30.0",
"rimraf": "^5.0.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, act } from '@mui-internal/test-utils';
import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import {
DataGridPremium as DataGrid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
within,
act,
fireEvent,
} from '@mui-internal/test-utils';
} from '@mui/internal-test-utils';
import { expect } from 'chai';
import { getCell, getColumnHeaderCell, getColumnValues } from 'test/utils/helperFn';
import { SinonSpy, spy } from 'sinon';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { stub, SinonStub } from 'sinon';
import { expect } from 'chai';
import { spyApi, getCell, grid } from 'test/utils/helperFn';
import { createRenderer, fireEvent, act, userEvent, screen } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, act, userEvent, screen } from '@mui/internal-test-utils';
import {
DataGridPremium,
DataGridPremiumProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GridColDef,
} from '@mui/x-data-grid-premium';
// @ts-ignore Remove once the test utils are typed
import { createRenderer, fireEvent, userEvent, waitFor } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, userEvent, waitFor } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { stub, SinonStub, spy } from 'sinon';
import { getCell, getColumnValues, sleep } from 'test/utils/helperFn';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { act, createRenderer, fireEvent } from '@mui-internal/test-utils';
import { act, createRenderer, fireEvent } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { DataGridPremium, gridClasses } from '@mui/x-data-grid-premium';
import { getCell, getColumnHeaderCell } from 'test/utils/helperFn';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DataGridPremiumProps,
GridActionsCellItem,
} from '@mui/x-data-grid-premium';
import { createRenderer, screen, fireEvent, act } from '@mui-internal/test-utils';
import { createRenderer, screen, fireEvent, act } from '@mui/internal-test-utils';
import { spy, SinonSpy } from 'sinon';
import { expect } from 'chai';
import Excel from 'exceljs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import addYears from 'date-fns/addYears';
import { expect } from 'chai';
import { createRenderer, screen, waitFor } from '@mui-internal/test-utils';
import { createRenderer, screen, waitFor } from '@mui/internal-test-utils';
import { DataGridPremium } from '@mui/x-data-grid-premium';
import { generateLicense, LicenseInfo } from '@mui/x-license';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
act,
userEvent,
waitFor,
} from '@mui-internal/test-utils';
} from '@mui/internal-test-utils';
import {
microtasks,
getColumnHeaderCell,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui/internal-test-utils';
import * as React from 'react';
import { expect } from 'chai';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GridRowsProp,
useGridApiRef,
} from '@mui/x-data-grid-premium';
import { createRenderer, act } from '@mui-internal/test-utils';
import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { getColumnValues } from 'test/utils/helperFn';

Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-premium/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["@mui/material/themeCssVarsAugmentation"]
"types": ["@mui/material/themeCssVarsAugmentation", "chai-dom", "mocha"]
},
"include": ["src/**/*"]
}
1 change: 1 addition & 0 deletions packages/x-data-grid-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"react-dom": "^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
"@types/prop-types": "^15.7.12",
"rimraf": "^5.0.7"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import axe from 'axe-core';
import { DataGridPro } from '@mui/x-data-grid-pro';
import { useBasicDemoData } from '@mui/x-data-grid-generator';
import { createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui/internal-test-utils';

function logViolations(violations: any) {
if (violations.length !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
GridCellModes,
} from '@mui/x-data-grid-pro';
import { getBasicGridData } from '@mui/x-data-grid-generator';
import { createRenderer, fireEvent, act, userEvent } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, act, userEvent } from '@mui/internal-test-utils';
import { getCell, spyApi } from 'test/utils/helperFn';

describe('<DataGridPro /> - Cell editing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { GridApi, useGridApiRef, DataGridPro, DataGridProProps } from '@mui/x-data-grid-pro';
import { createRenderer, fireEvent, act, userEvent } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, act, userEvent } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { stub, SinonStub } from 'sinon';
import { getCell } from 'test/utils/helperFn';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, fireEvent, screen } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, screen } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { gridClasses, DataGridPro, DataGridProProps } from '@mui/x-data-grid-pro';
import { getColumnHeaderCell, getColumnValues } from 'test/utils/helperFn';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
createEvent,
act,
userEvent,
} from '@mui-internal/test-utils';
} from '@mui/internal-test-utils';
import {
$,
$$,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, fireEvent, createEvent, act } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, createEvent, act } from '@mui/internal-test-utils';
import {
getColumnHeadersTextContent,
getColumnHeaderCell,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, fireEvent, act, userEvent } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, act, userEvent } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { DataGridPro, GridApi, useGridApiRef, GridColDef, gridClasses } from '@mui/x-data-grid-pro';
import { getActiveCell, getCell, getColumnHeaderCell } from 'test/utils/helperFn';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, fireEvent, screen, act } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, screen, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { spy } from 'sinon';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { spy } from 'sinon';
import { expect } from 'chai';
import { createRenderer, fireEvent, act } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, act } from '@mui/internal-test-utils';
import {
DataGridPro,
DataGridProProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, EventType, fireEvent, userEvent } from '@mui-internal/test-utils';
import { createRenderer, EventType, fireEvent, userEvent } from '@mui/internal-test-utils';
import { spy } from 'sinon';
import { expect } from 'chai';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
waitFor,
act,
userEvent,
} from '@mui-internal/test-utils';
} from '@mui/internal-test-utils';
import { $, $$, grid, getRow, getCell, getColumnValues, microtasks } from 'test/utils/helperFn';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
renderEditInputCell,
renderEditSingleSelectCell,
} from '@mui/x-data-grid-pro';
import { act, createRenderer, fireEvent, screen, userEvent } from '@mui-internal/test-utils';
import { act, createRenderer, fireEvent, screen, userEvent } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { getCell, spyApi } from 'test/utils/helperFn';
import { spy, SinonSpy } from 'sinon';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, fireEvent, screen, act } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, screen, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import {
DataGridPro,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GridApi,
DataGridProProps,
} from '@mui/x-data-grid-pro';
import { createRenderer, act } from '@mui-internal/test-utils';
import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import * as React from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GridApi,
useGridApiRef,
} from '@mui/x-data-grid-pro';
import { createRenderer, act } from '@mui-internal/test-utils';
import { createRenderer, act } from '@mui/internal-test-utils';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

Expand Down
Loading

0 comments on commit 7269ea0

Please sign in to comment.