@rind-ui/testing 0.1.0 → 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.
@@ -1,4 +1,4 @@
1
- import { o as poll, r as describeBy, t as composeInPage } from "./compose-C7RIqRoi.mjs";
1
+ import { o as poll, r as describeBy, t as composeInPage } from "./compose-DPLnCCnJ.mjs";
2
2
  //#region src/adapters/chromium-tree.ts
3
3
  const toNode = (n) => ({
4
4
  role: n.role?.value ?? "",
@@ -199,7 +199,7 @@ function createPlaywrightEnv(getBase, { scope, anchor, modality, platform }, opt
199
199
  const byLocator = (root, by) => "role" in by ? root.getByRole(by.role, { ...by.name === void 0 ? {} : {
200
200
  name: by.name,
201
201
  exact: true
202
- } }) : root.getByText(by.text, { exact: true });
202
+ } }) : "part" in by ? root.locator(`[data-scope="${scope}"][data-part="${by.part}"]`) : root.getByText(by.text, { exact: true });
203
203
  const describeAll = (l) => l.evaluateAll((els) => els.map((el) => el.outerHTML.slice(0, 160)).join("\n"));
204
204
  /** What tells a navigation: the URL, the open pages, and the in-page log (fakeRouter). */
205
205
  const navigationState = async () => {
@@ -345,6 +345,7 @@ function createPlaywrightEnv(getBase, { scope, anchor, modality, platform }, opt
345
345
  attr: async (name) => (await now()).getAttribute(name),
346
346
  tagName: async () => (await now()).evaluate((el) => el.tagName.toLowerCase()),
347
347
  scoped: (scope, partName) => handle(`${scope}.${partName} in ${label}`, async () => (await now()).locator(`[data-scope="${scope}"][data-part="${partName}"]`)),
348
+ withAttr: (name, value) => handle(`[${name}] in ${label}`, async () => (await now()).locator(value === void 0 ? `[${name}]` : `[${name}="${value.replace(/["\\]/g, "\\$&")}"]`)),
348
349
  accessibleName: async () => {
349
350
  const { root } = await getBase();
350
351
  await ensureInPage(root);
@@ -1 +1 @@
1
- export { i as axNodeOf, a as chromiumTree, n as playwrightEnv } from "./playwright-CNUCI2Xe.mjs";
1
+ export { i as axNodeOf, a as chromiumTree, n as playwrightEnv } from "./playwright-C2LKzGS_.mjs";
package/dist/setup.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as navigationLog, n as installErrorLog, o as installAnnouncementLog } from "./dom-Ds2Cv9wy.mjs";
1
+ import { a as navigationLog, n as installErrorLog, o as installAnnouncementLog } from "./dom-DZtl6G1E.mjs";
2
2
  //#region src/setup.ts
3
3
  function define(target, name, value) {
4
4
  if (!target || Reflect.get(target, name) != null) return;
@@ -94,7 +94,30 @@ function resetRindGlobals() {
94
94
  }
95
95
  installErrorLog();
96
96
  installAnnouncementLog();
97
- const afterEachHook = g["afterEach"];
98
- if (typeof afterEachHook === "function") afterEachHook(resetRindGlobals);
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
+ }
99
122
  //#endregion
100
123
  export { RESETS, resetRindGlobals };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rind-ui/testing",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Test drivers and environment setup for rind-ui components (Testing Library and Playwright).",
5
5
  "license": "MIT",
6
6
  "author": "Watermelon Bros",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "dom-accessibility-api": "^0.7.1",
55
- "@rind-ui/core": "0.1.0"
55
+ "@rind-ui/core": "0.2.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/node": "^24.19.2",
@@ -61,7 +61,7 @@
61
61
  "react": "^19.3.0",
62
62
  "react-dom": "^19.3.0",
63
63
  "rolldown": "1.2.13",
64
- "@rind-ui/react": "0.1.0"
64
+ "@rind-ui/react": "0.2.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@testing-library/dom": ">=10",