@mui/internal-test-utils 1.0.0-dev.20240529-082515-213b5e33ab

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 (148) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +9 -0
  4. package/build/.tsbuildinfo +1 -0
  5. package/build/KarmaReporterReactProfiler.d.ts +51 -0
  6. package/build/KarmaReporterReactProfiler.d.ts.map +1 -0
  7. package/build/KarmaReporterReactProfiler.js +68 -0
  8. package/build/KarmaReporterReactProfiler.js.map +1 -0
  9. package/build/components.d.ts +36 -0
  10. package/build/components.d.ts.map +1 -0
  11. package/build/components.js +78 -0
  12. package/build/components.js.map +1 -0
  13. package/build/createDOM.d.ts +3 -0
  14. package/build/createDOM.d.ts.map +1 -0
  15. package/build/createDOM.js +60 -0
  16. package/build/createDOM.js.map +1 -0
  17. package/build/createDescribe.d.ts +8 -0
  18. package/build/createDescribe.d.ts.map +1 -0
  19. package/build/createDescribe.js +22 -0
  20. package/build/createDescribe.js.map +1 -0
  21. package/build/createMount.d.ts +9 -0
  22. package/build/createMount.d.ts.map +1 -0
  23. package/build/createMount.js +120 -0
  24. package/build/createMount.js.map +1 -0
  25. package/build/createRenderer.d.ts +231 -0
  26. package/build/createRenderer.d.ts.map +1 -0
  27. package/build/createRenderer.js +506 -0
  28. package/build/createRenderer.js.map +1 -0
  29. package/build/createRenderer.test.d.ts +2 -0
  30. package/build/createRenderer.test.d.ts.map +1 -0
  31. package/build/createRenderer.test.js +48 -0
  32. package/build/createRenderer.test.js.map +1 -0
  33. package/build/describeConformance.d.ts +152 -0
  34. package/build/describeConformance.d.ts.map +1 -0
  35. package/build/describeConformance.js +815 -0
  36. package/build/describeConformance.js.map +1 -0
  37. package/build/findOutermostIntrinsic.d.ts +14 -0
  38. package/build/findOutermostIntrinsic.d.ts.map +1 -0
  39. package/build/findOutermostIntrinsic.js +22 -0
  40. package/build/findOutermostIntrinsic.js.map +1 -0
  41. package/build/findOutermostIntrinsic.test.d.ts +2 -0
  42. package/build/findOutermostIntrinsic.test.d.ts.map +1 -0
  43. package/build/findOutermostIntrinsic.test.js +70 -0
  44. package/build/findOutermostIntrinsic.test.js.map +1 -0
  45. package/build/fireDiscreteEvent.d.ts +7 -0
  46. package/build/fireDiscreteEvent.d.ts.map +1 -0
  47. package/build/fireDiscreteEvent.js +98 -0
  48. package/build/fireDiscreteEvent.js.map +1 -0
  49. package/build/flushMicrotasks.d.ts +2 -0
  50. package/build/flushMicrotasks.d.ts.map +1 -0
  51. package/build/flushMicrotasks.js +11 -0
  52. package/build/flushMicrotasks.js.map +1 -0
  53. package/build/focusVisible.d.ts +7 -0
  54. package/build/focusVisible.d.ts.map +1 -0
  55. package/build/focusVisible.js +33 -0
  56. package/build/focusVisible.js.map +1 -0
  57. package/build/index.d.ts +18 -0
  58. package/build/index.d.ts.map +1 -0
  59. package/build/index.js +59 -0
  60. package/build/index.js.map +1 -0
  61. package/build/init.d.ts +2 -0
  62. package/build/init.d.ts.map +1 -0
  63. package/build/init.js +42 -0
  64. package/build/init.js.map +1 -0
  65. package/build/initMatchers.d.ts +81 -0
  66. package/build/initMatchers.d.ts.map +1 -0
  67. package/build/initMatchers.js +431 -0
  68. package/build/initMatchers.js.map +1 -0
  69. package/build/initMatchers.test.d.ts +2 -0
  70. package/build/initMatchers.test.d.ts.map +1 -0
  71. package/build/initMatchers.test.js +103 -0
  72. package/build/initMatchers.test.js.map +1 -0
  73. package/build/initPlaywrightMatchers.d.ts +25 -0
  74. package/build/initPlaywrightMatchers.d.ts.map +1 -0
  75. package/build/initPlaywrightMatchers.js +63 -0
  76. package/build/initPlaywrightMatchers.js.map +1 -0
  77. package/build/mochaHooks.d.ts +25 -0
  78. package/build/mochaHooks.d.ts.map +1 -0
  79. package/build/mochaHooks.js +171 -0
  80. package/build/mochaHooks.js.map +1 -0
  81. package/build/mochaHooks.test.d.ts +2 -0
  82. package/build/mochaHooks.test.d.ts.map +1 -0
  83. package/build/mochaHooks.test.js +112 -0
  84. package/build/mochaHooks.test.js.map +1 -0
  85. package/build/setup.d.ts +2 -0
  86. package/build/setup.d.ts.map +1 -0
  87. package/build/setup.js +10 -0
  88. package/build/setup.js.map +1 -0
  89. package/build/setupBabel.d.ts +2 -0
  90. package/build/setupBabel.d.ts.map +1 -0
  91. package/build/setupBabel.js +5 -0
  92. package/build/setupBabel.js.map +1 -0
  93. package/build/setupBabelPlaywright.d.ts +2 -0
  94. package/build/setupBabelPlaywright.d.ts.map +1 -0
  95. package/build/setupBabelPlaywright.js +11 -0
  96. package/build/setupBabelPlaywright.js.map +1 -0
  97. package/build/setupJSDOM.d.ts +7 -0
  98. package/build/setupJSDOM.d.ts.map +1 -0
  99. package/build/setupJSDOM.js +17 -0
  100. package/build/setupJSDOM.js.map +1 -0
  101. package/build/setupKarma.d.ts +2 -0
  102. package/build/setupKarma.d.ts.map +1 -0
  103. package/build/setupKarma.js +56 -0
  104. package/build/setupKarma.js.map +1 -0
  105. package/build/until.d.ts +2 -0
  106. package/build/until.d.ts.map +1 -0
  107. package/build/until.js +26 -0
  108. package/build/until.js.map +1 -0
  109. package/build/until.test.d.ts +2 -0
  110. package/build/until.test.d.ts.map +1 -0
  111. package/build/until.test.js +118 -0
  112. package/build/until.test.js.map +1 -0
  113. package/build/userEvent.d.ts +8 -0
  114. package/build/userEvent.d.ts.map +1 -0
  115. package/build/userEvent.js +61 -0
  116. package/build/userEvent.js.map +1 -0
  117. package/package.json +76 -0
  118. package/src/KarmaReporterReactProfiler.js +81 -0
  119. package/src/components.tsx +61 -0
  120. package/src/createDOM.d.ts +9 -0
  121. package/src/createDOM.js +67 -0
  122. package/src/createDescribe.ts +31 -0
  123. package/src/createMount.tsx +136 -0
  124. package/src/createRenderer.test.js +31 -0
  125. package/src/createRenderer.tsx +737 -0
  126. package/src/describeConformance.tsx +1117 -0
  127. package/src/findOutermostIntrinsic.test.js +68 -0
  128. package/src/findOutermostIntrinsic.ts +19 -0
  129. package/src/fireDiscreteEvent.ts +76 -0
  130. package/src/flushMicrotasks.ts +8 -0
  131. package/src/focusVisible.ts +28 -0
  132. package/src/index.ts +24 -0
  133. package/src/init.js +15 -0
  134. package/src/initMatchers.test.js +126 -0
  135. package/src/initMatchers.ts +658 -0
  136. package/src/initPlaywrightMatchers.ts +96 -0
  137. package/src/mochaHooks.js +209 -0
  138. package/src/mochaHooks.test.js +113 -0
  139. package/src/setup.js +10 -0
  140. package/src/setupBabel.js +3 -0
  141. package/src/setupBabelPlaywright.js +10 -0
  142. package/src/setupJSDOM.js +20 -0
  143. package/src/setupKarma.js +65 -0
  144. package/src/until.js +28 -0
  145. package/src/until.test.js +120 -0
  146. package/src/userEvent.ts +35 -0
  147. package/tsconfig.build.json +17 -0
  148. package/tsconfig.json +12 -0
