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

[code-infra] Changes for test util to work in vitest #43625

Merged
merged 55 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d69264c
Make createRenderer compliant with vitest
JCQuintas Sep 4, 2024
31326f9
Make describeConformance compliant with vitest
JCQuintas Sep 4, 2024
4db459c
Warning becomes too verbose
JCQuintas Sep 4, 2024
456df29
global this
JCQuintas Sep 5, 2024
76edd75
Fix chai matchers
JCQuintas Sep 5, 2024
5bea067
Merge commit '2ad38e3044063e60bdad98618997233b27383001' into vitest-c…
JCQuintas Sep 5, 2024
2a7343c
fix lint
JCQuintas Sep 5, 2024
c60515e
Fix mocha done
JCQuintas Sep 5, 2024
63115f5
add mocha types
JCQuintas Sep 5, 2024
e7e755b
Replace tobeundefined with tobenull
JCQuintas Sep 5, 2024
917dd25
separately export chai plugins
JCQuintas Sep 10, 2024
41cbeea
Revert "Fix chai matchers"
JCQuintas Sep 10, 2024
5fd0830
Merge commit 'dbc95b46cb0eff128872927aa3efcb9410fc46c6' into vitest-c…
JCQuintas Sep 10, 2024
8157404
Use vitest internal fake timers
JCQuintas Sep 11, 2024
0e74f56
only run useRealTimers if config
JCQuintas Sep 11, 2024
ae23bac
Invert running timers
JCQuintas Sep 11, 2024
bbd6fdd
Merge commit '94cc3d0a66456713e6e25edf9a1ba35ad8df88bc' into vitest-c…
JCQuintas Sep 11, 2024
ed66a3e
JCQuintas Sep 11, 2024
2284ad6
Merge commit 'e513ea36330c5222855130c8e3e6827901837f31' into vitest-c…
JCQuintas Sep 13, 2024
0648e94
Merge commit 'be68b0913c61eae68175c0b8d79c1b032fa383e4' into vitest-c…
JCQuintas Oct 4, 2024
e9f9582
Some updates
Janpot Oct 4, 2024
442770a
updates
Janpot Oct 5, 2024
4e4cf78
tweaks
Janpot Oct 5, 2024
ba7fd91
Update ButtonBase.test.js
Janpot Oct 5, 2024
9e8711c
fwfwr
Janpot Oct 5, 2024
e019f1a
Merge remote-tracking branch 'upstream/master' into pr/43625
Janpot Oct 7, 2024
d2b3f7f
tweaks
Janpot Oct 8, 2024
ccb3dd5
Update pnpm-lock.yaml
Janpot Oct 8, 2024
9e3c284
remove troublesome deprecated queries
JCQuintas Oct 8, 2024
a105b2a
Browser tests
Janpot Oct 9, 2024
39dc4f6
Update pnpm-lock.yaml
Janpot Oct 9, 2024
7db34a1
Merge remote-tracking branch 'upstream/master' into pr/43625
Janpot Oct 9, 2024
199bbef
Add describeSkipIf shim to test-utils
Janpot Oct 9, 2024
73c5415
Fix sequence
Janpot Oct 9, 2024
110d779
Update createRenderer.tsx
Janpot Oct 9, 2024
b67121a
Update setupVitest.ts
Janpot Oct 9, 2024
92c2399
Merge commit 'e802a736705e54e337f6f4ac165022465c61cc8c' into vitest-c…
JCQuintas Oct 14, 2024
6afd7c4
Expand tests
Janpot Oct 17, 2024
6224e16
Create vitest.config.ts
Janpot Oct 17, 2024
6e1c0a5
initMatchers
Janpot Oct 17, 2024
e512880
Update vitest.workspace.ts
Janpot Oct 17, 2024
d503f30
builder fixes
Janpot Oct 17, 2024
d4e0b02
wef
Janpot Oct 17, 2024
6baab86
Update builder.test.mjs
Janpot Oct 17, 2024
b6ab66d
Merge remote-tracking branch 'upstream/master' into pr/43625
Janpot Oct 17, 2024
7682b52
Update builder.test.mjs
Janpot Oct 17, 2024
eca4283
tests
Janpot Oct 17, 2024
f30b9a1
more tests
Janpot Oct 17, 2024
370470d
fix typescript
Janpot Oct 18, 2024
4eef12a
Merge remote-tracking branch 'upstream/master' into pr/43625
Janpot Oct 18, 2024
b955b6f
Merge commit '0ceedb8bc1f2f3bad9c6adf5a9d8f97a45a3c8b3' into vitest-c…
JCQuintas Nov 5, 2024
9aafe1d
add vitestSetup export
JCQuintas Nov 5, 2024
ef00405
Revert test changes
JCQuintas Nov 5, 2024
34e8231
deduped
JCQuintas Nov 5, 2024
dd8ee60
fix typescript
JCQuintas Nov 5, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED = [
module.exports = /** @type {Config} */ ({
root: true, // So parent files don't get applied
env: {
es6: true,
es2020: true,
browser: true,
node: true,
},
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = function getBabelConfig(api) {
'@mui/utils': resolveAliasPath('./packages/mui-utils/src'),
'@mui/joy': resolveAliasPath('./packages/mui-joy/src'),
'@mui/internal-docs-utils': resolveAliasPath('./packages-internal/docs-utils/src'),
'@mui/internal-test-utils': resolveAliasPath('./packages-internal/test-utils/src'),
docs: resolveAliasPath('./docs'),
test: resolveAliasPath('./test'),
};
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitest/browser": "^2.1.2",
"@vitest/coverage-v8": "^2.1.2",
"babel-loader": "^9.2.1",
"babel-plugin-istanbul": "^7.0.0",
"babel-plugin-module-resolver": "^5.0.2",
Expand Down Expand Up @@ -192,6 +194,8 @@
"terser-webpack-plugin": "^5.3.10",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"vitest": "^2.1.2",
"vitest-fail-on-console": "^0.7.1",
"webpack": "^5.96.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
Expand Down
4 changes: 3 additions & 1 deletion packages-internal/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"./setupBabel": "./build/setupBabel.js",
"./setupBabelPlaywright": "./build/setupBabelPlaywright.js",
"./setupJSDOM": "./build/setupJSDOM.js",
"./setupKarma": "./build/setupKarma.js"
"./setupKarma": "./build/setupKarma.js",
"./chaiPlugin": "./build/chaiPlugin.js",
"./setupVitest": "./build/setupVitest.js"
},
"scripts": {
"prebuild": "rimraf ./build",
Expand Down
106 changes: 106 additions & 0 deletions packages-internal/test-utils/src/chai.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
export {};

// https://stackoverflow.com/a/46755166/3406963
declare global {
namespace Chai {
interface Assertion {
/**
* Checks `expectedStyle` is a subset of the elements inline style i.e. `element.style`.
* @example expect(element).toHaveInlineStyle({ width: '200px' })
*/
toHaveInlineStyle(
expectedStyle: Partial<
Record<
Exclude<
keyof CSSStyleDeclaration,
| 'getPropertyPriority'
| 'getPropertyValue'
| 'item'
| 'removeProperty'
| 'setProperty'
| number
>,
string
>
>,
): void;
/**
* Checks `expectedStyle` is a subset of the elements computed style i.e. `window.getComputedStyle(element)`.
* @example expect(element).toHaveComputedStyle({ width: '200px' })
*/
toHaveComputedStyle(
expectedStyle: Partial<
Record<
Exclude<
keyof CSSStyleDeclaration,
| 'getPropertyPriority'
| 'getPropertyValue'
| 'item'
| 'removeProperty'
| 'setProperty'
| number
>,
string
>
>,
): void;
/**
* Check if an element's [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) is not `hidden` or `collapsed`.
*/
toBeVisible(): void;
/**
* Check if an element's [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) is `hidden` or `collapsed`.
*/
toBeHidden(): void;
/**
* Checks if the element is inaccessible.
*
* Elements are considered inaccessible if they either:
* - have [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) `hidden`
* - have [`display`](https://developer.mozilla.org/en-US/docs/Web/CSS/display) `none`
* - have `aria-hidden` `true` or any of their parents
*
* @see [Excluding Elements from the Accessibility Tree](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion)
*/
toBeInaccessible(): void;
toHaveAccessibleDescription(description: string): void;
/**
* Checks if the accessible name computation (according to `accname` spec)
* matches the expectation.
*
* @see https://www.w3.org/TR/accname-1.2/
* @param name
*/
toHaveAccessibleName(name: string): void;
/**
* Checks if the element is actually focused i.e. `document.activeElement` is equal to the actual element.
*/
toHaveFocus(): void;
/**
* Checks if the element is the active-descendant of the active element.
*/
toHaveVirtualFocus(): void;
/**
* Matches calls to `console.warn` in the asserted callback.
*
* @example expect(() => render()).not.toWarnDev()
* @example expect(() => render()).toWarnDev('single message')
* @example expect(() => render()).toWarnDev(['first warning', 'then the second'])
*/
toWarnDev(messages?: string | readonly (string | boolean)[]): void;
/**
* Matches calls to `console.error` in the asserted callback.
*
* @example expect(() => render()).not.toErrorDev()
* @example expect(() => render()).toErrorDev('single message')
* @example expect(() => render()).toErrorDev(['first warning', 'then the second'])
*/
toErrorDev(messages?: string | readonly (string | boolean)[]): void;
/**
* Asserts that the given callback throws an error matching the given message in development (process.env.NODE_ENV !== 'production').
* In production it expects a minified error.
*/
toThrowMinified(message: string): void;
}
}
}
Loading