@ctrl/dom 0.1.4 → 0.1.6

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 (59) hide show
  1. package/dist/aria/_chunks/roles-list-BXCvPLJT.cjs +4 -0
  2. package/dist/aria/_chunks/roles-list-rVVxaIPs.js +4 -0
  3. package/dist/aria/index.cjs +1 -232
  4. package/dist/aria/index.js +1 -198
  5. package/dist/aria/internal.cjs +1 -69
  6. package/dist/aria/internal.js +1 -30
  7. package/dist/cli/_chunks/report-z52LF7nA.js +12 -0
  8. package/dist/cli/_chunks/rolldown-runtime-H3fMLYWS.js +1 -0
  9. package/dist/cli/ctrl-dom.js +2 -181
  10. package/dist/cli/jest-reporter.js +2 -54
  11. package/dist/cli/vitest-reporter.js +2 -81
  12. package/dist/dom/_chunks/src-sZY6a2LC.js +49 -0
  13. package/dist/dom/index.js +1 -3
  14. package/dist/dom/internal.js +1 -434
  15. package/dist/dom/types/window/clock.d.ts +2 -2
  16. package/dist/jest-dom/_chunks/matchers-CGTk9GX9.cjs +31 -0
  17. package/dist/jest-dom/_chunks/matchers-Chf0yHoo.js +31 -0
  18. package/dist/jest-dom/index.cjs +1 -5
  19. package/dist/jest-dom/index.js +1 -6
  20. package/dist/jest-dom/jest-globals.cjs +1 -6
  21. package/dist/jest-dom/jest-globals.js +1 -7
  22. package/dist/jest-dom/matchers.cjs +1 -53
  23. package/dist/jest-dom/matchers.js +1 -3
  24. package/dist/jest-dom/vitest.cjs +1 -6
  25. package/dist/jest-dom/vitest.js +1 -7
  26. package/dist/react/_chunks/pure-CCeTO5Mk.js +1 -0
  27. package/dist/react/_chunks/pure-DQzwul4s.cjs +1 -0
  28. package/dist/react/dont-cleanup-after-each.cjs +1 -3
  29. package/dist/react/dont-cleanup-after-each.js +1 -4
  30. package/dist/react/index.cjs +1 -47
  31. package/dist/react/index.js +1 -35
  32. package/dist/react/pure.cjs +1 -17
  33. package/dist/react/pure.js +1 -5
  34. package/dist/register/index.js +1 -11
  35. package/dist/register/pure.js +1 -147
  36. package/dist/testing-library/_chunks/aria-snapshot-diff--o7AL030.cjs +14 -0
  37. package/dist/testing-library/_chunks/aria-snapshot-diff-BV9IkeNc.js +14 -0
  38. package/dist/testing-library/agent.cjs +10 -720
  39. package/dist/testing-library/agent.js +10 -712
  40. package/dist/testing-library/index.cjs +19 -2459
  41. package/dist/testing-library/index.js +19 -2380
  42. package/dist/user-event/index.cjs +33 -3924
  43. package/dist/user-event/index.js +33 -3899
  44. package/dist/user-event/types/ctrl-dom.d.ts +1 -1
  45. package/dist/vitest-environment/_chunks/rolldown-runtime-BhWHdk3m.js +1 -0
  46. package/dist/vitest-environment/failure-snapshot.js +1 -42
  47. package/dist/vitest-environment/index.js +1 -185
  48. package/dist/vitest-environment/plugin.js +1 -90
  49. package/package.json +6 -6
  50. package/dist/aria/_chunks/roles-list-CYZF-l9K.js +0 -1503
  51. package/dist/aria/_chunks/roles-list-D4WCyRO_.cjs +0 -1754
  52. package/dist/cli/_chunks/report-DdncYfuJ.js +0 -93
  53. package/dist/dom/_chunks/src-Cp3oLry4.js +0 -47610
  54. package/dist/jest-dom/_chunks/matchers-CDnnXUfG.js +0 -2211
  55. package/dist/jest-dom/_chunks/matchers-D988Ducb.cjs +0 -2516
  56. package/dist/react/_chunks/pure-DZ97z2oT.cjs +0 -498
  57. package/dist/react/_chunks/pure-PtE2hivW.js +0 -420
  58. package/dist/testing-library/_chunks/aria-snapshot-diff-D7PzpXew.cjs +0 -1170
  59. package/dist/testing-library/_chunks/aria-snapshot-diff-Q8Wj33K0.js +0 -985
