@mui/internal-test-utils 2.0.12 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/KarmaReporterReactProfiler.d.ts.map +1 -1
- package/build/KarmaReporterReactProfiler.js +5 -7
- package/build/KarmaReporterReactProfiler.js.map +1 -1
- package/build/chai.types.d.ts.map +1 -1
- package/build/chaiPlugin.d.ts +2 -2
- package/build/chaiPlugin.d.ts.map +1 -1
- package/build/chaiPlugin.js +41 -7
- package/build/chaiPlugin.js.map +1 -1
- package/build/createRenderer.d.ts.map +1 -1
- package/build/createRenderer.js +1 -3
- package/build/createRenderer.js.map +1 -1
- package/build/describeConformance.d.ts.map +1 -1
- package/build/describeConformance.js +9 -6
- package/build/describeConformance.js.map +1 -1
- package/build/fireDiscreteEvent.d.ts +1 -1
- package/build/fireDiscreteEvent.d.ts.map +1 -1
- package/build/fireDiscreteEvent.js +9 -9
- package/build/fireDiscreteEvent.js.map +1 -1
- package/build/focusVisible.d.ts.map +1 -1
- package/build/focusVisible.js +3 -1
- package/build/focusVisible.js.map +1 -1
- package/build/initMatchers.js +36 -3
- package/build/initMatchers.js.map +1 -1
- package/build/initPlaywrightMatchers.d.ts.map +1 -1
- package/build/initPlaywrightMatchers.js +6 -6
- package/build/initPlaywrightMatchers.js.map +1 -1
- package/build/setupVitest.js.map +1 -1
- package/package.json +13 -9
- package/src/KarmaReporterReactProfiler.js +8 -7
- package/src/chai-augmentation.d.ts +8 -0
- package/src/chai.types.ts +1 -0
- package/src/chaiPlugin.ts +9 -9
- package/src/createRenderer.tsx +1 -3
- package/src/describeConformance.tsx +11 -6
- package/src/fireDiscreteEvent.ts +1 -1
- package/src/focusVisible.ts +3 -1
- package/src/initMatchers.ts +1 -1
- package/src/initPlaywrightMatchers.ts +8 -3
- package/src/setupVitest.ts +1 -1
- package/tsconfig.build.json +0 -1
- package/tsconfig.json +2 -1
|
@@ -8,7 +8,7 @@ exports.keyDown = keyDown;
|
|
|
8
8
|
exports.keyUp = keyUp;
|
|
9
9
|
exports.mouseDown = mouseDown;
|
|
10
10
|
exports.mouseUp = mouseUp;
|
|
11
|
-
const
|
|
11
|
+
const pure_1 = require("@testing-library/react/pure");
|
|
12
12
|
const reactMajor_1 = __importDefault(require("./reactMajor"));
|
|
13
13
|
const noWrapper = (callback) => callback();
|
|
14
14
|
/**
|
|
@@ -27,15 +27,15 @@ function withMissingActWarningsIgnored(callback) {
|
|
|
27
27
|
originalConsoleError.call(console, message, ...args);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
const originalConfig = (0,
|
|
31
|
-
(0,
|
|
30
|
+
const originalConfig = (0, pure_1.getConfig)();
|
|
31
|
+
(0, pure_1.configure)({
|
|
32
32
|
eventWrapper: noWrapper,
|
|
33
33
|
});
|
|
34
34
|
try {
|
|
35
35
|
callback();
|
|
36
36
|
}
|
|
37
37
|
finally {
|
|
38
|
-
(0,
|
|
38
|
+
(0, pure_1.configure)(originalConfig);
|
|
39
39
|
console.error = originalConsoleError;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -51,27 +51,27 @@ function withMissingActWarningsIgnored(callback) {
|
|
|
51
51
|
// -----------------------------------------
|
|
52
52
|
function click(...args) {
|
|
53
53
|
return withMissingActWarningsIgnored(() => {
|
|
54
|
-
|
|
54
|
+
pure_1.fireEvent.click(...args);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
function keyDown(...args) {
|
|
58
58
|
return withMissingActWarningsIgnored(() => {
|
|
59
|
-
|
|
59
|
+
pure_1.fireEvent.keyDown(...args);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function keyUp(...args) {
|
|
63
63
|
return withMissingActWarningsIgnored(() => {
|
|
64
|
-
|
|
64
|
+
pure_1.fireEvent.keyUp(...args);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
function mouseDown(...args) {
|
|
68
68
|
return withMissingActWarningsIgnored(() => {
|
|
69
|
-
|
|
69
|
+
pure_1.fireEvent.mouseDown(...args);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
function mouseUp(...args) {
|
|
73
73
|
return withMissingActWarningsIgnored(() => {
|
|
74
|
-
|
|
74
|
+
pure_1.fireEvent.mouseUp(...args);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
//# sourceMappingURL=fireDiscreteEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fireDiscreteEvent.js","sourceRoot":"","sources":["../src/fireDiscreteEvent.ts"],"names":[],"mappings":";;;;;AA+CA,sBAIC;AAED,0BAIC;AAED,sBAIC;AAED,8BAIC;AAED,0BAIC;AA3ED,
|
|
1
|
+
{"version":3,"file":"fireDiscreteEvent.js","sourceRoot":"","sources":["../src/fireDiscreteEvent.ts"],"names":[],"mappings":";;;;;AA+CA,sBAIC;AAED,0BAIC;AAED,sBAIC;AAED,8BAIC;AAED,0BAIC;AA3ED,sDAA8E;AAC9E,8DAAsC;AAEtC,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC;AAEvD;;;GAGG;AACH,SAAS,6BAA6B,CAAC,QAAoB;IACzD,IAAI,oBAAU,IAAI,EAAE,EAAE,CAAC;QACrB,QAAQ,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,MAAM,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC;IAC3C,OAAO,CAAC,KAAK,GAAG,SAAS,yBAAyB,CAAC,OAAO,EAAE,GAAG,IAAI;QACjE,MAAM,mBAAmB,GAAG,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACvD,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,IA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CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusVisible.d.ts","sourceRoot":"","sources":["../src/focusVisible.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"focusVisible.d.ts","sourceRoot":"","sources":["../src/focusVisible.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,EAAE,WAAW,QAQxD;AAED,wBAAgB,qBAAqB,SAIpC;AAED,wBAAgB,sBAAsB,SAErC;AAED;;GAEG;AACH,wBAAgB,qCAAqC,IAAI,OAAO,CAQ/D"}
|
package/build/focusVisible.js
CHANGED
|
@@ -8,7 +8,9 @@ const createRenderer_1 = require("./createRenderer");
|
|
|
8
8
|
function focusVisible(element) {
|
|
9
9
|
(0, createRenderer_1.act)(() => {
|
|
10
10
|
element.blur();
|
|
11
|
-
|
|
11
|
+
});
|
|
12
|
+
createRenderer_1.fireEvent.keyDown(document.body, { key: 'Tab' });
|
|
13
|
+
(0, createRenderer_1.act)(() => {
|
|
12
14
|
element.focus();
|
|
13
15
|
});
|
|
14
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusVisible.js","sourceRoot":"","sources":["../src/focusVisible.ts"],"names":[],"mappings":";;AAEA,+
|
|
1
|
+
{"version":3,"file":"focusVisible.js","sourceRoot":"","sources":["../src/focusVisible.ts"],"names":[],"mappings":";;AAEA,+BAQC;AAED,sDAIC;AAED,wDAEC;AAKD,sFAQC;AAjCD,qDAAkD;AAElD,SAAwB,YAAY,CAAC,OAAoB;IACvD,IAAA,oBAAG,EAAC,GAAG,EAAE;QACP,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,0BAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,IAAA,oBAAG,EAAC,GAAG,EAAE;QACP,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,qBAAqB;IACnC,qEAAqE;IACrE,sBAAsB;IACtB,0BAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,sBAAsB;IACpC,0BAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,SAAgB,qCAAqC;IACnD,IAAI,CAAC;QACH,4GAA4G;QAC5G,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/build/initMatchers.js
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
39
|
+
const chai = __importStar(require("chai"));
|
|
7
40
|
const chai_dom_1 = __importDefault(require("chai-dom"));
|
|
8
41
|
require("./chai.types");
|
|
9
42
|
const chaiPlugin_1 = __importDefault(require("./chaiPlugin"));
|
|
10
|
-
|
|
11
|
-
|
|
43
|
+
chai.use(chai_dom_1.default);
|
|
44
|
+
chai.use(chaiPlugin_1.default);
|
|
12
45
|
//# sourceMappingURL=initMatchers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initMatchers.js","sourceRoot":"","sources":["../src/initMatchers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initMatchers.js","sourceRoot":"","sources":["../src/initMatchers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,wDAA+B;AAC/B,wBAAsB;AACtB,8DAAsC;AAEtC,IAAI,CAAC,GAAG,CAAC,kBAAO,CAAC,CAAC;AAClB,IAAI,CAAC,GAAG,CAAC,oBAAU,CAAC,CAAC"}
|
|
@@ -1 +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;
|
|
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;IAEb,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"}
|
|
@@ -33,12 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const chai = __importStar(require("chai"));
|
|
37
|
+
chai.use((chaiAPI, utils) => {
|
|
38
|
+
chai.Assertion.addMethod('toHaveFocus', async function elementHandleIsFocused() {
|
|
39
39
|
const $elementOrHandle = utils.flag(this, 'object');
|
|
40
40
|
if ($elementOrHandle == null) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new chai.AssertionError(`Expected an element handle but got ${String($elementOrHandle)}.`);
|
|
42
42
|
}
|
|
43
43
|
const $element = typeof $elementOrHandle.then === 'function'
|
|
44
44
|
? await $elementOrHandle
|
|
@@ -53,10 +53,10 @@ chai_1.default.use((chaiAPI, utils) => {
|
|
|
53
53
|
});
|
|
54
54
|
this.assert(isFocused, `expected element to have focus`, `expected element to NOT have focus \n${stringifiedElement}`, stringifiedElement, stringifiedActiveElement);
|
|
55
55
|
});
|
|
56
|
-
|
|
56
|
+
chai.Assertion.addMethod('toHaveAttribute', async function elementHandleHasAttribute(attributeName, attributeValue) {
|
|
57
57
|
const $elementOrHandle = utils.flag(this, 'object');
|
|
58
58
|
if ($elementOrHandle == null) {
|
|
59
|
-
throw new
|
|
59
|
+
throw new chai.AssertionError(`Expected an element handle but got ${String($elementOrHandle)}.`);
|
|
60
60
|
}
|
|
61
61
|
const $element = typeof $elementOrHandle.then === 'function'
|
|
62
62
|
? await $elementOrHandle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initPlaywrightMatchers.js","sourceRoot":"","sources":["../src/initPlaywrightMatchers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"initPlaywrightMatchers.js","sourceRoot":"","sources":["../src/initPlaywrightMatchers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AA+B7B,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;IAC1B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,KAAK,UAAU,sBAAsB;QAC3E,MAAM,gBAAgB,GAA2C,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC5F,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;YAC7B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AC3B,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAClC,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,CAAC;KACF;IACD,mBAAmB;IACnB,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-test-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Utilities for MUI tests. This is an internal package not meant for general use.",
|
|
6
6
|
"main": "./build/index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mui/material-ui.git",
|
|
10
|
+
"directory": "packages-internal/test-utils"
|
|
11
|
+
},
|
|
7
12
|
"exports": {
|
|
8
13
|
".": "./build/index.js",
|
|
9
14
|
"./createDescribe": "./build/createDescribe.js",
|
|
@@ -29,8 +34,8 @@
|
|
|
29
34
|
"dependencies": {
|
|
30
35
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
31
36
|
"@babel/preset-typescript": "^7.27.1",
|
|
32
|
-
"@babel/register": "^7.
|
|
33
|
-
"@babel/runtime": "^7.28.
|
|
37
|
+
"@babel/register": "^7.28.3",
|
|
38
|
+
"@babel/runtime": "^7.28.4",
|
|
34
39
|
"@emotion/cache": "^11.14.0",
|
|
35
40
|
"@emotion/react": "^11.14.0",
|
|
36
41
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -39,27 +44,26 @@
|
|
|
39
44
|
"chai-dom": "^1.12.1",
|
|
40
45
|
"dom-accessibility-api": "^0.7.0",
|
|
41
46
|
"format-util": "^1.0.5",
|
|
42
|
-
"fs-extra": "^11.3.0",
|
|
43
47
|
"jsdom": "^26.1.0",
|
|
44
48
|
"lodash": "^4.17.21",
|
|
45
|
-
"mocha": "^11.7.
|
|
49
|
+
"mocha": "^11.7.2",
|
|
46
50
|
"prop-types": "^15.8.1",
|
|
47
51
|
"sinon": "^21.0.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@playwright/test": "^1.
|
|
54
|
+
"@playwright/test": "^1.55.1",
|
|
51
55
|
"@types/chai": "^4.3.20",
|
|
52
56
|
"@types/chai-dom": "^1.11.3",
|
|
53
57
|
"@types/format-util": "^1.0.4",
|
|
54
58
|
"@types/prop-types": "^15.7.15",
|
|
55
|
-
"@types/react": "^19.1.
|
|
56
|
-
"@types/react-dom": "^19.1.
|
|
59
|
+
"@types/react": "^19.1.13",
|
|
60
|
+
"@types/react-dom": "^19.1.9",
|
|
57
61
|
"@types/sinon": "^17.0.4",
|
|
58
62
|
"typescript": "^5.9.2"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
61
65
|
"@playwright/test": "^1.53.1",
|
|
62
|
-
"chai": "^4.5.0 || ^5.0.0",
|
|
66
|
+
"chai": "^4.5.0 || ^5.0.0 || ^6.0.0",
|
|
63
67
|
"react": "^18.0.0 || ^19.0.0",
|
|
64
68
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
65
69
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File is not transpiled.
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const
|
|
3
|
+
const fs = require('node:fs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {object} Browser
|
|
@@ -25,7 +25,7 @@ function KarmaReporterReactProfiler(karmaConfig) {
|
|
|
25
25
|
`Expected karma config to contain reactProfilerReporter.outputDir of type 'string' but got type '${typeof outputDir}'.`,
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {Browser} browser
|
|
@@ -44,7 +44,7 @@ function KarmaReporterReactProfiler(karmaConfig) {
|
|
|
44
44
|
this.onBrowserStart = (browser) => {
|
|
45
45
|
allRenders.set(browser.id, {});
|
|
46
46
|
// Create it on start to signal to users where the files will appear
|
|
47
|
-
|
|
47
|
+
fs.mkdirSync(path.join(outputDir, browser.name), { recursive: true });
|
|
48
48
|
|
|
49
49
|
browser.emitter.addListener('browser_info', handleBrowserInfo);
|
|
50
50
|
};
|
|
@@ -67,10 +67,11 @@ function KarmaReporterReactProfiler(karmaConfig) {
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
fs.mkdirSync(path.join(outputDir, browser.name), { recursive: true });
|
|
71
|
+
fs.writeFileSync(
|
|
72
|
+
path.join(outputDir, browser.name, `${Date.now()}.json`),
|
|
73
|
+
JSON.stringify(browserRenders, null, 2),
|
|
74
|
+
);
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import 'chai';
|
|
3
|
+
import type { AssertionError as RealAssertionError } from 'assertion-error';
|
|
4
|
+
|
|
5
|
+
declare module 'chai' {
|
|
6
|
+
// Looks like they forgot to export the AssertionError type in @types/chai
|
|
7
|
+
export const AssertionError: typeof RealAssertionError;
|
|
8
|
+
}
|
package/src/chai.types.ts
CHANGED
package/src/chaiPlugin.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isInaccessible } from '@testing-library/dom';
|
|
2
2
|
import { prettyDOM } from '@testing-library/react/pure';
|
|
3
|
-
import
|
|
4
|
-
import { AssertionError } from 'chai';
|
|
3
|
+
import * as chai from 'chai';
|
|
5
4
|
import { computeAccessibleDescription, computeAccessibleName } from 'dom-accessibility-api';
|
|
6
5
|
import formatUtil from 'format-util';
|
|
7
|
-
|
|
6
|
+
// avoid loading whole lodash, it takes ~50ms to initialize
|
|
7
|
+
import kebabCase from 'lodash.kebabcase';
|
|
8
8
|
import './chai.types';
|
|
9
9
|
|
|
10
10
|
const isKarma = Boolean(process.env.KARMA);
|
|
11
11
|
|
|
12
12
|
function isInJSDOM() {
|
|
13
|
-
return
|
|
13
|
+
return window.navigator.userAgent.includes('jsdom');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// chai#utils.elToString that looks like stringified elements in testing-library
|
|
@@ -21,7 +21,7 @@ function elementToString(element: Element | null | undefined) {
|
|
|
21
21
|
return String(element);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const chaiPlugin: Parameters<
|
|
24
|
+
const chaiPlugin: Parameters<typeof chai.use>[0] = (chaiAPI, utils) => {
|
|
25
25
|
const blockElements = new Set([
|
|
26
26
|
'html',
|
|
27
27
|
'address',
|
|
@@ -202,7 +202,7 @@ const chaiPlugin: Parameters<(typeof chaiType)['use']>[0] = (chaiAPI, utils) =>
|
|
|
202
202
|
// This is closer to actual CSS and required for getPropertyValue anyway.
|
|
203
203
|
const expectedStyle: Record<string, string> = {};
|
|
204
204
|
Object.keys(expectedStyleUnnormalized).forEach((cssProperty) => {
|
|
205
|
-
const hyphenCasedPropertyName =
|
|
205
|
+
const hyphenCasedPropertyName = kebabCase(cssProperty);
|
|
206
206
|
const isVendorPrefixed = /^(moz|ms|o|webkit)-/.test(hyphenCasedPropertyName);
|
|
207
207
|
const propertyName = isVendorPrefixed
|
|
208
208
|
? `-${hyphenCasedPropertyName}`
|
|
@@ -279,7 +279,7 @@ const chaiPlugin: Parameters<(typeof chaiType)['use']>[0] = (chaiAPI, utils) =>
|
|
|
279
279
|
|
|
280
280
|
const jsdomHint =
|
|
281
281
|
'Styles in JSDOM e.g. from `test:unit` are often misleading since JSDOM does not implement the Cascade nor actual CSS property value computation. ' +
|
|
282
|
-
'If results differ between real browsers and JSDOM, skip the test in JSDOM e.g. `if (
|
|
282
|
+
'If results differ between real browsers and JSDOM, skip the test in JSDOM e.g. `if (window.navigator.userAgent.includes("jsdom")) this.skip();`';
|
|
283
283
|
const shorthandHint =
|
|
284
284
|
'Browsers can compute shorthand properties differently. Prefer longhand properties e.g. `borderTopColor`, `borderRightColor` etc. instead of `border` or `border-color`.';
|
|
285
285
|
const messageHint = `${jsdomHint}\n${shorthandHint}`;
|
|
@@ -316,7 +316,7 @@ const chaiPlugin: Parameters<(typeof chaiType)['use']>[0] = (chaiAPI, utils) =>
|
|
|
316
316
|
const element = utils.flag(this, 'object') as HTMLElement;
|
|
317
317
|
if (element?.nodeType !== 1) {
|
|
318
318
|
// Same pre-condition for negated and unnegated assertion
|
|
319
|
-
throw new AssertionError(`Expected an Element but got ${String(element)}`);
|
|
319
|
+
throw new chai.AssertionError(`Expected an Element but got ${String(element)}`);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
assertMatchingStyles.call(this, element.style, expectedStyleUnnormalized, {
|
|
@@ -331,7 +331,7 @@ const chaiPlugin: Parameters<(typeof chaiType)['use']>[0] = (chaiAPI, utils) =>
|
|
|
331
331
|
const element = utils.flag(this, 'object') as HTMLElement;
|
|
332
332
|
if (element?.nodeType !== 1) {
|
|
333
333
|
// Same pre-condition for negated and unnegated assertion
|
|
334
|
-
throw new AssertionError(`Expected an Element but got ${String(element)}`);
|
|
334
|
+
throw new chai.AssertionError(`Expected an Element but got ${String(element)}`);
|
|
335
335
|
}
|
|
336
336
|
const computedStyle = element.ownerDocument.defaultView!.getComputedStyle(element);
|
|
337
337
|
|
package/src/createRenderer.tsx
CHANGED
|
@@ -92,10 +92,8 @@ interface Profiler {
|
|
|
92
92
|
class NoopProfiler implements Profiler {
|
|
93
93
|
id = 'noop';
|
|
94
94
|
|
|
95
|
-
// eslint-disable-next-line class-methods-use-this
|
|
96
95
|
onRender() {}
|
|
97
96
|
|
|
98
|
-
// eslint-disable-next-line class-methods-use-this
|
|
99
97
|
report() {}
|
|
100
98
|
}
|
|
101
99
|
|
|
@@ -270,7 +268,7 @@ function render(
|
|
|
270
268
|
);
|
|
271
269
|
const result: MuiRenderResult = {
|
|
272
270
|
...testingLibraryRenderResult,
|
|
273
|
-
user: userEvent.setup(),
|
|
271
|
+
user: userEvent.setup({ document }),
|
|
274
272
|
forceUpdate() {
|
|
275
273
|
traceSync('forceUpdate', () =>
|
|
276
274
|
testingLibraryRenderResult.rerender(
|
|
@@ -774,7 +774,7 @@ function testThemeStyleOverrides(
|
|
|
774
774
|
) {
|
|
775
775
|
describe('theme style overrides:', () => {
|
|
776
776
|
it("respect theme's styleOverrides custom state", async function test(t = {}) {
|
|
777
|
-
if (
|
|
777
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
778
778
|
// @ts-ignore
|
|
779
779
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
780
780
|
this?.skip?.() ?? t?.skip();
|
|
@@ -831,7 +831,7 @@ function testThemeStyleOverrides(
|
|
|
831
831
|
});
|
|
832
832
|
|
|
833
833
|
it("respect theme's styleOverrides slots", async function test(t = {}) {
|
|
834
|
-
if (
|
|
834
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
835
835
|
// @ts-ignore
|
|
836
836
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
837
837
|
this?.skip?.() ?? t?.skip();
|
|
@@ -944,7 +944,7 @@ function testThemeStyleOverrides(
|
|
|
944
944
|
});
|
|
945
945
|
|
|
946
946
|
it('overrideStyles does not replace each other in slots', async function test(t = {}) {
|
|
947
|
-
if (
|
|
947
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
948
948
|
// @ts-ignore
|
|
949
949
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
950
950
|
this?.skip?.() ?? t?.skip();
|
|
@@ -1027,7 +1027,7 @@ function testThemeVariants(
|
|
|
1027
1027
|
) {
|
|
1028
1028
|
describe('theme variants:', () => {
|
|
1029
1029
|
it("respect theme's variants", async function test(t = {}) {
|
|
1030
|
-
if (
|
|
1030
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
1031
1031
|
// @ts-ignore
|
|
1032
1032
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
1033
1033
|
this?.skip?.() ?? t?.skip();
|
|
@@ -1084,7 +1084,7 @@ function testThemeVariants(
|
|
|
1084
1084
|
});
|
|
1085
1085
|
|
|
1086
1086
|
it('supports custom variant', async function test(t = {}) {
|
|
1087
|
-
if (
|
|
1087
|
+
if (window.navigator.userAgent.includes('jsdom')) {
|
|
1088
1088
|
// @ts-ignore
|
|
1089
1089
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
1090
1090
|
this?.skip?.() ?? t?.skip();
|
|
@@ -1140,7 +1140,12 @@ function testThemeCustomPalette(
|
|
|
1140
1140
|
describe('theme extended palette:', () => {
|
|
1141
1141
|
it('should render without errors', function test(t = {}) {
|
|
1142
1142
|
const { render, ThemeProvider, createTheme } = getOptions();
|
|
1143
|
-
if (
|
|
1143
|
+
if (
|
|
1144
|
+
!window.navigator.userAgent.includes('jsdom') ||
|
|
1145
|
+
!render ||
|
|
1146
|
+
!ThemeProvider ||
|
|
1147
|
+
!createTheme
|
|
1148
|
+
) {
|
|
1144
1149
|
// @ts-ignore
|
|
1145
1150
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
1146
1151
|
this?.skip?.() ?? t?.skip();
|
package/src/fireDiscreteEvent.ts
CHANGED
package/src/focusVisible.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { act, fireEvent } from './createRenderer';
|
|
|
3
3
|
export default function focusVisible(element: HTMLElement) {
|
|
4
4
|
act(() => {
|
|
5
5
|
element.blur();
|
|
6
|
-
|
|
6
|
+
});
|
|
7
|
+
fireEvent.keyDown(document.body, { key: 'Tab' });
|
|
8
|
+
act(() => {
|
|
7
9
|
element.focus();
|
|
8
10
|
});
|
|
9
11
|
}
|
package/src/initMatchers.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as chai from 'chai';
|
|
2
2
|
import * as DomTestingLibrary from '@testing-library/dom';
|
|
3
3
|
import type { ElementHandle } from '@playwright/test';
|
|
4
4
|
|
|
5
5
|
// https://stackoverflow.com/a/46755166/3406963
|
|
6
6
|
declare global {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
7
8
|
namespace Chai {
|
|
8
9
|
interface Assertion {
|
|
9
10
|
/**
|
|
@@ -32,7 +33,9 @@ chai.use((chaiAPI, utils) => {
|
|
|
32
33
|
chai.Assertion.addMethod('toHaveFocus', async function elementHandleIsFocused() {
|
|
33
34
|
const $elementOrHandle: ElementHandle | Promise<ElementHandle> = utils.flag(this, 'object');
|
|
34
35
|
if ($elementOrHandle == null) {
|
|
35
|
-
throw new AssertionError(
|
|
36
|
+
throw new chai.AssertionError(
|
|
37
|
+
`Expected an element handle but got ${String($elementOrHandle)}.`,
|
|
38
|
+
);
|
|
36
39
|
}
|
|
37
40
|
const $element =
|
|
38
41
|
typeof ($elementOrHandle as Promise<any>).then === 'function'
|
|
@@ -65,7 +68,9 @@ chai.use((chaiAPI, utils) => {
|
|
|
65
68
|
async function elementHandleHasAttribute(attributeName: string, attributeValue?: string) {
|
|
66
69
|
const $elementOrHandle: ElementHandle | Promise<ElementHandle> = utils.flag(this, 'object');
|
|
67
70
|
if ($elementOrHandle == null) {
|
|
68
|
-
throw new AssertionError(
|
|
71
|
+
throw new chai.AssertionError(
|
|
72
|
+
`Expected an element handle but got ${String($elementOrHandle)}.`,
|
|
73
|
+
);
|
|
69
74
|
}
|
|
70
75
|
const $element =
|
|
71
76
|
typeof ($elementOrHandle as Promise<any>).then === 'function'
|
package/src/setupVitest.ts
CHANGED
|
@@ -23,7 +23,7 @@ testingLibrary.configure({
|
|
|
23
23
|
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
24
24
|
|
|
25
25
|
failOnConsole({
|
|
26
|
-
silenceMessage: (message) => {
|
|
26
|
+
silenceMessage: (message: string) => {
|
|
27
27
|
if (process.env.NODE_ENV === 'production') {
|
|
28
28
|
// TODO: mock scheduler
|
|
29
29
|
if (message.includes('act(...) is not supported in production builds of React')) {
|
package/tsconfig.build.json
CHANGED