@mui/internal-test-utils 2.0.18-canary.3 → 2.0.18-canary.30

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.
Files changed (47) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -14
  3. package/chaiPlugin.d.mts +3 -0
  4. package/chaiPlugin.d.ts +1 -1
  5. package/chaiPlugin.js +1 -1
  6. package/{esm/chaiPlugin.js → chaiPlugin.mjs} +2 -2
  7. package/{esm/createRenderer.d.ts → createRenderer.d.mts} +11 -10
  8. package/createRenderer.d.ts +10 -9
  9. package/{esm/createRenderer.js → createRenderer.mjs} +3 -3
  10. package/{esm/describeConformance.d.ts → describeConformance.d.mts} +2 -20
  11. package/describeConformance.d.ts +1 -19
  12. package/describeConformance.js +2 -173
  13. package/{esm/describeConformance.js → describeConformance.mjs} +4 -175
  14. package/{esm/flushMicrotasks.js → flushMicrotasks.mjs} +1 -1
  15. package/{esm/focusVisible.js → focusVisible.mjs} +1 -1
  16. package/index.d.mts +11 -0
  17. package/index.js +2 -2
  18. package/index.mjs +19 -0
  19. package/initMatchers.d.mts +5 -0
  20. package/{esm/initMatchers.js → initMatchers.mjs} +2 -2
  21. package/{esm/initPlaywrightMatchers.d.ts → initPlaywrightMatchers.d.mts} +1 -1
  22. package/initPlaywrightMatchers.d.ts +1 -1
  23. package/package.json +57 -27
  24. package/{esm/setupVitest.d.ts → setupVitest.d.mts} +2 -2
  25. package/setupVitest.d.ts +1 -1
  26. package/setupVitest.js +13 -11
  27. package/{esm/setupVitest.js → setupVitest.mjs} +16 -14
  28. package/esm/chaiPlugin.d.ts +0 -3
  29. package/esm/index.d.ts +0 -11
  30. package/esm/index.js +0 -19
  31. package/esm/initMatchers.d.ts +0 -5
  32. package/esm/package.json +0 -1
  33. /package/{esm/chaiTypes.d.ts → chaiTypes.d.mts} +0 -0
  34. /package/{esm/chaiTypes.js → chaiTypes.mjs} +0 -0
  35. /package/{esm/components.d.ts → components.d.mts} +0 -0
  36. /package/{esm/components.js → components.mjs} +0 -0
  37. /package/{esm/configure.d.ts → configure.d.mts} +0 -0
  38. /package/{esm/configure.js → configure.mjs} +0 -0
  39. /package/{esm/createDescribe.d.ts → createDescribe.d.mts} +0 -0
  40. /package/{esm/createDescribe.js → createDescribe.mjs} +0 -0
  41. /package/{esm/env.d.ts → env.d.mts} +0 -0
  42. /package/{esm/env.js → env.mjs} +0 -0
  43. /package/{esm/flushMicrotasks.d.ts → flushMicrotasks.d.mts} +0 -0
  44. /package/{esm/focusVisible.d.ts → focusVisible.d.mts} +0 -0
  45. /package/{esm/ignoreActWarnings.d.ts → ignoreActWarnings.d.mts} +0 -0
  46. /package/{esm/ignoreActWarnings.js → ignoreActWarnings.mjs} +0 -0
  47. /package/{esm/initPlaywrightMatchers.js → initPlaywrightMatchers.mjs} +0 -0
@@ -1,12 +1,9 @@
1
1
  import { expect } from 'chai';
2
2
  import * as React from 'react';
3
3
  import { describe, it, afterAll, afterEach, beforeEach } from 'vitest';
