@rind-ui/testing 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +15 -2
- package/dist/adapter-UPhu17S6.d.mts +152 -0
- package/dist/compose-DPLnCCnJ.mjs +111 -0
- package/dist/dist-DGqRlido.mjs +6978 -0
- package/dist/dom-BxnIjEBk.d.mts +28 -0
- package/dist/dom-DZtl6G1E.mjs +854 -0
- package/dist/dom.d.mts +2 -0
- package/dist/dom.mjs +1 -0
- package/dist/index.d.mts +3103 -0
- package/dist/index.mjs +2007 -0
- package/dist/inpage.iife.js +4 -0
- package/dist/playwright-C2LKzGS_.mjs +526 -0
- package/dist/playwright-CtIxjMKr.d.mts +14 -0
- package/dist/playwright.d.mts +29 -0
- package/dist/playwright.mjs +1 -0
- package/dist/setup.d.mts +9 -0
- package/dist/setup.mjs +123 -0
- package/package.json +92 -3
package/dist/setup.mjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { a as navigationLog, n as installErrorLog, o as installAnnouncementLog } from "./dom-DZtl6G1E.mjs";
|
|
2
|
+
//#region src/setup.ts
|
|
3
|
+
function define(target, name, value) {
|
|
4
|
+
if (!target || Reflect.get(target, name) != null) return;
|
|
5
|
+
Object.defineProperty(target, name, {
|
|
6
|
+
value,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const g = globalThis;
|
|
12
|
+
const proto = typeof Element === "undefined" ? void 0 : Element.prototype;
|
|
13
|
+
var NoopObserver = class {
|
|
14
|
+
observe() {}
|
|
15
|
+
unobserve() {}
|
|
16
|
+
disconnect() {}
|
|
17
|
+
takeRecords() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
define(g, "ResizeObserver", NoopObserver);
|
|
22
|
+
define(g, "IntersectionObserver", NoopObserver);
|
|
23
|
+
const noop = () => {};
|
|
24
|
+
define(proto, "scrollIntoView", noop);
|
|
25
|
+
define(proto, "scrollTo", noop);
|
|
26
|
+
define(proto, "scrollBy", noop);
|
|
27
|
+
if (typeof window !== "undefined") define(window, "scrollTo", noop);
|
|
28
|
+
define(proto, "getAnimations", () => []);
|
|
29
|
+
if (typeof document !== "undefined") define(document, "getAnimations", () => []);
|
|
30
|
+
if (typeof MouseEvent !== "undefined" && g["PointerEvent"] == null) {
|
|
31
|
+
class PointerEventPolyfill extends MouseEvent {
|
|
32
|
+
pointerId;
|
|
33
|
+
pointerType;
|
|
34
|
+
width;
|
|
35
|
+
height;
|
|
36
|
+
pressure;
|
|
37
|
+
isPrimary;
|
|
38
|
+
constructor(type, init = {}) {
|
|
39
|
+
super(type, init);
|
|
40
|
+
this.pointerId = init.pointerId ?? 1;
|
|
41
|
+
this.pointerType = init.pointerType ?? "mouse";
|
|
42
|
+
this.width = init.width ?? 1;
|
|
43
|
+
this.height = init.height ?? 1;
|
|
44
|
+
this.pressure = init.pressure ?? 0;
|
|
45
|
+
this.isPrimary = init.isPrimary ?? true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
define(g, "PointerEvent", PointerEventPolyfill);
|
|
49
|
+
}
|
|
50
|
+
define(proto, "setPointerCapture", noop);
|
|
51
|
+
define(proto, "releasePointerCapture", noop);
|
|
52
|
+
define(proto, "hasPointerCapture", () => false);
|
|
53
|
+
if (typeof window !== "undefined") {
|
|
54
|
+
define(window, "matchMedia", (query) => ({
|
|
55
|
+
matches: false,
|
|
56
|
+
media: query,
|
|
57
|
+
onchange: null,
|
|
58
|
+
addEventListener: noop,
|
|
59
|
+
removeEventListener: noop,
|
|
60
|
+
addListener: noop,
|
|
61
|
+
removeListener: noop,
|
|
62
|
+
dispatchEvent: () => false
|
|
63
|
+
}));
|
|
64
|
+
define(window, "visualViewport", {
|
|
65
|
+
get width() {
|
|
66
|
+
return window.innerWidth;
|
|
67
|
+
},
|
|
68
|
+
get height() {
|
|
69
|
+
return window.innerHeight;
|
|
70
|
+
},
|
|
71
|
+
offsetLeft: 0,
|
|
72
|
+
offsetTop: 0,
|
|
73
|
+
pageLeft: 0,
|
|
74
|
+
pageTop: 0,
|
|
75
|
+
scale: 1,
|
|
76
|
+
onresize: null,
|
|
77
|
+
onscroll: null,
|
|
78
|
+
addEventListener: noop,
|
|
79
|
+
removeEventListener: noop,
|
|
80
|
+
dispatchEvent: () => false
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Where rind-ui modules that keep document-level state (layer stack, scroll lock, focus
|
|
85
|
+
* trap stack, tooltip group) register how to reset it.
|
|
86
|
+
*/
|
|
87
|
+
const RESETS = Symbol.for("rind-ui.resets");
|
|
88
|
+
/** Clears every piece of rind-ui document-level state. Call after each test. */
|
|
89
|
+
function resetRindGlobals() {
|
|
90
|
+
const resets = Reflect.get(globalThis, RESETS);
|
|
91
|
+
for (const reset of resets ?? []) reset();
|
|
92
|
+
installAnnouncementLog().length = 0;
|
|
93
|
+
navigationLog().length = 0;
|
|
94
|
+
}
|
|
95
|
+
installErrorLog();
|
|
96
|
+
installAnnouncementLog();
|
|
97
|
+
/** The runner's afterEach: a global (Jest, Vitest with `globals`), else Vitest's export. */
|
|
98
|
+
async function runnerAfterEach() {
|
|
99
|
+
const global = g["afterEach"];
|
|
100
|
+
if (typeof global === "function") return global;
|
|
101
|
+
try {
|
|
102
|
+
return (await import("./dist-DGqRlido.mjs")).afterEach ?? null;
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* After each test: rind-ui's document-level state, and (unless opted out) Testing
|
|
109
|
+
* Library's `cleanup`, so a second `render` in a file does not leave the first tree in the
|
|
110
|
+
* document (drivers would then find two matches). Vitest without `globals` gets neither
|
|
111
|
+
* from Testing Library itself. Opt out with `globalThis.RIND_AUTO_CLEANUP = false` set
|
|
112
|
+
* before this file runs (an earlier setup file).
|
|
113
|
+
*/
|
|
114
|
+
const afterEachHook = await runnerAfterEach();
|
|
115
|
+
if (afterEachHook) {
|
|
116
|
+
afterEachHook(resetRindGlobals);
|
|
117
|
+
if (g["RIND_AUTO_CLEANUP"] !== false) try {
|
|
118
|
+
const { cleanup } = await import("@testing-library/react");
|
|
119
|
+
afterEachHook(cleanup);
|
|
120
|
+
} catch {}
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { RESETS, resetRindGlobals };
|
package/package.json
CHANGED
|
@@ -1,6 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rind-ui/testing",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Test drivers and environment setup for rind-ui components (Testing Library and Playwright).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Watermelon Bros",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/WatermelonBros/rind-ui.git",
|
|
10
|
+
"directory": "packages/testing"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/WatermelonBros/rind-ui#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/WatermelonBros/rind-ui/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"testing",
|
|
18
|
+
"testing-library",
|
|
19
|
+
"playwright",
|
|
20
|
+
"test-driver",
|
|
21
|
+
"accessibility"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"./dist/setup.mjs",
|
|
26
|
+
"./src/setup.ts"
|
|
27
|
+
],
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"@rind-ui/source": "./src/index.ts",
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./dom": {
|
|
38
|
+
"@rind-ui/source": "./src/dom.ts",
|
|
39
|
+
"types": "./dist/dom.d.mts",
|
|
40
|
+
"default": "./dist/dom.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./playwright": {
|
|
43
|
+
"@rind-ui/source": "./src/playwright.ts",
|
|
44
|
+
"types": "./dist/playwright.d.mts",
|
|
45
|
+
"default": "./dist/playwright.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./setup": {
|
|
48
|
+
"@rind-ui/source": "./src/setup.ts",
|
|
49
|
+
"types": "./dist/setup.d.mts",
|
|
50
|
+
"default": "./dist/setup.mjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"dom-accessibility-api": "^0.7.1",
|
|
55
|
+
"@rind-ui/core": "0.2.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^24.19.2",
|
|
59
|
+
"@types/react": "^19.3.0",
|
|
60
|
+
"@types/react-dom": "^19.3.0",
|
|
61
|
+
"react": "^19.3.0",
|
|
62
|
+
"react-dom": "^19.3.0",
|
|
63
|
+
"rolldown": "1.2.13",
|
|
64
|
+
"@rind-ui/react": "0.2.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@testing-library/dom": ">=10",
|
|
68
|
+
"@testing-library/user-event": ">=14",
|
|
69
|
+
"playwright": ">=1.40",
|
|
70
|
+
"@guidepup/virtual-screen-reader": ">=0.33"
|
|
71
|
+
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"@testing-library/dom": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@testing-library/user-event": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"playwright": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@guidepup/virtual-screen-reader": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "tsdown && node scripts/inpage.mjs",
|
|
91
|
+
"dev": "tsdown --watch",
|
|
92
|
+
"typecheck": "tsc --noEmit",
|
|
93
|
+
"inpage": "node scripts/inpage.mjs"
|
|
94
|
+
}
|
|
6
95
|
}
|