@mui/internal-test-utils 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/chai.types.d.ts +75 -0
- package/build/chai.types.d.ts.map +1 -0
- package/build/chai.types.js +3 -0
- package/build/chai.types.js.map +1 -0
- package/build/chaiPlugin.d.ts +5 -0
- package/build/chaiPlugin.d.ts.map +1 -0
- package/build/chaiPlugin.js +406 -0
- package/build/chaiPlugin.js.map +1 -0
- package/build/createDOM.js +4 -4
- package/build/createDOM.js.map +1 -1
- package/build/createRenderer.d.ts +37 -62
- package/build/createRenderer.d.ts.map +1 -1
- package/build/createRenderer.js +85 -40
- package/build/createRenderer.js.map +1 -1
- package/build/describeConformance.d.ts.map +1 -1
- package/build/describeConformance.js +28 -14
- package/build/describeConformance.js.map +1 -1
- package/build/describeSkipIf.d.ts +3 -0
- package/build/describeSkipIf.d.ts.map +1 -0
- package/build/describeSkipIf.js +10 -0
- package/build/describeSkipIf.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/initMatchers.d.ts +1 -74
- package/build/initMatchers.d.ts.map +1 -1
- package/build/initMatchers.js +4 -400
- package/build/initMatchers.js.map +1 -1
- package/build/initMatchers.test.js +4 -6
- package/build/initMatchers.test.js.map +1 -1
- package/build/mochaHooks.test.js +5 -1
- package/build/mochaHooks.test.js.map +1 -1
- package/build/setupJSDOM.js +2 -2
- package/build/setupJSDOM.js.map +1 -1
- package/build/setupVitest.d.ts +2 -0
- package/build/setupVitest.d.ts.map +1 -0
- package/build/setupVitest.js +121 -0
- package/build/setupVitest.js.map +1 -0
- package/package.json +6 -4
- package/src/chai.types.ts +106 -0
- package/src/chaiPlugin.ts +512 -0
- package/src/createDOM.js +4 -4
- package/src/createRenderer.tsx +106 -51
- package/src/describeConformance.tsx +28 -16
- package/src/describeSkipIf.tsx +9 -0
- package/src/index.ts +1 -0
- package/src/initMatchers.test.js +4 -6
- package/src/initMatchers.ts +4 -615
- package/src/mochaHooks.test.js +2 -1
- package/src/setupJSDOM.js +2 -2
- package/src/setupVitest.ts +117 -0
- package/tsconfig.json +5 -2
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const vitest_1 = require("vitest");
|
|
30
|
+
const testingLibrary = __importStar(require("@testing-library/dom"));
|
|
31
|
+
const vitest_fail_on_console_1 = __importDefault(require("vitest-fail-on-console"));
|
|
32
|
+
require("./initMatchers");
|
|
33
|
+
// checking if an element is hidden is quite expensive
|
|
34
|
+
// this is only done in CI as a fail safe. It can still explicitly be checked
|
|
35
|
+
// in the test files which helps documenting what is part of the DOM but hidden
|
|
36
|
+
// from assistive technology
|
|
37
|
+
const defaultHidden = !process.env.CI;
|
|
38
|
+
// adds verbosity for something that might be confusing
|
|
39
|
+
console.warn(`${defaultHidden ? 'including' : 'excluding'} inaccessible elements by default`);
|
|
40
|
+
testingLibrary.configure({
|
|
41
|
+
// JSDOM logs errors otherwise on `getComputedStyle(element, pseudoElement)` calls.
|
|
42
|
+
computedStyleSupportsPseudoElements: false,
|
|
43
|
+
defaultHidden,
|
|
44
|
+
});
|
|
45
|
+
// Enable missing act warnings: https://github.com/reactwg/react-18/discussions/102
|
|
46
|
+
globalThis.jest = null;
|
|
47
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
48
|
+
(0, vitest_fail_on_console_1.default)({
|
|
49
|
+
silenceMessage: (message) => {
|
|
50
|
+
if (process.env.NODE_ENV === 'production') {
|
|
51
|
+
// TODO: mock scheduler
|
|
52
|
+
if (message.includes('act(...) is not supported in production builds of React')) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
|
|
57
|
+
// Controversial warning that is commonly ignored by switching to `useEffect` on the server.
|
|
58
|
+
// https://github.com/facebook/react/issues/14927
|
|
59
|
+
// However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
// Unclear why this is an issue for the current occurrences of this warning.
|
|
63
|
+
// TODO: Revisit once https://github.com/facebook/react/issues/22796 is resolved
|
|
64
|
+
if (message.includes('Detected multiple renderers concurrently rendering the same context provider.')) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
function wrapIt(itFn) {
|
|
71
|
+
return function wrapper(name, fn) {
|
|
72
|
+
return itFn(name, (context) => {
|
|
73
|
+
return fn?.call({
|
|
74
|
+
...context,
|
|
75
|
+
currentTest: {
|
|
76
|
+
fullTitle: () => context.task.name,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const wrappedIt = wrapIt(vitest_1.it);
|
|
83
|
+
wrappedIt.skip = wrapIt(vitest_1.it.skip);
|
|
84
|
+
wrappedIt.only = wrapIt(vitest_1.it.only);
|
|
85
|
+
globalThis.it = wrappedIt;
|
|
86
|
+
if (!globalThis.before) {
|
|
87
|
+
globalThis.before = vitest_1.beforeAll;
|
|
88
|
+
}
|
|
89
|
+
if (!globalThis.after) {
|
|
90
|
+
globalThis.after = vitest_1.afterAll;
|
|
91
|
+
}
|
|
92
|
+
if (!globalThis.specify) {
|
|
93
|
+
globalThis.specify = wrappedIt;
|
|
94
|
+
}
|
|
95
|
+
const isJsdom = typeof window !== 'undefined' && window.navigator.userAgent.includes('jsdom');
|
|
96
|
+
// Only necessary when not in browser mode.
|
|
97
|
+
if (isJsdom) {
|
|
98
|
+
class Touch {
|
|
99
|
+
constructor(instance) {
|
|
100
|
+
this.instance = instance;
|
|
101
|
+
}
|
|
102
|
+
get identifier() {
|
|
103
|
+
return this.instance.identifier;
|
|
104
|
+
}
|
|
105
|
+
get pageX() {
|
|
106
|
+
return this.instance.pageX;
|
|
107
|
+
}
|
|
108
|
+
get pageY() {
|
|
109
|
+
return this.instance.pageY;
|
|
110
|
+
}
|
|
111
|
+
get clientX() {
|
|
112
|
+
return this.instance.clientX;
|
|
113
|
+
}
|
|
114
|
+
get clientY() {
|
|
115
|
+
return this.instance.clientY;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// @ts-expect-error
|
|
119
|
+
globalThis.window.Touch = Touch;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=setupVitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupVitest.js","sourceRoot":"","sources":["../src/setupVitest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiD;AACjD,qEAAuD;AACvD,oFAAmD;AACnD,0BAAwB;AAExB,sDAAsD;AACtD,6EAA6E;AAC7E,+EAA+E;AAC/E,4BAA4B;AAC5B,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAEtC,uDAAuD;AACvD,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,mCAAmC,CAAC,CAAC;AAE9F,cAAc,CAAC,SAAS,CAAC;IACvB,mFAAmF;IACnF,mCAAmC,EAAE,KAAK;IAC1C,aAAa;CACd,CAAC,CAAC;AAEH,mFAAmF;AAClF,UAAkB,CAAC,IAAI,GAAG,IAAI,CAAC;AAC/B,UAAkB,CAAC,wBAAwB,GAAG,IAAI,CAAC;AAEpD,IAAA,gCAAa,EAAC;IACZ,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE;QAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC1C,uBAAuB;YACvB,IAAI,OAAO,CAAC,QAAQ,CAAC,yDAAyD,CAAC,EAAE,CAAC;gBAChF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,qDAAqD,CAAC,EAAE,CAAC;YAC5E,4FAA4F;YAC5F,iDAAiD;YACjD,sHAAsH;YACtH,OAAO,IAAI,CAAC;QACd,CAAC;QAED,4EAA4E;QAC5E,gFAAgF;QAChF,IACE,OAAO,CAAC,QAAQ,CACd,+EAA+E,CAChF,EACD,CAAC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QAAQ,CAAC;QAC3B,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAClC,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,CAAC;KACF;IACD,mBAAmB;IACnB,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-test-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Utilities for MUI tests. This is an internal package not meant for general use.",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"./setupBabel": "./build/setupBabel.js",
|
|
22
22
|
"./setupBabelPlaywright": "./build/setupBabelPlaywright.js",
|
|
23
23
|
"./setupJSDOM": "./build/setupJSDOM.js",
|
|
24
|
-
"./setupKarma": "./build/setupKarma.js"
|
|
24
|
+
"./setupKarma": "./build/setupKarma.js",
|
|
25
|
+
"./chaiPlugin": "./build/chaiPlugin.js",
|
|
26
|
+
"./setupVitest": "./build/setupVitest.js"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
|
|
@@ -40,10 +42,10 @@
|
|
|
40
42
|
"fs-extra": "^11.2.0",
|
|
41
43
|
"jsdom": "^24.0.0",
|
|
42
44
|
"lodash": "^4.17.21",
|
|
43
|
-
"mocha": "^10.
|
|
45
|
+
"mocha": "^10.8.2",
|
|
44
46
|
"playwright": "^1.48.2",
|
|
45
47
|
"prop-types": "^15.8.1",
|
|
46
|
-
"sinon": "^
|
|
48
|
+
"sinon": "^19.0.2"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@types/chai": "^4.3.20",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
// https://stackoverflow.com/a/46755166/3406963
|
|
4
|
+
declare global {
|
|
5
|
+
namespace Chai {
|
|
6
|
+
interface Assertion {
|
|
7
|
+
/**
|
|
8
|
+
* Checks `expectedStyle` is a subset of the elements inline style i.e. `element.style`.
|
|
9
|
+
* @example expect(element).toHaveInlineStyle({ width: '200px' })
|
|
10
|
+
*/
|
|
11
|
+
toHaveInlineStyle(
|
|
12
|
+
expectedStyle: Partial<
|
|
13
|
+
Record<
|
|
14
|
+
Exclude<
|
|
15
|
+
keyof CSSStyleDeclaration,
|
|
16
|
+
| 'getPropertyPriority'
|
|
17
|
+
| 'getPropertyValue'
|
|
18
|
+
| 'item'
|
|
19
|
+
| 'removeProperty'
|
|
20
|
+
| 'setProperty'
|
|
21
|
+
| number
|
|
22
|
+
>,
|
|
23
|
+
string
|
|
24
|
+
>
|
|
25
|
+
>,
|
|
26
|
+
): void;
|
|
27
|
+
/**
|
|
28
|
+
* Checks `expectedStyle` is a subset of the elements computed style i.e. `window.getComputedStyle(element)`.
|
|
29
|
+
* @example expect(element).toHaveComputedStyle({ width: '200px' })
|
|
30
|
+
*/
|
|
31
|
+
toHaveComputedStyle(
|
|
32
|
+
expectedStyle: Partial<
|
|
33
|
+
Record<
|
|
34
|
+
Exclude<
|
|
35
|
+
keyof CSSStyleDeclaration,
|
|
36
|
+
| 'getPropertyPriority'
|
|
37
|
+
| 'getPropertyValue'
|
|
38
|
+
| 'item'
|
|
39
|
+
| 'removeProperty'
|
|
40
|
+
| 'setProperty'
|
|
41
|
+
| number
|
|
42
|
+
>,
|
|
43
|
+
string
|
|
44
|
+
>
|
|
45
|
+
>,
|
|
46
|
+
): void;
|
|
47
|
+
/**
|
|
48
|
+
* Check if an element's [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) is not `hidden` or `collapsed`.
|
|
49
|
+
*/
|
|
50
|
+
toBeVisible(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Check if an element's [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) is `hidden` or `collapsed`.
|
|
53
|
+
*/
|
|
54
|
+
toBeHidden(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if the element is inaccessible.
|
|
57
|
+
*
|
|
58
|
+
* Elements are considered inaccessible if they either:
|
|
59
|
+
* - have [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) `hidden`
|
|
60
|
+
* - have [`display`](https://developer.mozilla.org/en-US/docs/Web/CSS/display) `none`
|
|
61
|
+
* - have `aria-hidden` `true` or any of their parents
|
|
62
|
+
*
|
|
63
|
+
* @see [Excluding Elements from the Accessibility Tree](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion)
|
|
64
|
+
*/
|
|
65
|
+
toBeInaccessible(): void;
|
|
66
|
+
toHaveAccessibleDescription(description: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if the accessible name computation (according to `accname` spec)
|
|
69
|
+
* matches the expectation.
|
|
70
|
+
*
|
|
71
|
+
* @see https://www.w3.org/TR/accname-1.2/
|
|
72
|
+
* @param name
|
|
73
|
+
*/
|
|
74
|
+
toHaveAccessibleName(name: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the element is actually focused i.e. `document.activeElement` is equal to the actual element.
|
|
77
|
+
*/
|
|
78
|
+
toHaveFocus(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the element is the active-descendant of the active element.
|
|
81
|
+
*/
|
|
82
|
+
toHaveVirtualFocus(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Matches calls to `console.warn` in the asserted callback.
|
|
85
|
+
*
|
|
86
|
+
* @example expect(() => render()).not.toWarnDev()
|
|
87
|
+
* @example expect(() => render()).toWarnDev('single message')
|
|
88
|
+
* @example expect(() => render()).toWarnDev(['first warning', 'then the second'])
|
|
89
|
+
*/
|
|
90
|
+
toWarnDev(messages?: string | readonly (string | boolean)[]): void;
|
|
91
|
+
/**
|
|
92
|
+
* Matches calls to `console.error` in the asserted callback.
|
|
93
|
+
*
|
|
94
|
+
* @example expect(() => render()).not.toErrorDev()
|
|
95
|
+
* @example expect(() => render()).toErrorDev('single message')
|
|
96
|
+
* @example expect(() => render()).toErrorDev(['first warning', 'then the second'])
|
|
97
|
+
*/
|
|
98
|
+
toErrorDev(messages?: string | readonly (string | boolean)[]): void;
|
|
99
|
+
/**
|
|
100
|
+
* Asserts that the given callback throws an error matching the given message in development (process.env.NODE_ENV !== 'production').
|
|
101
|
+
* In production it expects a minified error.
|
|
102
|
+
*/
|
|
103
|
+
toThrowMinified(message: string): void;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|