@mui/internal-test-utils 1.0.19 → 1.0.21

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 (55) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/chai.types.d.ts +75 -0
  3. package/build/chai.types.d.ts.map +1 -0
  4. package/build/chai.types.js +3 -0
  5. package/build/chai.types.js.map +1 -0
  6. package/build/chaiPlugin.d.ts +5 -0
  7. package/build/chaiPlugin.d.ts.map +1 -0
  8. package/build/chaiPlugin.js +406 -0
  9. package/build/chaiPlugin.js.map +1 -0
  10. package/build/createDOM.js +4 -4
  11. package/build/createDOM.js.map +1 -1
  12. package/build/createRenderer.d.ts +37 -62
  13. package/build/createRenderer.d.ts.map +1 -1
  14. package/build/createRenderer.js +85 -40
  15. package/build/createRenderer.js.map +1 -1
  16. package/build/describeConformance.d.ts.map +1 -1
  17. package/build/describeConformance.js +41 -19
  18. package/build/describeConformance.js.map +1 -1
  19. package/build/describeSkipIf.d.ts +3 -0
  20. package/build/describeSkipIf.d.ts.map +1 -0
  21. package/build/describeSkipIf.js +10 -0
  22. package/build/describeSkipIf.js.map +1 -0
  23. package/build/index.d.ts +1 -0
  24. package/build/index.d.ts.map +1 -1
  25. package/build/index.js +3 -1
  26. package/build/index.js.map +1 -1
  27. package/build/initMatchers.d.ts +1 -74
  28. package/build/initMatchers.d.ts.map +1 -1
  29. package/build/initMatchers.js +4 -400
  30. package/build/initMatchers.js.map +1 -1
  31. package/build/initMatchers.test.js +4 -6
  32. package/build/initMatchers.test.js.map +1 -1
  33. package/build/mochaHooks.test.js +5 -1
  34. package/build/mochaHooks.test.js.map +1 -1
  35. package/build/setupJSDOM.js +2 -2
  36. package/build/setupJSDOM.js.map +1 -1
  37. package/build/setupVitest.d.ts +2 -0
  38. package/build/setupVitest.d.ts.map +1 -0
  39. package/build/setupVitest.js +121 -0
  40. package/build/setupVitest.js.map +1 -0
  41. package/package.json +6 -4
  42. package/src/chai.types.ts +106 -0
  43. package/src/chaiPlugin.ts +512 -0
  44. package/src/createDOM.js +4 -4
  45. package/src/createRenderer.tsx +106 -51
  46. package/src/describeConformance.tsx +39 -20
  47. package/src/describeSkipIf.tsx +9 -0
  48. package/src/index.ts +1 -0
  49. package/src/initMatchers.test.js +4 -6
  50. package/src/initMatchers.ts +4 -615
  51. package/src/mochaHooks.test.js +2 -1
  52. package/src/setupJSDOM.js +2 -2
  53. package/src/setupVitest.ts +117 -0
  54. package/tsconfig.json +5 -2
  55. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,117 @@