4
- import createDescribe from "./createDescribe.js";
5
- import { isJsdom } from "./env.js";
4
+ import createDescribe from "./createDescribe.mjs";
5
+ import { isJsdom } from "./env.mjs";
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- function capitalize(string) {
8
- return string.charAt(0).toUpperCase() + string.slice(1);
9
- }
10
7
  /**
11
8
  * Glossary
12
9
  * - root component:
@@ -197,8 +194,7 @@ function forEachSlot(slots, callback) {
197
194
  function testSlotsProp(element, getOptions) {
198
195
  const {
199
196
  render,
200
- slots,
201
- testLegacyComponentsProp
197
+ slots
202
198
  } = getOptions();
203
199
  const CustomComponent = /*#__PURE__*/React.forwardRef(({
204
200
  className,
@@ -260,107 +256,12 @@ function testSlotsProp(element, getOptions) {
260
256
  }
261
257
  });
262
258
  }
263
-
264
- // For testing Material UI components v5, and v6. Likely to be removed in a future major release.
265
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
266
- it(`allows overriding the ${slotName} slot with a component using the components.${capitalize(slotName)} prop`, async () => {
267
- if (!render) {
268
- throwMissingPropError('render');
269
- }
270
- const slotComponent = slotOptions.testWithComponent ?? CustomComponent;
271
- const components = {
272
- [capitalize(slotName)]: slotComponent
273
- };
274
- const {
275
- queryByTestId
276
- } = await render(/*#__PURE__*/React.cloneElement(element, {
277
- components
278
- }));
279
- const renderedElement = queryByTestId('custom');
280
- expect(renderedElement).not.to.equal(null);
281
- if (slotOptions.expectedClassName) {
282
- expect(renderedElement).to.have.class(slotOptions.expectedClassName);
283
- }
284
- });
285
- it(`prioritizes the 'slots.${slotName}' over components.${capitalize(slotName)} if both are defined`, async () => {
286
- if (!render) {
287
- throwMissingPropError('render');
288
- }
289
- const ComponentForComponentsProp = /*#__PURE__*/React.forwardRef(({
290
- children
291
- }, ref) => {
292
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
293
- return /*#__PURE__*/_jsx(SlotComponent, {
294
- ref: ref,
295
- "data-testid": "from-components",
296
- children: children
297
- });
298
- });
299
- if (process.env.NODE_ENV !== "production") ComponentForComponentsProp.displayName = "ComponentForComponentsProp";
300
- const ComponentForSlotsProp = /*#__PURE__*/React.forwardRef(({
301
- children
302
- }, ref) => {
303
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
304
- return /*#__PURE__*/_jsx(SlotComponent, {
305
- ref: ref,
306
- "data-testid": "from-slots",
307
- children: children
308
- });
309
- });
310
- if (process.env.NODE_ENV !== "production") ComponentForSlotsProp.displayName = "ComponentForSlotsProp";
311
- const components = {
312
- [capitalize(slotName)]: ComponentForComponentsProp
313
- };
314
- const slotOverrides = {
315
- [slotName]: ComponentForSlotsProp
316
- };
317
- const {
318
- queryByTestId
319
- } = await render(/*#__PURE__*/React.cloneElement(element, {
320
- components,
321
- slots: slotOverrides
322
- }));
323
- expect(queryByTestId('from-slots')).not.to.equal(null);
324
- expect(queryByTestId('from-components')).to.equal(null);
325
- });
326
- if (slotOptions.testWithElement !== null) {
327
- it(`allows overriding the ${slotName} slot with an element using the components.${capitalize(slotName)} prop`, async () => {
328
- if (!render) {
329
- throwMissingPropError('render');
330
- }
331
- const slotElement = slotOptions.testWithElement ?? 'i';
332
- const components = {
333
- [capitalize(slotName)]: slotElement
334
- };
335
- const componentsProps = {
336
- [slotName]: {
337
- 'data-testid': 'customized'
338
- }
339
- };
340
- const {
341
- queryByTestId
342
- } = await render(/*#__PURE__*/React.cloneElement(element, {
343
- components,
344
- componentsProps
345
- }));
346
- const renderedElement = queryByTestId('customized');
347
- expect(renderedElement).not.to.equal(null);
348
- if (typeof slotElement === 'string') {
349
- expect(renderedElement.nodeName.toLowerCase()).to.equal(slotElement);
350
- }
351
- if (slotOptions.expectedClassName) {
352
- expect(renderedElement).to.have.class(slotOptions.expectedClassName);
353
- }
354
- });
355
- }
356
- }
357
259
  });