@@ -1,93 +0,0 @@
1
- import { relative, sep } from "node:path";
2
- import { stripVTControlCharacters } from "node:util";
3
-
4
- // src/report.ts
5
- /** Strip ANSI escape sequences. */
6
- function stripAnsi(text) {
7
- return stripVTControlCharacters(String(text));
8
- }
9
- const FRAME = /^\s*at (?:(.*?) \()?(?:file:\/\/)?(\/[^():]+|[A-Za-z]:\\[^():]+):(\d+):(\d+)\)?\s*$/;
10
- /**
11
- * `file:line:column`, relative to `root`, of the first stack frame in `testFile`, else of the first
12
- * frame outside node_modules and Node internals.
13
- */
14
- function firstProjectFrame(stack, root, testFile) {
15
- let fallback = null;
16
- for (const line of String(stack ?? "").split("\n")) {
17
- const m = FRAME.exec(line);
18
- if (m === null) continue;
19
- const file = m[2];
20
- if (file.includes(`${sep}node_modules${sep}`) || file.includes("/node_modules/")) continue;
21
- const at = `${relative(root, file) || file}:${m[3]}:${m[4]}`;
22
- if (testFile === void 0 || file === testFile) return at;
23
- fallback ??= at;
24
- }
25
- return fallback;
26
- }
27
- /** An error message without its stack frames (` at …` lines). */
28
- function messageWithoutFrames(text) {
29
- const lines = stripAnsi(text).split("\n");
30
- const out = [];
31
- for (const line of lines) if (!/^\s*at .+(:\d+:\d+\)?|\(<anonymous>\)|native\))\s*$/.test(line)) out.push(line);
32
- while (out.length > 0 && out[out.length - 1].trim() === "") out.pop();
33
- return out.join("\n");
34
- }
35
- function indent(text, prefix = " ") {
36
- return text.split("\n").map((line) => line === "" ? line : prefix + line).join("\n");
37
- }
38
- /** Keep at most `max` lines, noting how many were cut. */
39
- function budget(text, max) {
40
- const lines = text.split("\n");
41
- if (lines.length <= max) return text;
42
- return `${lines.slice(0, max).join("\n")}\n… ${lines.length - max} more lines`;
43
- }
44
- const CONSOLE_MAX_LINES = Number(process.env.CTRL_DOM_DEBUG_CONSOLE_LINES) > 0 ? Number(process.env.CTRL_DOM_DEBUG_CONSOLE_LINES) : 150;
45
- const FAILURE_MAX_LINES = 400;
46
- /** The report. */
47
- function formatReport(r) {
48
- const out = [];
49
- for (const f of r.errors) {
50
- out.push(`ERROR ${f.name}`, indent(budget(f.message, FAILURE_MAX_LINES)));
51
- if (f.at) out.push("", ` at ${f.at}`);
52
- out.push("");
53
- }
54
- for (const f of r.failures) {
55
- out.push(`FAIL ${f.name}`, indent(budget(f.message, FAILURE_MAX_LINES)));
56
- if (f.at) out.push("", ` at ${f.at}`);
57
- out.push("");
58
- }
59
- if (r.logs.length > 0) {
60
- let used = 0;
61
- let cut = 0;
62
- const parts = [];
63
- for (const log of r.logs) {
64
- const content = stripAnsi(log.content).replace(/\n$/, "");
65
- const lines = content.split("\n").length + 1;
66
- if (used + lines > CONSOLE_MAX_LINES) {
67
- cut++;
68
- continue;
69
- }
70
- used += lines;
71
- parts.push(`${log.type === "stderr" ? "stderr" : "stdout"} | ${log.name}`, indent(content));
72
- }
73
- out.push("Console output:", ...parts);
74
- if (cut > 0) out.push(`… ${cut} more console messages (CTRL_DOM_DEBUG_CONSOLE_LINES raises the budget)`);
75
- out.push("");
76
- }
77
- const counts = [
78
- r.failed && `${r.failed} failed`,
79
- r.passed && `${r.passed} passed`,
80
- r.skipped && `${r.skipped} skipped`
81
- ].filter(Boolean).join(", ") || "no tests ran";
82
- out.push(`${counts} · ${r.runner} · ${r.files.join(", ") || "(no test files)"} · ${(r.durationMs / 1e3).toFixed(1)} s`);
83
- return `${out.join("\n")}\n`;
84
- }
85
- /** A hint when failures came without the snapshot a failure should carry in agent mode. */
86
- function missingSnapshotHint(failures, runner) {
87
- if (failures.length === 0 || process.env.CTRL_DOM_DEBUG === void 0) return "";
88
- if (failures.some((f) => f.message.includes("when the test failed"))) return "";
89
- if (runner === "vitest") return "Note: no failure snapshots. Use ctrlDom() from \"@ctrl/dom/vitest\", or add \"@ctrl/dom/vitest-environment/failure-snapshot\" to test.setupFiles (the ctrl-dom environment is required).\n";
90
- return "Note: no failure snapshots. They need testEnvironment \"@ctrl/dom-jest-environment\" or preset \"@ctrl/dom\".\n";
91
- }
92
-
93
- export { stripAnsi as a, missingSnapshotHint as i, formatReport as n, messageWithoutFrames as r, firstProjectFrame as t };