1
+ import { beforeAll, afterAll, it } from 'vitest';
2
+ import * as testingLibrary from '@testing-library/dom';
3
+ import failOnConsole from 'vitest-fail-on-console';
4
+ import './initMatchers';
5
+
6
+ // checking if an element is hidden is quite expensive
7
+ // this is only done in CI as a fail safe. It can still explicitly be checked
8
+ // in the test files which helps documenting what is part of the DOM but hidden
9
+ // from assistive technology
10
+ const defaultHidden = !process.env.CI;
11
+
12
+ // adds verbosity for something that might be confusing
13
+ console.warn(`${defaultHidden ? 'including' : 'excluding'} inaccessible elements by default`);
14
+
15
+ testingLibrary.configure({
16
+ // JSDOM logs errors otherwise on `getComputedStyle(element, pseudoElement)` calls.
17
+ computedStyleSupportsPseudoElements: false,
18
+ defaultHidden,
19
+ });
20
+
21
+ // Enable missing act warnings: https://github.com/reactwg/react-18/discussions/102
22
+ (globalThis as any).jest = null;
23
+ (globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
24
+
25
+ failOnConsole({
26
+ silenceMessage: (message) => {
27
+ if (process.env.NODE_ENV === 'production') {
28
+ // TODO: mock scheduler
29
+ if (message.includes('act(...) is not supported in production builds of React')) {
30
+ return true;
31
+ }
32
+ }
33
+
34
+ if (message.includes('Warning: useLayoutEffect does nothing on the server')) {
35
+ // Controversial warning that is commonly ignored by switching to `useEffect` on the server.
36
+ // https://github.com/facebook/react/issues/14927
37
+ // However, this switch doesn't work since it relies on environment sniffing and we test SSR in a browser environment.
38
+ return true;
39
+ }
40
+
41
+ // Unclear why this is an issue for the current occurrences of this warning.
42
+ // TODO: Revisit once https://github.com/facebook/react/issues/22796 is resolved
43
+ if (
44
+ message.includes(
45
+ 'Detected multiple renderers concurrently rendering the same context provider.',
46
+ )
47
+ ) {
48
+ return true;
49
+ }
50
+
51
+ return false;
52
+ },
53
+ });
54
+
55
+ function wrapIt(itFn: typeof it.only) {
56
+ return function wrapper(name: string, fn: Function) {
57
+ return itFn(name, (context) => {
58
+ return fn?.call({
59
+ ...context,
60
+ currentTest: {
61
+ fullTitle: () => context.task.name,
62
+ },
63
+ });
64
+ });
65
+ };
66
+ }
67
+
68
+ const wrappedIt: any = wrapIt(it);
69
+ wrappedIt.skip = wrapIt(it.skip);
70
+ wrappedIt.only = wrapIt(it.only);
71
+
72
+ (globalThis as any).it = wrappedIt;
73
+
74
+ if (!globalThis.before) {
75
+ (globalThis as any).before = beforeAll;
76
+ }
77
+ if (!globalThis.after) {
78
+ (globalThis as any).after = afterAll;
79
+ }
80
+ if (!globalThis.specify) {
81
+ (globalThis as any).specify = wrappedIt;
82
+ }
83
+
84
+ const isJsdom = typeof window !== 'undefined' && window.navigator.userAgent.includes('jsdom');
85
+
86
+ // Only necessary when not in browser mode.
87
+ if (isJsdom) {
88
+ class Touch {
89
+ instance: any;
90
+
91
+ constructor(instance: any) {
92
+ this.instance = instance;
93
+ }
94
+
95
+ get identifier() {
96
+ return this.instance.identifier;
97
+ }
98
+
99
+ get pageX() {
100
+ return this.instance.pageX;
101
+ }
102
+
103
+ get pageY() {
104
+ return this.instance.pageY;
105
+ }
106
+
107
+ get clientX() {
108
+ return this.instance.clientX;
109
+ }
110
+
111
+ get clientY() {
112
+ return this.instance.clientY;
113
+ }
114
+ }
115
+ // @ts-expect-error
116
+ globalThis.window.Touch = Touch;
117
+ }
package/tsconfig.json CHANGED
@@ -3,11 +3,14 @@
3
3
  "lib": ["es2020", "dom"],
4
4
  "noEmit": true,
5
5
  "moduleResolution": "node",
6
- "types": ["node"],
6
+ "types": ["node", "mocha"],
7
7
  "strict": true,
8
8
  "esModuleInterop": true,
9
9
  "isolatedModules": true,
10
- "jsx": "react"
10
+ "jsx": "react",
11
+ // https://github.com/vitest-dev/vitest/issues/4688
12
+ // TODO: Remove after fully migrated chai to vitest
13
+ "skipLibCheck": true
11
14
  },
12
15
  "include": ["./src/**/*"]
13
16
  }
@@ -1 +0,0 @@
1
- {"root":["./src/components.tsx","./src/createdom.d.ts","./src/createdescribe.ts","./src/createrenderer.tsx","./src/describeconformance.tsx","./src/firediscreteevent.ts","./src/flushmicrotasks.ts","./src/focusvisible.ts","./src/index.ts","./src/initmatchers.ts","./src/initplaywrightmatchers.ts","./src/reactmajor.ts"],"version":"5.7.0-dev.20240821"}