358
260
  }
359
261
  function testSlotPropsProp(element, getOptions) {
360
262
  const {
361
263
  render,
362
- slots,
363
- testLegacyComponentsProp
264
+ slots
364
265
  } = getOptions();
365
266
  if (!render) {
366
267
  throwMissingPropError('render');
@@ -400,48 +301,6 @@ function testSlotPropsProp(element, getOptions) {
400
301
  expect(getByTestId('custom')).to.have.class(slotProps[slotName].className);
401
302
  });
402
303
  }
403
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
404
- it(`sets custom properties on the ${slotName} slot's element with the componentsProps.${slotName} prop`, async () => {
405
- const componentsProps = {
406
- [slotName]: {
407
- 'data-testid': 'custom'
408
- }
409
- };
410
- const {
411
- queryByTestId
412
- } = await render(/*#__PURE__*/React.cloneElement(element, {
413
- componentsProps
414
- }));
415
- const slotComponent = queryByTestId('custom');
416
- expect(slotComponent).not.to.equal(null);
417
- if (slotOptions.expectedClassName) {
418
- expect(slotComponent).to.have.class(slotOptions.expectedClassName);
419
- }
420
- });
421
- it(`prioritizes the 'slotProps.${slotName}' over componentsProps.${slotName} if both are defined`, async () => {
422
- const componentsProps = {
423
- [slotName]: {
424
- 'data-testid': 'custom',
425
- 'data-from-components-props': 'true'
426
- }
427
- };
428
- const slotProps = {
429
- [slotName]: {
430
- 'data-testid': 'custom',
431
- 'data-from-slot-props': 'true'
432
- }
433
- };
434
- const {
435
- queryByTestId
436
- } = await render(/*#__PURE__*/React.cloneElement(element, {
437
- componentsProps,
438
- slotProps
439
- }));
440
- const slotComponent = queryByTestId('custom');
441
- expect(slotComponent).to.have.attribute('data-from-slot-props', 'true');
442
- expect(slotComponent).not.to.have.attribute('data-from-components-props');
443
- });
444
- }
445
304
  });
446
305
  }
447
306
  function testSlotPropsCallback(element, getOptions) {
@@ -499,35 +358,6 @@ function testSlotPropsCallbackWithPropsAsOwnerState(element, getOptions) {
499
358
  });
500
359
  }
501
360
 
