@mui/internal-test-utils 2.0.16 → 2.0.18-canary.1
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/CHANGELOG.md +11 -3
- package/LICENSE +1 -1
- package/README.md +52 -6
- package/chaiPlugin.d.ts +0 -1
- package/chaiPlugin.js +47 -34
- package/components.js +2 -1
- package/configure.d.ts +9 -0
- package/configure.js +16 -0
- package/createDescribe.d.ts +10 -3
- package/createDescribe.js +11 -4
- package/createRenderer.d.ts +109 -107
- package/createRenderer.js +71 -52
- package/describeConformance.d.ts +1 -5
- package/describeConformance.js +13 -8
- package/env.d.ts +9 -1
- package/env.js +13 -3
- package/esm/chaiPlugin.d.ts +0 -1
- package/esm/chaiPlugin.js +46 -34
- package/esm/components.js +2 -1
- package/esm/configure.d.ts +9 -0
- package/esm/configure.js +9 -0
- package/esm/createDescribe.d.ts +10 -3
- package/esm/createDescribe.js +10 -2
- package/esm/createRenderer.d.ts +109 -107
- package/esm/createRenderer.js +53 -47
- package/esm/describeConformance.d.ts +1 -5
- package/esm/describeConformance.js +13 -8
- package/esm/env.d.ts +9 -1
- package/esm/env.js +11 -3
- package/esm/flushMicrotasks.d.ts +1 -1
- package/esm/flushMicrotasks.js +1 -1
- package/esm/index.d.ts +4 -12
- package/esm/index.js +6 -15
- package/esm/initMatchers.d.ts +5 -1
- package/esm/initMatchers.js +5 -2
- package/esm/setupVitest.d.ts +8 -1
- package/esm/setupVitest.js +87 -21
- package/flushMicrotasks.d.ts +1 -1
- package/flushMicrotasks.js +1 -1
- package/index.d.ts +4 -12
- package/index.js +13 -27
- package/initMatchers.d.ts +5 -1
- package/initMatchers.js +21 -2
- package/package.json +31 -20
- package/setupVitest.d.ts +8 -1
- package/setupVitest.js +93 -21
- package/createDOM.d.ts +0 -2
- package/createDOM.js +0 -49
- package/createRenderer.test.d.ts +0 -1
- package/esm/createDOM.d.ts +0 -2
- package/esm/createDOM.js +0 -47
- package/esm/createRenderer.test.d.ts +0 -1
- package/esm/fireDiscreteEvent.d.ts +0 -6
- package/esm/fireDiscreteEvent.js +0 -68
- package/esm/init.d.ts +0 -1
- package/esm/init.js +0 -13
- package/esm/initMatchers.test.d.ts +0 -1
- package/esm/reactMajor.d.ts +0 -2
- package/esm/reactMajor.js +0 -2
- package/esm/setup.d.ts +0 -1
- package/esm/setup.js +0 -8
- package/esm/setupVitestBrowser.d.ts +0 -1
- package/esm/setupVitestBrowser.js +0 -30
- package/fireDiscreteEvent.d.ts +0 -6
- package/fireDiscreteEvent.js +0 -79
- package/init.d.ts +0 -1
- package/init.js +0 -15
- package/initMatchers.test.d.ts +0 -1
- package/reactMajor.d.ts +0 -2
- package/reactMajor.js +0 -9
- package/setup.d.ts +0 -1
- package/setup.js +0 -10
- package/setupVitestBrowser.d.ts +0 -1
- package/setupVitestBrowser.js +0 -34
- /package/{chai.types.d.ts → chaiTypes.d.ts} +0 -0
- /package/{chai.types.js → chaiTypes.js} +0 -0
- /package/esm/{chai.types.d.ts → chaiTypes.d.ts} +0 -0
- /package/esm/{chai.types.js → chaiTypes.js} +0 -0
package/esm/env.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
3
2
|
export function isJsdom() {
|
|
4
3
|
return window.navigator.userAgent.includes('jsdom');
|
|
5
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export const reactMajor = parseInt(React.version, 10);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Set to true if console logs during [lifecycles that are invoked twice in `React.StrictMode`](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects) are suppressed.
|
|
9
|
+
* Useful for asserting on `console.warn` or `console.error` via `toErrorDev()`.
|
|
10
|
+
* TODO: Refactor to use reactMajor when fixing the React 17 cron test.
|
|
11
|
+
* https://github.com/mui/material-ui/issues/43153
|
|
12
|
+
*/
|
|
13
|
+
export const strictModeDoubleLoggingSuppressed = reactMajor === 17;
|
package/esm/flushMicrotasks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function flushMicrotasks(): Promise<void>;
|
package/esm/flushMicrotasks.js
CHANGED
package/esm/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import "./initMatchers.js";
|
|
1
2
|
export * from "./components.js";
|
|
2
3
|
export { default as describeConformance } from "./describeConformance.js";
|
|
3
4
|
export * from "./describeConformance.js";
|
|
4
5
|
export { default as createDescribe } from "./createDescribe.js";
|
|
5
6
|
export * from "./createRenderer.js";
|
|
6
7
|
export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
|
|
7
|
-
export {} from
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export { default as reactMajor } from "./reactMajor.js";
|
|
11
|
-
export * from "./env.js";
|
|
12
|
-
/**
|
|
13
|
-
* Set to true if console logs during [lifecycles that are invoked twice in `React.StrictMode`](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects) are suppressed.
|
|
14
|
-
* Useful for asserting on `console.warn` or `console.error` via `toErrorDev()`.
|
|
15
|
-
* TODO: Refactor to use reactMajor when fixing the React 17 cron test.
|
|
16
|
-
* https://github.com/mui/material-ui/issues/43153
|
|
17
|
-
*/
|
|
18
|
-
export declare const strictModeDoubleLoggingSuppressed: boolean;
|
|
8
|
+
export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
|
|
9
|
+
export { flushMicrotasks } from "./flushMicrotasks.js";
|
|
10
|
+
export * from "./env.js";
|
package/esm/index.js
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/internal-test-utils v2.0.
|
|
2
|
+
* @mui/internal-test-utils v2.0.17
|
|
3
3
|
*
|
|
4
4
|
* @license undefined
|
|
5
5
|
* This source code is licensed under the undefined license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import "./initMatchers.js";
|
|
9
9
|
export * from "./components.js";
|
|
10
10
|
export { default as describeConformance } from "./describeConformance.js";
|
|
11
11
|
export * from "./describeConformance.js";
|
|
12
12
|
export { default as createDescribe } from "./createDescribe.js";
|
|
13
13
|
export * from "./createRenderer.js";
|
|
14
14
|
export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export
|
|
19
|
-
export * from "./env.js";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Set to true if console logs during [lifecycles that are invoked twice in `React.StrictMode`](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects) are suppressed.
|
|
23
|
-
* Useful for asserting on `console.warn` or `console.error` via `toErrorDev()`.
|
|
24
|
-
* TODO: Refactor to use reactMajor when fixing the React 17 cron test.
|
|
25
|
-
* https://github.com/mui/material-ui/issues/43153
|
|
26
|
-
*/
|
|
27
|
-
export const strictModeDoubleLoggingSuppressed = React.version.startsWith('17');
|
|
15
|
+
// eslint-disable-next-line import/extensions
|
|
16
|
+
export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
|
|
17
|
+
export { flushMicrotasks } from "./flushMicrotasks.js";
|
|
18
|
+
export * from "./env.js";
|
package/esm/initMatchers.d.ts
CHANGED
package/esm/initMatchers.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
2
|
import chaiDom from 'chai-dom';
|
|
3
|
-
import "./
|
|
3
|
+
import "./chaiTypes.js";
|
|
4
4
|
import chaiPlugin from "./chaiPlugin.js";
|
|
5
5
|
chai.use(chaiDom);
|
|
6
|
-
chai.use(chaiPlugin);
|
|
6
|
+
chai.use(chaiPlugin);
|
|
7
|
+
|
|
8
|
+
// Make sure to export the chai instance and plugins for declarations
|
|
9
|
+
export { chai, chaiDom, chaiPlugin };
|
package/esm/setupVitest.d.ts
CHANGED
package/esm/setupVitest.js
CHANGED
|
@@ -1,28 +1,94 @@
|
|
|
1
1
|
import failOnConsole from 'vitest-fail-on-console';
|
|
2
2
|
import * as chai from 'chai';
|
|
3
|
-
import "./
|
|
3
|
+
import "./chaiTypes.js";
|
|
4
|
+
// eslint-disable-next-line import/extensions
|
|
5
|
+
import { cleanup, act } from '@testing-library/react/pure.js';
|
|
6
|
+
import { afterEach, vi } from 'vitest';
|
|
7
|
+
import chaiDom from 'chai-dom';
|
|
4
8
|
import chaiPlugin from "./chaiPlugin.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
import { configure } from "./configure.js";
|
|
10
|
+
let isInitialized = false;
|
|
11
|
+
export default function setupVitest({
|
|
12
|
+
failOnConsoleEnabled = true,
|
|
13
|
+
...config
|
|
14
|
+
} = {}) {
|
|
15
|
+
// When run in vitest with --no-isolate, the test hooks are cleared between each suite,
|
|
16
|
+
// but modules are only evaluated once, so calling it top-level would only register the
|
|
17
|
+
// hooks for the first suite only.
|
|
18
|
+
// Instead call `setupVitest` in one of the `setupFiles`, which are not cached and executed
|
|
19
|
+
// per suite.
|
|
20
|
+
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
if (vi.isFakeTimers()) {
|
|
23
|
+
await act(async () => {
|
|
24
|
+
vi.runOnlyPendingTimers();
|
|
25
|
+
});
|
|
19
26
|
}
|
|
27
|
+
vi.useRealTimers();
|
|
28
|
+
cleanup();
|
|
29
|
+
});
|
|
30
|
+
if (isInitialized) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
configure(config);
|
|
34
|
+
isInitialized = true;
|
|
35
|
+
|
|
36
|
+
// Don't call test lifecycle hooks after this point
|
|
37
|
+
|
|
38
|
+
chai.use(chaiPlugin);
|
|
39
|
+
if (failOnConsoleEnabled) {
|
|
40
|
+
failOnConsole({
|
|
41
|
+
silenceMessage: message => {
|
|
42
|
+
if (process.env.NODE_ENV === 'production') {
|
|
43
|
+
// TODO: mock scheduler
|
|
44
|
+
if (message.includes('act(...) is not supported in production builds of React')) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
|
|
49
|
+
// Controversial warning that is commonly ignored by switching to `useEffect` on the server.
|
|
50
|
+
// https://github.com/facebook/react/issues/14927
|
|
51
|
+
// However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Unclear why this is an issue for the current occurrences of this warning.
|
|
56
|
+
// TODO: Revisit once https://github.com/facebook/react/issues/22796 is resolved
|
|
57
|
+
if (message.includes('Detected multiple renderers concurrently rendering the same context provider.')) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (typeof window !== 'undefined') {
|
|
65
|
+
chai.use(chaiDom);
|
|
20
66
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
67
|
+
// Enable missing act warnings: https://github.com/reactwg/react-18/discussions/102
|
|
68
|
+
globalThis.jest = null;
|
|
69
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
70
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
71
|
+
// Not yet supported: https://github.com/jsdom/jsdom/issues/2152
|
|
72
|
+
globalThis.window.Touch ??= class Touch {
|
|
73
|
+
constructor(instance) {
|
|
74
|
+
this.instance = instance;
|
|
75
|
+
}
|
|
76
|
+
get identifier() {
|
|
77
|
+
return this.instance.identifier;
|
|
78
|
+
}
|
|
79
|
+
get pageX() {
|
|
80
|
+
return this.instance.pageX;
|
|
81
|
+
}
|
|
82
|
+
get pageY() {
|
|
83
|
+
return this.instance.pageY;
|
|
84
|
+
}
|
|
85
|
+
get clientX() {
|
|
86
|
+
return this.instance.clientX;
|
|
87
|
+
}
|
|
88
|
+
get clientY() {
|
|
89
|
+
return this.instance.clientY;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
25
92
|
}
|
|
26
|
-
return false;
|
|
27
93
|
}
|
|
28
|
-
}
|
|
94
|
+
}
|
package/flushMicrotasks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function flushMicrotasks(): Promise<void>;
|
package/flushMicrotasks.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.flushMicrotasks = flushMicrotasks;
|
|
7
7
|
var _createRenderer = require("./createRenderer");
|
|
8
8
|
async function flushMicrotasks() {
|
|
9
9
|
await (0, _createRenderer.act)(async () => {});
|
package/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import "./initMatchers.js";
|
|
1
2
|
export * from "./components.js";
|
|
2
3
|
export { default as describeConformance } from "./describeConformance.js";
|
|
3
4
|
export * from "./describeConformance.js";
|
|
4
5
|
export { default as createDescribe } from "./createDescribe.js";
|
|
5
6
|
export * from "./createRenderer.js";
|
|
6
7
|
export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
|
|
7
|
-
export {} from
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export { default as reactMajor } from "./reactMajor.js";
|
|
11
|
-
export * from "./env.js";
|
|
12
|
-
/**
|
|
13
|
-
* Set to true if console logs during [lifecycles that are invoked twice in `React.StrictMode`](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects) are suppressed.
|
|
14
|
-
* Useful for asserting on `console.warn` or `console.error` via `toErrorDev()`.
|
|
15
|
-
* TODO: Refactor to use reactMajor when fixing the React 17 cron test.
|
|
16
|
-
* https://github.com/mui/material-ui/issues/43153
|
|
17
|
-
*/
|
|
18
|
-
export declare const strictModeDoubleLoggingSuppressed: boolean;
|
|
8
|
+
export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
|
|
9
|
+
export { flushMicrotasks } from "./flushMicrotasks.js";
|
|
10
|
+
export * from "./env.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/internal-test-utils v2.0.
|
|
2
|
+
* @mui/internal-test-utils v2.0.17
|
|
3
3
|
*
|
|
4
4
|
* @license undefined
|
|
5
5
|
* This source code is licensed under the undefined license found in the
|
|
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
15
|
var _exportNames = {
|
|
16
|
-
strictModeDoubleLoggingSuppressed: true,
|
|
17
16
|
describeConformance: true,
|
|
18
17
|
createDescribe: true,
|
|
19
18
|
focusVisible: true,
|
|
@@ -21,8 +20,7 @@ var _exportNames = {
|
|
|
21
20
|
simulateKeyboardDevice: true,
|
|
22
21
|
programmaticFocusTriggersFocusVisible: true,
|
|
23
22
|
fireDiscreteEvent: true,
|
|
24
|
-
flushMicrotasks: true
|
|
25
|
-
reactMajor: true
|
|
23
|
+
flushMicrotasks: true
|
|
26
24
|
};
|
|
27
25
|
Object.defineProperty(exports, "createDescribe", {
|
|
28
26
|
enumerable: true,
|
|
@@ -36,11 +34,16 @@ Object.defineProperty(exports, "describeConformance", {
|
|
|
36
34
|
return _describeConformance.default;
|
|
37
35
|
}
|
|
38
36
|
});
|
|
39
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "fireDiscreteEvent", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _pure.fireEvent;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
40
43
|
Object.defineProperty(exports, "flushMicrotasks", {
|
|
41
44
|
enumerable: true,
|
|
42
45
|
get: function () {
|
|
43
|
-
return _flushMicrotasks.
|
|
46
|
+
return _flushMicrotasks.flushMicrotasks;
|
|
44
47
|
}
|
|
45
48
|
});
|
|
46
49
|
Object.defineProperty(exports, "focusVisible", {
|
|
@@ -55,12 +58,6 @@ Object.defineProperty(exports, "programmaticFocusTriggersFocusVisible", {
|
|
|
55
58
|
return _focusVisible.programmaticFocusTriggersFocusVisible;
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
|
-
Object.defineProperty(exports, "reactMajor", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return _reactMajor.default;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
61
|
Object.defineProperty(exports, "simulateKeyboardDevice", {
|
|
65
62
|
enumerable: true,
|
|
66
63
|
get: function () {
|
|
@@ -73,8 +70,7 @@ Object.defineProperty(exports, "simulatePointerDevice", {
|
|
|
73
70
|
return _focusVisible.simulatePointerDevice;
|
|
74
71
|
}
|
|
75
72
|
});
|
|
76
|
-
|
|
77
|
-
var React = _interopRequireWildcard(require("react"));
|
|
73
|
+
require("./initMatchers");
|
|
78
74
|
var _components = require("./components");
|
|
79
75
|
Object.keys(_components).forEach(function (key) {
|
|
80
76
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -113,11 +109,8 @@ Object.keys(_createRenderer).forEach(function (key) {
|
|
|
113
109
|
});
|
|
114
110
|
});
|
|
115
111
|
var _focusVisible = _interopRequireWildcard(require("./focusVisible"));
|
|
116
|
-
require("
|
|
117
|
-
var
|
|
118
|
-
exports.fireDiscreteEvent = _fireDiscreteEvent;
|
|
119
|
-
var _flushMicrotasks = _interopRequireDefault(require("./flushMicrotasks"));
|
|
120
|
-
var _reactMajor = _interopRequireDefault(require("./reactMajor"));
|
|
112
|
+
var _pure = require("@testing-library/react/pure.js");
|
|
113
|
+
var _flushMicrotasks = require("./flushMicrotasks");
|
|
121
114
|
var _env = require("./env");
|
|
122
115
|
Object.keys(_env).forEach(function (key) {
|
|
123
116
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -129,11 +122,4 @@ Object.keys(_env).forEach(function (key) {
|
|
|
129
122
|
return _env[key];
|
|
130
123
|
}
|
|
131
124
|
});
|
|
132
|
-
});
|
|
133
|
-
/**
|
|
134
|
-
* Set to true if console logs during [lifecycles that are invoked twice in `React.StrictMode`](https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects) are suppressed.
|
|
135
|
-
* Useful for asserting on `console.warn` or `console.error` via `toErrorDev()`.
|
|
136
|
-
* TODO: Refactor to use reactMajor when fixing the React 17 cron test.
|
|
137
|
-
* https://github.com/mui/material-ui/issues/43153
|
|
138
|
-
*/
|
|
139
|
-
const strictModeDoubleLoggingSuppressed = exports.strictModeDoubleLoggingSuppressed = React.version.startsWith('17');
|
|
125
|
+
});
|
package/initMatchers.d.ts
CHANGED
package/initMatchers.js
CHANGED
|
@@ -2,9 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.chai = void 0;
|
|
9
|
+
Object.defineProperty(exports, "chaiDom", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _chaiDom.default;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "chaiPlugin", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _chaiPlugin.default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
5
21
|
var chai = _interopRequireWildcard(require("chai"));
|
|
22
|
+
exports.chai = chai;
|
|
6
23
|
var _chaiDom = _interopRequireDefault(require("chai-dom"));
|
|
7
|
-
require("./
|
|
24
|
+
require("./chaiTypes");
|
|
8
25
|
var _chaiPlugin = _interopRequireDefault(require("./chaiPlugin"));
|
|
9
26
|
chai.use(_chaiDom.default);
|
|
10
|
-
chai.use(_chaiPlugin.default);
|
|
27
|
+
chai.use(_chaiPlugin.default);
|
|
28
|
+
|
|
29
|
+
// Make sure to export the chai instance and plugins for declarations
|
package/package.json
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-test-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18-canary.1",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Utilities for MUI tests. This is an internal package not meant for general use.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/mui/
|
|
9
|
-
"directory": "packages
|
|
8
|
+
"url": "git+https://github.com/mui/mui-public.git",
|
|
9
|
+
"directory": "packages/test-utils"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"@types/chai-dom": "^1.11.3",
|
|
12
13
|
"@babel/runtime": "^7.28.4",
|
|
13
|
-
"@emotion/cache": "^11.14.0",
|
|
14
|
-
"@emotion/react": "^11.14.0",
|
|
15
14
|
"@testing-library/dom": "^10.4.1",
|
|
16
|
-
"@testing-library/react": "^16.3.
|
|
15
|
+
"@testing-library/react": "^16.3.1",
|
|
17
16
|
"@testing-library/user-event": "^14.6.1",
|
|
18
17
|
"assertion-error": "^2.0.1",
|
|
19
18
|
"chai-dom": "^1.12.1",
|
|
20
|
-
"dom-accessibility-api": "^0.7.
|
|
21
|
-
"es-toolkit": "^1.
|
|
19
|
+
"dom-accessibility-api": "^0.7.1",
|
|
20
|
+
"es-toolkit": "^1.43.0",
|
|
22
21
|
"format-util": "^1.0.5",
|
|
23
22
|
"jsdom": "^26.1.0",
|
|
24
23
|
"prop-types": "^15.8.1",
|
|
25
|
-
"sinon": "^21.0.
|
|
24
|
+
"sinon": "^21.0.1",
|
|
25
|
+
"vitest-fail-on-console": "^0.10.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
+
"@emotion/cache": "11",
|
|
29
|
+
"@emotion/react": "11",
|
|
28
30
|
"@playwright/test": "^1.53.1",
|
|
29
31
|
"chai": "^4.5.0 || ^5.0.0 || ^6.0.0",
|
|
30
32
|
"react": "^18.0.0 || ^19.0.0",
|
|
31
33
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
32
34
|
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@emotion/cache": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"@emotion/react": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
33
43
|
"publishConfig": {
|
|
34
44
|
"access": "public"
|
|
35
45
|
},
|
|
@@ -68,16 +78,6 @@
|
|
|
68
78
|
"default": "./esm/createRenderer.js"
|
|
69
79
|
}
|
|
70
80
|
},
|
|
71
|
-
"./init": {
|
|
72
|
-
"require": {
|
|
73
|
-
"types": "./init.d.ts",
|
|
74
|
-
"default": "./init.js"
|
|
75
|
-
},
|
|
76
|
-
"default": {
|
|
77
|
-
"types": "./esm/init.d.ts",
|
|
78
|
-
"default": "./esm/init.js"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
81
|
"./initMatchers": {
|
|
82
82
|
"require": {
|
|
83
83
|
"types": "./initMatchers.d.ts",
|
|
@@ -88,6 +88,16 @@
|
|
|
88
88
|
"default": "./esm/initMatchers.js"
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
|
+
"./env": {
|
|
92
|
+
"require": {
|
|
93
|
+
"types": "./env.d.ts",
|
|
94
|
+
"default": "./env.js"
|
|
95
|
+
},
|
|
96
|
+
"default": {
|
|
97
|
+
"types": "./esm/env.d.ts",
|
|
98
|
+
"default": "./esm/env.js"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
91
101
|
"./initPlaywrightMatchers": {
|
|
92
102
|
"require": {
|
|
93
103
|
"types": "./initPlaywrightMatchers.d.ts",
|
|
@@ -119,5 +129,6 @@
|
|
|
119
129
|
}
|
|
120
130
|
},
|
|
121
131
|
"./esm": null
|
|
122
|
-
}
|
|
132
|
+
},
|
|
133
|
+
"gitSha": "7f5c7019e5ec5cc1413a5d6d22137941bba633c8"
|
|
123
134
|
}
|
package/setupVitest.d.ts
CHANGED
package/setupVitest.js
CHANGED
|
@@ -2,31 +2,103 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = setupVitest;
|
|
5
9
|
var _vitestFailOnConsole = _interopRequireDefault(require("vitest-fail-on-console"));
|
|
6
10
|
var chai = _interopRequireWildcard(require("chai"));
|
|
7
|
-
require("./
|
|
11
|
+
require("./chaiTypes");
|
|
12
|
+
var _pure = require("@testing-library/react/pure.js");
|
|
13
|
+
var _vitest = require("vitest");
|
|
14
|
+
var _chaiDom = _interopRequireDefault(require("chai-dom"));
|
|
8
15
|
var _chaiPlugin = _interopRequireDefault(require("./chaiPlugin"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
var _configure = require("./configure");
|
|
17
|
+
// eslint-disable-next-line import/extensions
|
|
18
|
+
|
|
19
|
+
let isInitialized = false;
|
|
20
|
+
function setupVitest({
|
|
21
|
+
failOnConsoleEnabled = true,
|
|
22
|
+
...config
|
|
23
|
+
} = {}) {
|
|
24
|
+
// When run in vitest with --no-isolate, the test hooks are cleared between each suite,
|
|
25
|
+
// but modules are only evaluated once, so calling it top-level would only register the
|
|
26
|
+
// hooks for the first suite only.
|
|
27
|
+
// Instead call `setupVitest` in one of the `setupFiles`, which are not cached and executed
|
|
28
|
+
// per suite.
|
|
29
|
+
|
|
30
|
+
(0, _vitest.afterEach)(async () => {
|
|
31
|
+
if (_vitest.vi.isFakeTimers()) {
|
|
32
|
+
await (0, _pure.act)(async () => {
|
|
33
|
+
_vitest.vi.runOnlyPendingTimers();
|
|
34
|
+
});
|
|
23
35
|
}
|
|
36
|
+
_vitest.vi.useRealTimers();
|
|
37
|
+
(0, _pure.cleanup)();
|
|
38
|
+
});
|
|
39
|
+
if (isInitialized) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
(0, _configure.configure)(config);
|
|
43
|
+
isInitialized = true;
|
|
44
|
+
|
|
45
|
+
// Don't call test lifecycle hooks after this point
|
|
46
|
+
|
|
47
|
+
chai.use(_chaiPlugin.default);
|
|
48
|
+
if (failOnConsoleEnabled) {
|
|
49
|
+
(0, _vitestFailOnConsole.default)({
|
|
50
|
+
silenceMessage: message => {
|
|
51
|
+
if (process.env.NODE_ENV === 'production') {
|
|
52
|
+
// TODO: mock scheduler
|
|
53
|
+
if (message.includes('act(...) is not supported in production builds of React')) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
|
|
58
|
+
// Controversial warning that is commonly ignored by switching to `useEffect` on the server.
|
|
59
|
+
// https://github.com/facebook/react/issues/14927
|
|
60
|
+
// However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Unclear why this is an issue for the current occurrences of this warning.
|
|
65
|
+
// TODO: Revisit once https://github.com/facebook/react/issues/22796 is resolved
|
|
66
|
+
if (message.includes('Detected multiple renderers concurrently rendering the same context provider.')) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (typeof window !== 'undefined') {
|
|
74
|
+
chai.use(_chaiDom.default);
|
|
24
75
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
76
|
+
// Enable missing act warnings: https://github.com/reactwg/react-18/discussions/102
|
|
77
|
+
globalThis.jest = null;
|
|
78
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
79
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
80
|
+
var _window;
|
|
81
|
+
// Not yet supported: https://github.com/jsdom/jsdom/issues/2152
|
|
82
|
+
(_window = globalThis.window).Touch ?? (_window.Touch = class Touch {
|
|
83
|
+
constructor(instance) {
|
|
84
|
+
this.instance = instance;
|
|
85
|
+
}
|
|
86
|
+
get identifier() {
|
|
87
|
+
return this.instance.identifier;
|
|
88
|
+
}
|
|
89
|
+
get pageX() {
|
|
90
|
+
return this.instance.pageX;
|
|
91
|
+
}
|
|
92
|
+
get pageY() {
|
|
93
|
+
return this.instance.pageY;
|
|
94
|
+
}
|
|
95
|
+
get clientX() {
|
|
96
|
+
return this.instance.clientX;
|
|
97
|
+
}
|
|
98
|
+
get clientY() {
|
|
99
|
+
return this.instance.clientY;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
29
102
|
}
|
|
30
|
-
return false;
|
|
31
103
|
}
|
|
32
|
-
}
|
|
104
|
+
}
|
package/createDOM.d.ts
DELETED