@@ -0,0 +1,431 @@
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 chai_1 = __importStar(require("chai"));
30
+ const chai_dom_1 = __importDefault(require("chai-dom"));
31
+ const lodash_1 = __importDefault(require("lodash"));
32
+ const dom_1 = require("@testing-library/dom");
33
+ const pure_1 = require("@testing-library/react/pure");
34
+ const dom_accessibility_api_1 = require("dom-accessibility-api");
35
+ const format_util_1 = __importDefault(require("format-util"));
36
+ chai_1.default.use(chai_dom_1.default);
37
+ const isKarma = Boolean(process.env.KARMA);
38
+ function isInJSDOM() {
39
+ return /jsdom/.test(window.navigator.userAgent);
40
+ }
41
+ // chai#utils.elToString that looks like stringified elements in testing-library
42
+ function elementToString(element) {
43
+ if (typeof element?.nodeType === 'number') {
44
+ return (0, pure_1.prettyDOM)(element, undefined, { highlight: !isKarma, maxDepth: 1 });
45
+ }
46
+ return String(element);
47
+ }
48
+ chai_1.default.use((chaiAPI, utils) => {
49
+ const blockElements = new Set([
50
+ 'html',
51
+ 'address',
52
+ 'blockquote',
53
+ 'body',
54
+ 'dd',
55
+ 'div',
56
+ 'dl',
57
+ 'dt',
58
+ 'fieldset',
59
+ 'form',
60
+ 'frame',
61
+ 'frameset',
62
+ 'h1',
63
+ 'h2',
64
+ 'h3',
65
+ 'h4',
66
+ 'h5',
67
+ 'h6',
68
+ 'noframes',
69
+ 'ol',
70
+ 'p',
71
+ 'ul',
72
+ 'center',
73
+ 'dir',
74
+ 'hr',
75
+ 'menu',
76
+ 'pre',
77
+ ]);
78
+ function pretendVisibleGetComputedStyle(element) {
79
+ // `CSSStyleDeclaration` is not constructable
80
+ // https://stackoverflow.com/a/52732909/3406963
81
+ // this is not equivalent to the declaration from `getComputedStyle`
82
+ // for example `getComputedStyle` would return a readonly declaration
83
+ // let's hope this doesn't get passed around until it's no longer clear where it comes from
84
+ const declaration = document.createElement('span').style;
85
+ // initial values
86
+ declaration.content = '';
87
+ // technically it's `inline`. We partially apply the default user agent sheet (chrome) here
88
+ // we're only interested in elements that use block
89
+ declaration.display = blockElements.has(element.tagName) ? 'block' : 'inline';
90
+ declaration.visibility = 'visible';
91
+ return declaration;
92
+ }
93
+ // better diff view for expect(element).to.equal(document.activeElement)
94
+ chai_1.default.Assertion.addMethod('toHaveFocus', function elementIsFocused() {
95
+ const element = utils.flag(this, 'object');
96
+ this.assert(element === document.activeElement,
97
+ // karma does not show the diff like mocha does
98
+ `expected element to have focus${isKarma ? '\nexpected #{exp}\nactual: #{act}' : ''}`, `expected element to NOT have focus \n${elementToString(element)}`, elementToString(element), elementToString(document.activeElement));
99
+ });
100
+ chai_1.default.Assertion.addMethod('toHaveVirtualFocus', function elementIsVirtuallyFocused() {
101
+ const element = utils.flag(this, 'object');
102
+ const id = element.getAttribute('id');
103
+ const virtuallyFocusedElementId = document.activeElement.getAttribute('aria-activedescendant');
104
+ this.assert(virtuallyFocusedElementId === id, `expected element to be virtually focused\nexpected id #{exp}\n${virtuallyFocusedElementId === null
105
+ ? `activeElement: ${elementToString(document.activeElement)}`
106
+ : 'actual id: #{act}'}`, 'expected element to NOT to be virtually focused', id, virtuallyFocusedElementId, virtuallyFocusedElementId !== null);
107
+ });
108
+ chai_1.default.Assertion.addMethod('toBeAriaHidden', function elementIsAccessible() {
109
+ const element = utils.flag(this, 'object');
110
+ // used for debugging failed assertions, will either point to the top most node
111
+ // or the node that had aria-hidden="true"
112
+ let previousNode = element;
113
+ let currentNode = element;
114
+ let ariaHidden = false;
115
+ // "An element is considered hidden if it, or any of its ancestors are not
116
+ // rendered or have their aria-hidden attribute value set to true."
117
+ // -- https://www.w3.org/TR/wai-aria-1.1/#aria-hidden
118
+ while (currentNode !== null &&
119
+ // stopping at <html /> so that failed assertion message only prints
120
+ // <body /> or below. use cases for aria-hidden on <html /> are unknown
121
+ currentNode !== document.documentElement &&
122
+ ariaHidden === false) {
123
+ ariaHidden = currentNode.getAttribute('aria-hidden') === 'true';
124
+ previousNode = currentNode;
125
+ currentNode = currentNode.parentElement;
126
+ }
127
+ this.assert(ariaHidden === true, `expected \n${elementToString(element)} to be aria-hidden`, `expected \n${elementToString(element)} to not be aria-hidden, but \n${elementToString(previousNode)} had aria-hidden="true" instead`,
128
+ // Not interested in a diff but the typings require the 4th parameter.
129
+ undefined);
130
+ });
131
+ chai_1.default.Assertion.addMethod('toBeInaccessible', function elementIsAccessible() {
132
+ const element = utils.flag(this, 'object');
133
+ const inaccessible = (0, dom_1.isInaccessible)(element);
134
+ this.assert(inaccessible === true, `expected \n${elementToString(element)} to be inaccessible but it was accessible`, `expected \n${elementToString(element)} to be accessible but it was inaccessible`,
135
+ // Not interested in a diff but the typings require the 4th parameter.
136
+ undefined);
137
+ });
138
+ chai_1.default.Assertion.addMethod('toHaveAccessibleName', function hasAccessibleName(expectedName) {
139
+ const root = utils.flag(this, 'object');
140
+ // make sure it's an Element
141
+ new chai_1.default.Assertion(root.nodeType, `Expected an Element but got '${String(root)}'`).to.equal(1);
142
+ const actualName = (0, dom_accessibility_api_1.computeAccessibleName)(root, {
143
+ computedStyleSupportsPseudoElements: !isInJSDOM(),
144
+ // in local development we pretend to be visible. full getComputedStyle is
145
+ // expensive and reserved for CI
146
+ getComputedStyle: process.env.CI ? undefined : pretendVisibleGetComputedStyle,
147
+ });
148
+ this.assert(actualName === expectedName, `expected \n${elementToString(root)} to have accessible name #{exp} but got #{act} instead.`, `expected \n${elementToString(root)} not to have accessible name #{exp}.`, expectedName, actualName);
149
+ });
150
+ chai_1.default.Assertion.addMethod('toHaveAccessibleDescription', function hasAccessibleDescription(expectedDescription) {
151
+ const root = utils.flag(this, 'object');
152
+ // make sure it's an Element
153
+ new chai_1.default.Assertion(root.nodeType, `Expected an Element but got '${String(root)}'`).to.equal(1);
154
+ const actualDescription = (0, dom_accessibility_api_1.computeAccessibleDescription)(root, {
155
+ // in local development we pretend to be visible. full getComputedStyle is
156
+ // expensive and reserved for CI
157
+ getComputedStyle: process.env.CI ? undefined : pretendVisibleGetComputedStyle,
158
+ });
159
+ const possibleDescriptionComputationMessage = root.hasAttribute('title')
160
+ ? ' computeAccessibleDescription can be misleading when a `title` attribute is used. This might be a bug in `dom-accessibility-api`.'
161
+ : '';
162
+ this.assert(actualDescription === expectedDescription, `expected \n${elementToString(root)} to have accessible description #{exp} but got #{act} instead.${possibleDescriptionComputationMessage}`, `expected \n${elementToString(root)} not to have accessible description #{exp}.${possibleDescriptionComputationMessage}`, expectedDescription, actualDescription);
163
+ });
164
+ /**
165
+ * Correct name for `to.be.visible`
166
+ */
167
+ chai_1.default.Assertion.addMethod('toBeVisible', function toBeVisible() {
168
+ // eslint-disable-next-line no-underscore-dangle, @typescript-eslint/no-unused-expressions
169
+ new chai_1.default.Assertion(this._obj).to.be.visible;
170
+ });
171
+ /**
172
+ * Correct name for `not.to.be.visible`
173
+ */
174
+ chai_1.default.Assertion.addMethod('toBeHidden', function toBeHidden() {
175
+ // eslint-disable-next-line no-underscore-dangle, @typescript-eslint/no-unused-expressions
176
+ new chai_1.default.Assertion(this._obj).not.to.be.visible;
177
+ });
178
+ function assertMatchingStyles(actualStyleDeclaration, expectedStyleUnnormalized, options) {
179
+ const { styleTypeHint } = options;
180
+ // Compare objects using hyphen case.
181
+ // This is closer to actual CSS and required for getPropertyValue anyway.
182
+ const expectedStyle = {};
183
+ Object.keys(expectedStyleUnnormalized).forEach((cssProperty) => {
184
+ const hyphenCasedPropertyName = lodash_1.default.kebabCase(cssProperty);
185
+ const isVendorPrefixed = /^(moz|ms|o|webkit)-/.test(hyphenCasedPropertyName);
186
+ const propertyName = isVendorPrefixed
187
+ ? `-${hyphenCasedPropertyName}`
188
+ : hyphenCasedPropertyName;
189
+ expectedStyle[propertyName] = expectedStyleUnnormalized[cssProperty];
190
+ });
191
+ const shorthandProperties = new Set([
192
+ 'all',
193
+ 'animation',
194
+ 'background',
195
+ 'border',
196
+ 'border-block-end',
197
+ 'border-block-start',
198
+ 'border-bottom',
199
+ 'border-color',
200
+ 'border-image',
201
+ 'border-inline-end',
202
+ 'border-inline-start',
203
+ 'border-left',
204
+ 'border-radius',
205
+ 'border-right',
206
+ 'border-style',
207
+ 'border-top',
208
+ 'border-width',
209
+ 'column-rule',
210
+ 'columns',
211
+ 'flex',
212
+ 'flex-flow',
213
+ 'font',
214
+ 'gap',
215
+ 'grid',
216
+ 'grid-area',
217
+ 'grid-column',
218
+ 'grid-row',
219
+ 'grid-template',
220
+ 'list-style',
221
+ 'margin',
222
+ 'mask',
223
+ 'offset',
224
+ 'outline',
225
+ 'overflow',
226
+ 'padding',
227
+ 'place-content',
228
+ 'place-items',
229
+ 'place-self',
230
+ 'scroll-margin',
231
+ 'scroll-padding',
232
+ 'text-decoration',
233
+ 'text-emphasis',
234
+ 'transition',
235
+ ]);
236
+ const usedShorthandProperties = Object.keys(expectedStyle).filter((cssProperty) => {
237
+ return shorthandProperties.has(cssProperty);
238
+ });
239
+ if (usedShorthandProperties.length > 0) {
240
+ throw new Error([
241
+ `Shorthand properties are not supported in ${styleTypeHint} styles matchers since browsers can compute them differently. `,
242
+ 'Use longhand properties instead for the follow shorthand properties:\n',
243
+ usedShorthandProperties
244
+ .map((cssProperty) => {
245
+ return `- https://developer.mozilla.org/en-US/docs/Web/CSS/${cssProperty}#constituent_properties`;
246
+ })
247
+ .join('\n'),
248
+ ].join(''));
249
+ }
250
+ const actualStyle = {};
251
+ Object.keys(expectedStyle).forEach((cssProperty) => {
252
+ actualStyle[cssProperty] = actualStyleDeclaration.getPropertyValue(cssProperty);
253
+ });
254
+ const jsdomHint = 'Styles in JSDOM e.g. from `test:unit` are often misleading since JSDOM does not implement the Cascade nor actual CSS property value computation. ' +
255
+ 'If results differ between real browsers and JSDOM, skip the test in JSDOM e.g. `if (/jsdom/.test(window.navigator.userAgent)) this.skip();`';
256
+ const shorthandHint = 'Browsers can compute shorthand properties differently. Prefer longhand properties e.g. `borderTopColor`, `borderRightColor` etc. instead of `border` or `border-color`.';
257
+ const messageHint = `${jsdomHint}\n${shorthandHint}`;
258
+ if (isKarma) {
259
+ // `#{exp}` and `#{act}` placeholders escape the newlines
260
+ const expected = JSON.stringify(expectedStyle, null, 2);
261
+ const actual = JSON.stringify(actualStyle, null, 2);
262
+ // karma's `dots` reporter does not support diffs
263
+ this.assert(
264
+ // TODO Fix upstream docs/types
265
+ utils.eql(actualStyle, expectedStyle), `expected ${styleTypeHint} style of #{this} did not match\nExpected:\n${expected}\nActual:\n${actual}\n\n\n${messageHint}`, `expected #{this} to not have ${styleTypeHint} style\n${expected}\n\n\n${messageHint}`, expectedStyle, actualStyle);
266
+ }
267
+ else {
268
+ this.assert(
269
+ // TODO Fix upstream docs/types
270
+ utils.eql(actualStyle, expectedStyle), `expected #{this} to have ${styleTypeHint} style #{exp} \n\n${messageHint}`, `expected #{this} not to have ${styleTypeHint} style #{exp}${messageHint}`, expectedStyle, actualStyle, true);
271
+ }
272
+ }
273
+ chai_1.default.Assertion.addMethod('toHaveInlineStyle', function toHaveInlineStyle(expectedStyleUnnormalized) {
274
+ const element = utils.flag(this, 'object');
275
+ if (element?.nodeType !== 1) {
276
+ // Same pre-condition for negated and unnegated assertion
277
+ throw new chai_1.AssertionError(`Expected an Element but got ${String(element)}`);
278
+ }
279
+ assertMatchingStyles.call(this, element.style, expectedStyleUnnormalized, {
280
+ styleTypeHint: 'inline',
281
+ });
282
+ });
283
+ chai_1.default.Assertion.addMethod('toHaveComputedStyle', function toHaveComputedStyle(expectedStyleUnnormalized) {
284
+ const element = utils.flag(this, 'object');
285
+ if (element?.nodeType !== 1) {
286
+ // Same pre-condition for negated and unnegated assertion
287
+ throw new chai_1.AssertionError(`Expected an Element but got ${String(element)}`);
288
+ }
289
+ const computedStyle = element.ownerDocument.defaultView.getComputedStyle(element);
290
+ assertMatchingStyles.call(this, computedStyle, expectedStyleUnnormalized, {
291
+ styleTypeHint: 'computed',
292
+ });
293
+ });
294
+ chai_1.default.Assertion.addMethod('toThrowMinified', function toThrowMinified(expectedDevMessage) {
295
+ // TODO: Investigate if `as any` can be removed after https://github.com/DefinitelyTyped/DefinitelyTyped/issues/48634 is resolved.
296
+ if (process.env.NODE_ENV !== 'production') {
297
+ this.to.throw(expectedDevMessage);
298
+ }
299
+ else {
300
+ utils.flag(this, 'message', "Looks like the error was not minified. This can happen if the error code hasn't been generated yet. Run `pnpm extract-error-codes` and try again.");
301
+ // TODO: Investigate if `as any` can be removed after https://github.com/DefinitelyTyped/DefinitelyTyped/issues/48634 is resolved.
302
+ this.to.throw('Minified MUI error', 'helper');
303
+ }
304
+ });
305
+ });
306
+ chai_1.default.use((chaiAPI, utils) => {
307
+ function addConsoleMatcher(matcherName, methodName) {
308
+ /**
309
+ * @param {string[]} expectedMessages
310
+ */
311
+ function matcher(expectedMessagesInput = []) {
312
+ // documented pattern to get the actual value of the assertion
313
+ // eslint-disable-next-line no-underscore-dangle
314
+ const callback = this._obj;
315
+ if (process.env.NODE_ENV !== 'production') {
316
+ const expectedMessages = typeof expectedMessagesInput === 'string'
317
+ ? [expectedMessagesInput]
318
+ : expectedMessagesInput.slice();
319
+ const unexpectedMessages = [];
320
+ // TODO Remove type once MUI X enables noImplicitAny
321
+ let caughtError = null;
322
+ this.assert(expectedMessages.length > 0, `Expected to call console.${methodName} but didn't provide messages. ` +
323
+ `If you don't expect any messages prefer \`expect().not.${matcherName}();\`.`, `Expected no call to console.${methodName} while also expecting messages.` +
324
+ 'Expected no call to console.error but provided messages. ' +
325
+ "If you want to make sure a certain message isn't logged prefer the positive. " +
326
+ 'By expecting certain messages you automatically expect that no other messages are logged',
327
+ // Not interested in a diff but the typings require the 4th parameter.
328
+ undefined);
329
+ // Ignore skipped messages in e.g. `[condition && 'foo']`
330
+ const remainingMessages = expectedMessages.filter((messageOrFalse) => {
331
+ return messageOrFalse !== false;
332
+ });
333
+ // eslint-disable-next-line no-console
334
+ const originalMethod = console[methodName];
335
+ let messagesMatched = 0;
336
+ const consoleMatcher = (format, ...args) => {
337
+ // Ignore legacy root deprecation warnings
338
+ // TODO: Remove once we no longer use legacy roots.
339
+ if (format.indexOf('Use createRoot instead.') !== -1 ||
340
+ format.indexOf('Use hydrateRoot instead.') !== -1) {
341
+ return;
342
+ }
343
+ const actualMessage = (0, format_util_1.default)(format, ...args);
344
+ const expectedMessage = remainingMessages.shift();
345
+ messagesMatched += 1;
346
+ // TODO Remove type once MUI X enables noImplicitAny
347
+ let message = null;
348
+ if (expectedMessage === undefined) {
349
+ message = `Expected no more error messages but got:\n"${actualMessage}"`;
350
+ }
351
+ else if (!actualMessage.includes(expectedMessage)) {
352
+ message = `Expected #${messagesMatched} "${expectedMessage}" to be included in \n"${actualMessage}"`;
353
+ }
354
+ if (message !== null) {
355
+ const error = new Error(message);
356
+ const { stack: fullStack } = error;
357
+ const fullStacktrace = fullStack.replace(`Error: ${message}\n`, '').split('\n');
358
+ const usefulStacktrace = fullStacktrace
359
+ //
360
+ // first line points to this frame which is irrelevant for the tester
361
+ .slice(1);
362
+ const usefulStack = `${message}\n${usefulStacktrace.join('\n')}`;
363
+ error.stack = usefulStack;
364
+ unexpectedMessages.push(error);
365
+ }
366
+ };
367
+ // eslint-disable-next-line no-console
368
+ console[methodName] = consoleMatcher;
369
+ try {
370
+ callback();
371
+ }
372
+ catch (error) {
373
+ caughtError = error;
374
+ }
375
+ finally {
376
+ // eslint-disable-next-line no-console
377
+ console[methodName] = originalMethod;
378
+ // unexpected thrown error takes precedence over unexpected console call
379
+ if (caughtError !== null) {
380
+ // not the same pattern as described in the block because we don't rethrow in the catch
381
+ // eslint-disable-next-line no-unsafe-finally
382
+ throw caughtError;
383
+ }
384
+ const formatMessages = (messages) => {
385
+ const formattedMessages = messages.map((message) => {
386
+ if (typeof message === 'string') {
387
+ return `"${message}"`;
388
+ }
389
+ // full Error
390
+ return `${message.stack}`;
391
+ });
392
+ return `\n\n - ${formattedMessages.join('\n\n- ')}`;
393
+ };
394
+ const shouldHaveWarned = utils.flag(this, 'negate') !== true;
395
+ // unreachable from expect().not.toWarnDev(messages)
396
+ if (unexpectedMessages.length > 0) {
397
+ const unexpectedMessageRecordedMessage = `Recorded unexpected console.${methodName} calls: ${formatMessages(unexpectedMessages)}`;
398
+ // chai will duplicate the stack frames from the unexpected calls in their assertion error
399
+ // it's not ideal but the test failure is located the second to last stack frame
400
+ // and the origin of the call is the second stackframe in the stack
401
+ this.assert(
402
+ // force chai to always trigger an assertion error
403
+ !shouldHaveWarned, unexpectedMessageRecordedMessage, unexpectedMessageRecordedMessage,
404
+ // Not interested in a diff but the typings require the 4th parameter.
405
+ undefined);
406
+ }
407
+ if (shouldHaveWarned) {
408
+ this.assert(remainingMessages.length === 0, `Could not match the following console.${methodName} calls. ` +
409
+ `Make sure previous actions didn't call console.${methodName} by wrapping them in expect(() => {}).not.${matcherName}(): ${formatMessages(remainingMessages)}`, `Impossible state reached in \`expect().${matcherName}()\`. ` +
410
+ `This is a bug in the matcher.`,
411
+ // Not interested in a diff but the typings require the 4th parameter.
412
+ undefined);
413
+ }
414
+ }
415
+ }
416
+ else {
417
+ // nothing to do in prod
418
+ // If there are still console calls than our test setup throws.
419
+ callback();
420
+ }
421
+ }
422
+ chai_1.default.Assertion.addMethod(matcherName, matcher);
423
+ }
424
+ /**
425
+ * @example expect(() => render()).toWarnDev('single message')
426
+ * @example expect(() => render()).toWarnDev(['first warning', 'then the second'])
427
+ */
428
+ addConsoleMatcher('toWarnDev', 'warn');
429
+ addConsoleMatcher('toErrorDev', 'error');
430
+ });
431
+ //# sourceMappingURL=initMatchers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initMatchers.js","sourceRoot":"","sources":["../src/initMatchers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,wDAA+B;AAC/B,oDAAuB;AACvB,8CAAsD;AACtD,sDAAwD;AACxD,iEAA4F;AAC5F,8DAAqC;AAErC,cAAI,CAAC,GAAG,CAAC,kBAAO,CAAC,CAAC;AAElB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAiH3C,SAAS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AAgC,GAAG,+BAA+B,UAAU,WAAW,cAAc,CACzG,kBAAkB,CACnB,EAAE,CAAC;wBACJ,0FAA0F;wBAC1F,gFAAgF;wBAChF,mEAAmE;wBACnE,IAAI,CAAC,MAAM;wBACT,kDAAkD;wBAClD,CAAC,gBAAgB,EACjB,gCAAgC,EAChC,gCAAgC;wBAChC,sEAAsE;wBACtE,SAAS,CACV,CAAC;oBACJ,CAAC;oBAED,IAAI,gBAAgB,EAAE,CAAC;wBACrB,IAAI,CAAC,MAAM,CACT,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAC9B,yCAAyC,UAAU,UAAU;4BAC3D,kDAAkD,UAAU,6CAA6C,WAAW,OAAO,cAAc,CACvI,iBAAiB,CAClB,EAAE,EACL,0CAA0C,WAAW,QAAQ;4BAC3D,+BAA+B;wBACjC,sEAAsE;wBACtE,SAAS,CACV,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,wBAAwB;gBACxB,+DAA+D;gBAC/D,QAAQ,EAAE,CAAC;YACb,CAAC;QACH,CAAC;QAED,cAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACvC,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=initMatchers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initMatchers.test.d.ts","sourceRoot":"","sources":["../src/initMatchers.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ const sinon_1 = require("sinon");
5
+ describe('custom matchers', () => {
6
+ const consoleSandbox = (0, sinon_1.createSandbox)();
7
+ beforeEach(() => {
8
+ // otherwise our global setup throws on unexpected calls in afterEach
9
+ consoleSandbox.stub(console, 'warn');
10
+ consoleSandbox.stub(console, 'error');
11
+ });
12
+ afterEach(() => {
13
+ consoleSandbox.restore();
14
+ });
15
+ describe('toErrorDev()', () => {
16
+ it('passes if the message is exactly the same', () => {
17
+ (0, chai_1.expect)(() => console.error('expected message')).toErrorDev('expected message');
18
+ });
19
+ it('passes if the message is a subset', () => {
20
+ (0, chai_1.expect)(() => console.error('expected message')).toErrorDev('pected messa');
21
+ });
22
+ it('passes if multiple messages are expected', () => {
23
+ (0, chai_1.expect)(() => {
24
+ console.error('expected message');
25
+ console.error('another message');
26
+ }).toErrorDev(['expected message', 'another message']);
27
+ });
28
+ it("fails if an expected console.error call wasn't recorded with a useful stacktrace", () => {
29
+ let caughtError;
30
+ try {
31
+ console.error('expected message');
32
+ (0, chai_1.expect)(() => { }).toErrorDev('expected message');
33
+ }
34
+ catch (error) {
35
+ caughtError = error;
36
+ }
37
+ (0, chai_1.expect)(caughtError).to.have.property('stack');
38
+ (0, chai_1.expect)(caughtError.stack).to.include('Could not match the following console.error calls. ' +
39
+ "Make sure previous actions didn't call console.error by wrapping them in expect(() => {}).not.toErrorDev(): \n\n" +
40
+ ' - "expected message"\n' +
41
+ ' at Context.');
42
+ // check that the top stackframe points to this test
43
+ // if this test is moved to another file the next assertion fails
44
+ (0, chai_1.expect)(caughtError.stack).to.match(/- "expected message"\s+at Context\.(<anonymous>|it) \(.+\/initMatchers\.test\.js:\d+:\d+\)/);
45
+ });
46
+ it('is case sensitive', () => {
47
+ let caughtError;
48
+ try {
49
+ (0, chai_1.expect)(() => console.error('expected Message')).toErrorDev('expected message');
50
+ }
51
+ catch (error) {
52
+ caughtError = error;
53
+ }
54
+ (0, chai_1.expect)(caughtError).to.have.property('stack');
55
+ (0, chai_1.expect)(caughtError.stack).to.include('Recorded unexpected console.error calls: \n\n' +
56
+ ' - Expected #1 "expected message" to be included in \n' +
57
+ '"expected Message"\n' +
58
+ ' at callback');
59
+ // check that the top stackframe points to this test
60
+ // if this test is moved to another file the next assertion fails
61
+ (0, chai_1.expect)(caughtError.stack).to.match(/"expected Message"\s+at callback \(.+\/initMatchers\.test\.js:\d+:\d+\)/);
62
+ });
63
+ it('fails if the order of calls does not match', () => {
64
+ (0, chai_1.expect)(() => {
65
+ (0, chai_1.expect)(() => {
66
+ console.error('another message');
67
+ console.error('expected message');
68
+ }).toErrorDev(['expected message', 'another message']);
69
+ }).to.throw('Recorded unexpected console.error calls');
70
+ });
71
+ it('fails if there are fewer messages than expected', () => {
72
+ (0, chai_1.expect)(() => {
73
+ (0, chai_1.expect)(() => {
74
+ console.error('expected message');
75
+ }).toErrorDev(['expected message', 'another message']);
76
+ }).to.throw('Could not match the following console.error calls');
77
+ });
78
+ it('passes if no messages were recorded if expected', () => {
79
+ (0, chai_1.expect)(() => { }).not.toErrorDev();
80
+ (0, chai_1.expect)(() => { }).not.toErrorDev([]);
81
+ });
82
+ it('fails if no arguments are used as a way of negating', () => {
83
+ (0, chai_1.expect)(() => {
84
+ (0, chai_1.expect)(() => { }).toErrorDev();
85
+ }).to.throw("Expected to call console.error but didn't provide messages. " +
86
+ "If you don't expect any messages prefer `expect().not.toErrorDev();");
87
+ });
88
+ it('fails if arguments are passed when negated', () => {
89
+ (0, chai_1.expect)(() => {
90
+ (0, chai_1.expect)(() => { }).not.toErrorDev('not unexpected?');
91
+ }).to.throw('Expected no call to console.error but provided messages. ' +
92
+ "If you want to make sure a certain message isn't logged prefer the positive. " +
93
+ 'By expecting certain messages you automatically expect that no other messages are logged');
94
+ });
95
+ it('ignores `false` messages', () => {
96
+ const isReact16 = false;
97
+ (0, chai_1.expect)(() => {
98
+ (0, chai_1.expect)(() => { }).toErrorDev([isReact16 && 'some legacy error message']);
99
+ }).not.to.throw();
100
+ });
101
+ });
102
+ });
103
+ //# sourceMappingURL=initMatchers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initMatchers.test.js","sourceRoot":"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CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CACT,8DAA8D;gBAC5D,qEAAqE,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,IAAA,aAAM,EAAC,GAAG,EAAE;gBACV,IAAA,aAAM,EAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CACT,2DAA2D;gBACzD,+EAA+E;gBAC/E,0FAA0F,CAC7F,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;YAClC,MAAM,SAAS,GAAG,KAAK,CAAC;YACxB,IAAA,aAAM,EAAC,GAAG,EAAE;gBACV,IAAA,aAAM,EAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,SAAS,IAAI,2BAA2B,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import * as DomTestingLibrary from '@testing-library/dom';
2
+ declare global {
3
+ namespace Chai {
4
+ interface Assertion {
5
+ /**
6
+ * Checks if the element handle is actually focused i.e. the element handle is pointing to `document.activeElement`.
7
+ */
8
+ toHaveFocus(): Promise<void>;
9
+ /**
10
+ * Checks if the element handle has the given attribute.
11
+ * @example expect($element).toHaveAttribute('aria-expanded') is like `[aria-expanded]` CSS selector
12
+ * @example expect($element).toHaveAttribute('aria-expanded', 'true') is like `[aria-expanded="true"]` CSS selector
13
+ */
14
+ toHaveAttribute(attributeName: string, attributeValue?: string): Promise<void>;
15
+ }
16
+ }
17
+ interface Window {
18
+ DomTestingLibrary: typeof DomTestingLibrary;
19
+ /**
20
+ * @example $element.evaluate(element => window.pageElementToString(element))
21
+ */
22
+ elementToString(element: Node | null | undefined): string | false;
23
+ }
24
+ }
25
+ //# sourceMappingURL=initPlaywrightMatchers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initPlaywrightMatchers.d.ts","sourceRoot":"","sources":["../src/initPlaywrightMatchers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAI1D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI,CAAC;QACb,UAAU,SAAS;YACjB;;eAEG;YACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B;;;;eAIG;YACH,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;SAChF;KACF;IAED,UAAU,MAAM;QACd,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;QAC5C;;WAEG;QACH,eAAe,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;KACnE;CACF"}