502
- /**
503
- * MUI components have a `components` prop that allows rendering a different
504
- * Components from @inheritComponent
505
- */
506
- function testComponentsProp(element, getOptions) {
507
- describe('prop components:', () => {
508
- it('can render another root component with the `components` prop', async () => {
509
- const {
510
- render,
511
- testComponentsRootPropWith: component = 'em'
512
- } = getOptions();
513
- if (!render) {
514
- throwMissingPropError('render');
515
- }
516
- const testId = randomStringValue();
517
- const {
518
- getByTestId
519
- } = await render(/*#__PURE__*/React.cloneElement(element, {
520
- components: {
521
- Root: component
522
- },
523
- 'data-testid': testId
524
- }));
525
- expect(getByTestId(testId)).not.to.equal(null);
526
- expect(getByTestId(testId).nodeName.toLowerCase()).to.eq(component);
527
- });
528
- });
529
- }
530
-
531
361
  /**
532
362
  * MUI theme has a components section that allows specifying default props.
533
363
  * Components from @inheritComponent
@@ -963,7 +793,6 @@ function testThemeCustomPalette(element, getOptions) {
963
793
  }
964
794
  const fullSuite = {
965
795
  componentProp: testComponentProp,
966
- componentsProp: testComponentsProp,
967
796
  mergeClassName: testClassName,
968
797
  propsSpread: testPropsSpread,
969
798
  refForwarding: describeRef,
@@ -1,4 +1,4 @@
1
- import { act } from "./createRenderer.js";
1
+ import { act } from "./createRenderer.mjs";
2
2
  export async function flushMicrotasks() {
3
3
  await act(async () => {});
4
4
  }
@@ -1,4 +1,4 @@
1
- import { act, fireEvent } from "./createRenderer.js";
1
+ import { act, fireEvent } from "./createRenderer.mjs";
2
2
  export default function focusVisible(element) {
3
3
  act(() => {
4
4
  element.blur();
package/index.d.mts ADDED
@@ -0,0 +1,11 @@
1
+ import "./initMatchers.mjs";
2
+ export * from "./components.mjs";
3
+ export { default as describeConformance } from "./describeConformance.mjs";
4
+ export * from "./describeConformance.mjs";
5
+ export { default as createDescribe } from "./createDescribe.mjs";
6
+ export * from "./createRenderer.mjs";
7
+ export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.mjs";
8
+ export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
9
+ export { flushMicrotasks } from "./flushMicrotasks.mjs";
10
+ export * from "./env.mjs";
11
+ export { ignoreActWarnings } from "./ignoreActWarnings.mjs";
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @mui/internal-test-utils v2.0.17
3
3
  *
4
- * @license undefined
5
- * This source code is licensed under the undefined license found in the
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  "use strict";
package/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @mui/internal-test-utils v2.0.17
3
+ *
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "./initMatchers.mjs";
9
+ export * from "./components.mjs";
10
+ export { default as describeConformance } from "./describeConformance.mjs";
11
+ export * from "./describeConformance.mjs";
12
+ export { default as createDescribe } from "./createDescribe.mjs";
13
+ export * from "./createRenderer.mjs";
14
+ export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.mjs";
15
+ // eslint-disable-next-line import/extensions
16
+ export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
17
+ export { flushMicrotasks } from "./flushMicrotasks.mjs";
18
+ export * from "./env.mjs";
19
+ export { ignoreActWarnings } from "./ignoreActWarnings.mjs";
@@ -0,0 +1,5 @@
1
+ import * as chai from 'chai';
2
+ import chaiDom from 'chai-dom';
3
+ import "./chaiTypes.mjs";
4
+ import chaiPlugin from "./chaiPlugin.mjs";
5
+ export { chai, chaiDom, chaiPlugin };
@@ -1,7 +1,7 @@
1
1
  import * as chai from 'chai';
2
2
  import chaiDom from 'chai-dom';
3
- import "./chaiTypes.js";
4
- import chaiPlugin from "./chaiPlugin.js";
3
+ import "./chaiTypes.mjs";
4
+ import chaiPlugin from "./chaiPlugin.mjs";
5
5
  chai.use(chaiDom);
6
6
  chai.use(chaiPlugin);
7
7
 
@@ -1,4 +1,4 @@
1
- import * as DomTestingLibrary from '@testing-library/dom';
1
+ import type * as DomTestingLibrary from '@testing-library/dom';
2
2
  declare global {
3
3
  namespace Chai {
4
4
  interface Assertion {
@@ -1,4 +1,4 @@
1
- import * as DomTestingLibrary from '@testing-library/dom';
1
+ import type * as DomTestingLibrary from '@testing-library/dom';
2
2
  declare global {
3
3
  namespace Chai {
4
4
  interface Assertion {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@mui/internal-test-utils",
3
- "version": "2.0.18-canary.3",
3
+ "version": "2.0.18-canary.30",
4
4
  "author": "MUI Team",
5
5
  "description": "Utilities for MUI tests. This is an internal package not meant for general use.",
6
+ "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/mui/mui-public.git",
@@ -10,18 +11,16 @@
10
11
  },
11
12
  "dependencies": {
12
13
  "@types/chai-dom": "^1.11.3",
13
- "@babel/runtime": "^7.28.4",
14
+ "@babel/runtime": "^7.29.7",
14
15
  "@testing-library/dom": "^10.4.1",
15
- "@testing-library/react": "^16.3.1",
16
+ "@testing-library/react": "^16.3.2",
16
17
  "@testing-library/user-event": "^14.6.1",
17
18
  "assertion-error": "^2.0.1",
18
19
  "chai-dom": "^1.12.1",
19
20
  "dom-accessibility-api": "^0.7.1",
20
- "es-toolkit": "^1.43.0",
21
+ "es-toolkit": "^1.49.0",
21
22
  "format-util": "^1.0.5",
22
- "jsdom": "^27.4.0",
23
23
  "prop-types": "^15.8.1",
24
- "sinon": "^21.0.1",
25
24
  "vitest-fail-on-console": "^0.10.1"
26
25
  },
27
26
  "peerDependencies": {
@@ -44,91 +43,122 @@
44
43
  "access": "public"
45
44
  },
46
45
  "type": "commonjs",
47
- "main": "./index.js",
48
- "types": "./index.d.ts",
49
46
  "exports": {
50
47
  "./package.json": "./package.json",
51
48
  ".": {
49
+ "import": {
50
+ "types": "./index.d.mts",
51
+ "default": "./index.mjs"
52
+ },
52
53
  "require": {
53
54
  "types": "./index.d.ts",
54
55
  "default": "./index.js"
55
56
  },
56
57
  "default": {
57
- "types": "./esm/index.d.ts",
58
- "default": "./esm/index.js"
58
+ "types": "./index.d.mts",
59
+ "default": "./index.mjs"
59
60
  }
60
61
  },
61
62
  "./createDescribe": {
63
+ "import": {
64
+ "types": "./createDescribe.d.mts",
65
+ "default": "./createDescribe.mjs"
66
+ },
62
67
  "require": {
63
68
  "types": "./createDescribe.d.ts",
64
69
  "default": "./createDescribe.js"
65
70
  },
66
71
  "default": {
67
- "types": "./esm/createDescribe.d.ts",
68
- "default": "./esm/createDescribe.js"
72
+ "types": "./createDescribe.d.mts",
73
+ "default": "./createDescribe.mjs"
69
74
  }
70
75
  },
71
76
  "./createRenderer": {
77
+ "import": {
78
+ "types": "./createRenderer.d.mts",
79
+ "default": "./createRenderer.mjs"
80
+ },
72
81
  "require": {
73
82
  "types": "./createRenderer.d.ts",
74
83
  "default": "./createRenderer.js"
75
84
  },
76
85
  "default": {
77
- "types": "./esm/createRenderer.d.ts",
78
- "default": "./esm/createRenderer.js"
86
+ "types": "./createRenderer.d.mts",
87
+ "default": "./createRenderer.mjs"
79
88
  }
80
89
  },
81
90
  "./initMatchers": {
91
+ "import": {
92
+ "types": "./initMatchers.d.mts",
93
+ "default": "./initMatchers.mjs"
94
+ },
82
95
  "require": {
83
96
  "types": "./initMatchers.d.ts",
84
97
  "default": "./initMatchers.js"
85
98
  },
86
99
  "default": {
87
- "types": "./esm/initMatchers.d.ts",
88
- "default": "./esm/initMatchers.js"
100
+ "types": "./initMatchers.d.mts",
101
+ "default": "./initMatchers.mjs"
89
102
  }
90
103
  },
91
104
  "./env": {
105
+ "import": {
106
+ "types": "./env.d.mts",
107
+ "default": "./env.mjs"
108
+ },
92
109
  "require": {
93
110
  "types": "./env.d.ts",
94
111
  "default": "./env.js"
95
112
  },
96
113
  "default": {
97
- "types": "./esm/env.d.ts",
98
- "default": "./esm/env.js"
114
+ "types": "./env.d.mts",
115
+ "default": "./env.mjs"
99
116
  }
100
117
  },
101
118
  "./initPlaywrightMatchers": {
119
+ "import": {
120
+ "types": "./initPlaywrightMatchers.d.mts",
121
+ "default": "./initPlaywrightMatchers.mjs"
122
+ },
102
123
  "require": {
103
124
  "types": "./initPlaywrightMatchers.d.ts",
104
125
  "default": "./initPlaywrightMatchers.js"
105
126
  },
106
127
  "default": {
107
- "types": "./esm/initPlaywrightMatchers.d.ts",
108
- "default": "./esm/initPlaywrightMatchers.js"
128
+ "types": "./initPlaywrightMatchers.d.mts",
129
+ "default": "./initPlaywrightMatchers.mjs"
109
130
  }
110
131
  },
111
132
  "./chaiPlugin": {
133
+ "import": {
134
+ "types": "./chaiPlugin.d.mts",
135
+ "default": "./chaiPlugin.mjs"
136
+ },
112
137
  "require": {
113
138
  "types": "./chaiPlugin.d.ts",
114
139
  "default": "./chaiPlugin.js"
115
140
  },
116
141
  "default": {
117
- "types": "./esm/chaiPlugin.d.ts",
118
- "default": "./esm/chaiPlugin.js"
142
+ "types": "./chaiPlugin.d.mts",
143
+ "default": "./chaiPlugin.mjs"
119
144
  }
120
145
  },
121
146
  "./setupVitest": {
147
+ "import": {
148
+ "types": "./setupVitest.d.mts",
149
+ "default": "./setupVitest.mjs"
150
+ },
122
151
  "require": {
123
152
  "types": "./setupVitest.d.ts",
124
153
  "default": "./setupVitest.js"
125
154
  },
126
155
  "default": {
127
- "types": "./esm/setupVitest.d.ts",
128
- "default": "./esm/setupVitest.js"
156
+ "types": "./setupVitest.d.mts",
157
+ "default": "./setupVitest.mjs"
129
158
  }
130
- },
131
- "./esm": null
159
+ }
132
160
  },
133
- "gitSha": "2cce44e9da123b708fb35e4f1ec29be8dd58bfb5"
161
+ "main": "./index.js",
162
+ "types": "./index.d.ts",
163
+ "gitSha": "9590da6ae303c6afa7e67aebb6bc46232fac164e"
134
164
  }
@@ -1,5 +1,5 @@
1
- import "./chaiTypes.js";
2
- import { Configuration } from "./configure.js";
1
+ import "./chaiTypes.mjs";
2
+ import type { Configuration } from "./configure.mjs";
3
3
  export default function setupVitest({
4
4
  failOnConsoleEnabled,
5
5
  ...config
package/setupVitest.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chaiTypes.js";
2
- import { Configuration } from "./configure.js";
2
+ import type { Configuration } from "./configure.js";
3
3
  export default function setupVitest({
4
4
  failOnConsoleEnabled,
5
5
  ...config
package/setupVitest.js CHANGED
@@ -36,15 +36,6 @@ function setupVitest({
36
36
  _vitest.vi.useRealTimers();
37
37
  (0, _pure.cleanup)();
38
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
39
  if (failOnConsoleEnabled) {
49
40
  (0, _vitestFailOnConsole.default)({
50
41
  silenceMessage: message => {
@@ -56,13 +47,13 @@ function setupVitest({
56
47
  }
57
48
  if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
58
49
  // Controversial warning that is commonly ignored by switching to `useEffect` on the server.
59
- // https://github.com/facebook/react/issues/14927
50
+ // https://github.com/react/react/issues/14927
60
51
  // However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
61
52
  return true;
62
53
  }
63
54
 
64
55
  // 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
56
+ // TODO: Revisit once https://github.com/react/react/issues/22796 is resolved
66
57
  if (message.includes('Detected multiple renderers concurrently rendering the same context provider.')) {
67
58
  return true;
68
59
  }
@@ -70,6 +61,17 @@ function setupVitest({
70
61
  }
71
62
  });
72
63
  }
64
+
65
+ // Don't call test lifecycle hooks (afterEach/afterAll/beforeEach/beforeAll/...) after this point
66
+ // Make sure none of (transitive) dependencies call lifecycle hooks either, otherwise they won't be
67
+ // registered and thus won't run when using `--no-isolate --no-file-parallelism`.
68
+
69
+ if (isInitialized) {
70
+ return;
71
+ }
72
+ isInitialized = true;
73
+ (0, _configure.configure)(config);
74
+ chai.use(_chaiPlugin.default);
73
75
  if (typeof window !== 'undefined') {
74
76
  chai.use(_chaiDom.default);
75
77
 
@@ -1,12 +1,12 @@
1
1
  import failOnConsole from 'vitest-fail-on-console';
2
2
  import * as chai from 'chai';
3
- import "./chaiTypes.js";
3
+ import "./chaiTypes.mjs";
4
4
  // eslint-disable-next-line import/extensions
5
5
  import { cleanup, act } from '@testing-library/react/pure.js';
6
6
  import { afterEach, vi } from 'vitest';
7
7
  import chaiDom from 'chai-dom';
8
- import chaiPlugin from "./chaiPlugin.js";
9
- import { configure } from "./configure.js";
8
+ import chaiPlugin from "./chaiPlugin.mjs";
9
+ import { configure } from "./configure.mjs";
10
10
  let isInitialized = false;
11
11
  export default function setupVitest({
12
12
  failOnConsoleEnabled = true,
@@ -27,15 +27,6 @@ export default function setupVitest({
27
27
  vi.useRealTimers();
28
28
  cleanup();
29
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
30
  if (failOnConsoleEnabled) {
40
31
  failOnConsole({
41
32
  silenceMessage: message => {
@@ -47,13 +38,13 @@ export default function setupVitest({
47
38
  }
48
39
  if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
49
40
  // Controversial warning that is commonly ignored by switching to `useEffect` on the server.
50
- // https://github.com/facebook/react/issues/14927
41
+ // https://github.com/react/react/issues/14927
51
42
  // However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
52
43
  return true;
53
44
  }
54
45
 
55
46
  // 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
47
+ // TODO: Revisit once https://github.com/react/react/issues/22796 is resolved
57
48
  if (message.includes('Detected multiple renderers concurrently rendering the same context provider.')) {
58
49
  return true;
59
50
  }
@@ -61,6 +52,17 @@ export default function setupVitest({
61
52
  }
62
53
  });
63
54
  }
55
+
56
+ // Don't call test lifecycle hooks (afterEach/afterAll/beforeEach/beforeAll/...) after this point
57
+ // Make sure none of (transitive) dependencies call lifecycle hooks either, otherwise they won't be
58
+ // registered and thus won't run when using `--no-isolate --no-file-parallelism`.
59
+
60
+ if (isInitialized) {
61
+ return;
62
+ }
63
+ isInitialized = true;
64
+ configure(config);
65
+ chai.use(chaiPlugin);
64
66
  if (typeof window !== 'undefined') {
65
67
  chai.use(chaiDom);
66
68
 
@@ -1,3 +0,0 @@
1
- import * as chai from 'chai';
2
- declare const chaiPlugin: Parameters<typeof chai.use>[0];
3
- export default chaiPlugin;
package/esm/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import "./initMatchers.js";
2
- export * from "./components.js";
3
- export { default as describeConformance } from "./describeConformance.js";
4
- export * from "./describeConformance.js";
5
- export { default as createDescribe } from "./createDescribe.js";
6
- export * from "./createRenderer.js";
7
- export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
8
- export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
9
- export { flushMicrotasks } from "./flushMicrotasks.js";
10
- export * from "./env.js";
11
- export { ignoreActWarnings } from "./ignoreActWarnings.js";
package/esm/index.js DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * @mui/internal-test-utils v2.0.17
3
- *
4
- * @license undefined
5
- * This source code is licensed under the undefined license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- import "./initMatchers.js";
9
- export * from "./components.js";
10
- export { default as describeConformance } from "./describeConformance.js";
11
- export * from "./describeConformance.js";
12
- export { default as createDescribe } from "./createDescribe.js";
13
- export * from "./createRenderer.js";
14
- export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
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";
19
- export { ignoreActWarnings } from "./ignoreActWarnings.js";
@@ -1,5 +0,0 @@
1
- import * as chai from 'chai';
2
- import chaiDom from 'chai-dom';
3
- import "./chaiTypes.js";
4
- import chaiPlugin from "./chaiPlugin.js";
5
- export { chai, chaiDom, chaiPlugin };