@unframework.dev/testing 0.0.0-stage → 0.0.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/README.md +511 -2
- package/dist/browser/axe.js +34 -0
- package/dist/browser/behaviour.js +59 -0
- package/dist/browser/capabilities.js +58 -0
- package/dist/browser/clock.d.ts +17 -0
- package/dist/browser/clock.js +69 -0
- package/dist/browser/console.d.ts +27 -0
- package/dist/browser/console.js +142 -0
- package/dist/browser/determinism.js +108 -0
- package/dist/browser/element-timeout.js +28 -0
- package/dist/browser/events.js +68 -0
- package/dist/browser/geometry.js +135 -0
- package/dist/browser/keys.js +62 -0
- package/dist/browser/matchers.d.ts +39 -0
- package/dist/browser/matchers.js +78 -0
- package/dist/browser/navigation.js +38 -0
- package/dist/browser/parity.d.ts +10 -0
- package/dist/browser/parity.js +93 -0
- package/dist/browser/spec.d.ts +25 -0
- package/dist/browser/spec.js +38 -0
- package/dist/browser/target.d.ts +16 -0
- package/dist/browser/target.js +27 -0
- package/dist/browser/text-runs.js +68 -0
- package/dist/browser/thrown.js +71 -0
- package/dist/browser/trace.d.ts +21 -0
- package/dist/browser/trace.js +73 -0
- package/dist/browser/user.d.ts +45 -0
- package/dist/browser/user.js +184 -0
- package/dist/browser/view.d.ts +114 -0
- package/dist/browser/view.js +282 -0
- package/dist/browser/visual.d.ts +20 -0
- package/dist/browser/visual.js +36 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +90 -0
- package/dist/commands.d.ts +107 -0
- package/dist/config/broadcast.js +29 -0
- package/dist/config/cases.d.ts +28 -0
- package/dist/config/cases.js +94 -0
- package/dist/config/index.d.ts +81 -0
- package/dist/config/index.js +275 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +92 -0
- package/dist/dom/serialize.js +236 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +38 -0
- package/dist/harness.d.ts +184 -0
- package/dist/harness.js +53 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +12 -0
- package/dist/internal.d.ts +8 -0
- package/dist/internal.js +6 -0
- package/dist/layers.d.ts +183 -0
- package/dist/layers.js +241 -0
- package/dist/node/browser.d.ts +33 -0
- package/dist/node/browser.js +64 -0
- package/dist/node/commands.d.ts +137 -0
- package/dist/node/commands.js +139 -0
- package/dist/node/context.d.ts +28 -0
- package/dist/node/context.js +55 -0
- package/dist/node/events.d.ts +25 -0
- package/dist/node/events.js +50 -0
- package/dist/node/finished.d.ts +12 -0
- package/dist/node/finished.js +28 -0
- package/dist/node/index.d.ts +21 -0
- package/dist/node/index.js +20 -0
- package/dist/node/matrix.d.ts +219 -0
- package/dist/node/matrix.js +309 -0
- package/dist/node/mode.d.ts +101 -0
- package/dist/node/mode.js +201 -0
- package/dist/node/names.d.ts +4 -0
- package/dist/node/names.js +5 -0
- package/dist/node/policy.d.ts +44 -0
- package/dist/node/policy.js +140 -0
- package/dist/node/reporter.d.ts +101 -0
- package/dist/node/reporter.js +251 -0
- package/dist/node/summary.d.ts +99 -0
- package/dist/node/summary.js +352 -0
- package/dist/node/thrown.js +78 -0
- package/dist/node/viewport.d.ts +7 -0
- package/dist/node/viewport.js +8 -0
- package/dist/node/visual.d.ts +85 -0
- package/dist/node/visual.js +370 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/protocol.d.ts +23930 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/structs.d.ts +22 -0
- package/dist/node_modules/.pnpm/playwright-core@1.63.0/node_modules/playwright-core/types/types.d.ts +22221 -0
- package/dist/normalize/display.js +309 -0
- package/dist/normalize/index.d.ts +34 -0
- package/dist/normalize/index.js +38 -0
- package/dist/normalize/pipeline.d.ts +19 -0
- package/dist/normalize/pipeline.js +45 -0
- package/dist/normalize/print.js +103 -0
- package/dist/normalize/rules/angular-hosts.js +53 -0
- package/dist/normalize/rules/aria-hosts.js +48 -0
- package/dist/normalize/rules/comments.js +16 -0
- package/dist/normalize/rules/control-values.js +65 -0
- package/dist/normalize/rules/engine-aliases.js +34 -0
- package/dist/normalize/rules/framework-attributes.js +85 -0
- package/dist/normalize/rules/generated-ids.js +64 -0
- package/dist/normalize/rules/ordering.js +39 -0
- package/dist/normalize/rules/qwik-styles.js +21 -0
- package/dist/normalize/rules/qwik-templates.js +20 -0
- package/dist/normalize/rules/values.js +125 -0
- package/dist/normalize/rules/whitespace.js +381 -0
- package/dist/normalize/style.js +121 -0
- package/dist/normalize/targets.d.ts +8 -0
- package/dist/normalize/targets.js +17 -0
- package/dist/normalize/tree.d.ts +1 -0
- package/dist/normalize/tree.js +151 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +149 -0
- package/dist/ssr/index.d.ts +10 -0
- package/dist/ssr/index.js +103 -0
- package/dist/ssr/spec.d.ts +1 -0
- package/dist/ssr/spec.js +7 -0
- package/dist/targets/angular.d.ts +1 -0
- package/dist/targets/angular.js +5 -0
- package/dist/targets/astro.d.ts +1 -0
- package/dist/targets/astro.js +5 -0
- package/dist/targets/qwik.d.ts +1 -0
- package/dist/targets/qwik.js +5 -0
- package/dist/targets/react.d.ts +1 -0
- package/dist/targets/react.js +5 -0
- package/dist/targets/solid.d.ts +1 -0
- package/dist/targets/solid.js +5 -0
- package/dist/targets/svelte.d.ts +1 -0
- package/dist/targets/svelte.js +5 -0
- package/dist/targets/vue.d.ts +1 -0
- package/dist/targets/vue.js +5 -0
- package/dist/visual-types.d.ts +92 -0
- package/dist/visual-types.js +24 -0
- package/package.json +135 -3
package/dist/setup.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { caseOfFile } from "./harness.js";
|
|
2
|
+
import { currentTarget } from "./browser/target.js";
|
|
3
|
+
import { beginSpecFileConsole, beginTestConsole, describeConsole, endSpecFileConsole, endTestConsole, installConsoleCapture, unexpectedConsole } from "./browser/console.js";
|
|
4
|
+
import { BROWSER_LAYERS, recordLayer, recordStandIn } from "./layers.js";
|
|
5
|
+
import { noOutputReason, requiredSkip, standInCause } from "./browser/capabilities.js";
|
|
6
|
+
import { restoreClock } from "./browser/clock.js";
|
|
7
|
+
import { prepareSpecFile } from "./browser/determinism.js";
|
|
8
|
+
import { installNavigationGuard, takePreventedNavigations } from "./browser/navigation.js";
|
|
9
|
+
import { closeTraces } from "./browser/trace.js";
|
|
10
|
+
import { releaseKeys } from "./browser/user.js";
|
|
11
|
+
import { cleanup } from "./browser/view.js";
|
|
12
|
+
import { installMatchers } from "./browser/matchers.js";
|
|
13
|
+
import { judgeTest } from "./browser/behaviour.js";
|
|
14
|
+
import { boundElementTimeout } from "./browser/element-timeout.js";
|
|
15
|
+
import { afterAll, afterEach, aroundAll, aroundEach, beforeAll, beforeEach, inject } from "vitest";
|
|
16
|
+
import { commands, userEvent } from "vitest/browser";
|
|
17
|
+
//#region src/setup.ts
|
|
18
|
+
installConsoleCapture();
|
|
19
|
+
beginSpecFileConsole();
|
|
20
|
+
boundElementTimeout();
|
|
21
|
+
installMatchers();
|
|
22
|
+
installNavigationGuard();
|
|
23
|
+
aroundAll(async (runSuite, {}, suite) => {
|
|
24
|
+
await runSuite();
|
|
25
|
+
await commands.ufSpecFinished({ case: caseOfFile(suite.file.filepath, inject("ufHarness")) });
|
|
26
|
+
});
|
|
27
|
+
beforeAll(async ({}, suite) => {
|
|
28
|
+
await prepareSpecFile(await emulateColorScheme(suite.file.filepath));
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Emulates the colour scheme the spec file's case opts into (`case.json`'s `colorScheme`, ADR-0061),
|
|
32
|
+
* `light` by default, before anything mounts, and returns it for the startup check.
|
|
33
|
+
*/
|
|
34
|
+
async function emulateColorScheme(file) {
|
|
35
|
+
const harness = inject("ufHarness");
|
|
36
|
+
const scheme = harness.cases[caseOfFile(file, harness)]?.colorScheme ?? "light";
|
|
37
|
+
await commands.ufColorScheme(scheme);
|
|
38
|
+
return scheme;
|
|
39
|
+
}
|
|
40
|
+
beforeEach(({ task, skip }) => {
|
|
41
|
+
beginTestConsole();
|
|
42
|
+
closeTraces();
|
|
43
|
+
const requires = task.meta.ufRequires;
|
|
44
|
+
const subject = subjectOf(task);
|
|
45
|
+
const reason = noOutputReason(subject.case) ?? (requires ? requiredSkip(requires) : void 0);
|
|
46
|
+
if (reason === void 0) {
|
|
47
|
+
const cause = standInCause(subject.case);
|
|
48
|
+
if (cause !== void 0) recordStandIn(task, subject, cause);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (const layer of BROWSER_LAYERS) recordLayer(task, subject, layer, {
|
|
52
|
+
status: "skip",
|
|
53
|
+
reason
|
|
54
|
+
});
|
|
55
|
+
task.meta.uf.skipped = reason;
|
|
56
|
+
skip(reason);
|
|
57
|
+
});
|
|
58
|
+
/** The tests this file's afterEach has judged. */
|
|
59
|
+
const judged = /* @__PURE__ */ new WeakSet();
|
|
60
|
+
afterEach(async ({ task }) => {
|
|
61
|
+
judged.add(task);
|
|
62
|
+
await afterTest(task);
|
|
63
|
+
});
|
|
64
|
+
aroundEach(async (runTest, { task }) => {
|
|
65
|
+
await runTest();
|
|
66
|
+
if (!judged.has(task)) await afterTest(task);
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Unmounts what the test mounted, restores the real intervals a view's clock faked, resets the
|
|
70
|
+
* input, records L9's leftover steps, L13 and then L8, and fails the test with every failed
|
|
71
|
+
* layer. Throwing from afterEach fails the test (verified by the browser-projects spike). A test
|
|
72
|
+
* skipped by capability ran nothing: it has recorded every layer, and the console's entries are
|
|
73
|
+
* the next test's to judge.
|
|
74
|
+
*/
|
|
75
|
+
async function afterTest(task) {
|
|
76
|
+
if (task.meta.uf?.skipped !== void 0) return;
|
|
77
|
+
let cleanupError;
|
|
78
|
+
try {
|
|
79
|
+
await cleanup();
|
|
80
|
+
} catch (error) {
|
|
81
|
+
cleanupError = error;
|
|
82
|
+
}
|
|
83
|
+
restoreClock();
|
|
84
|
+
await resetInput();
|
|
85
|
+
await settleTeardown();
|
|
86
|
+
const subject = subjectOf(task);
|
|
87
|
+
for (const message of closeTraces()) recordLayer(task, subject, "L9", {
|
|
88
|
+
status: "fail",
|
|
89
|
+
message
|
|
90
|
+
});
|
|
91
|
+
const unexpected = unexpectedConsole();
|
|
92
|
+
endTestConsole();
|
|
93
|
+
recordLayer(task, subject, "L13", unexpected.length ? {
|
|
94
|
+
status: "fail",
|
|
95
|
+
message: describeConsole(unexpected)
|
|
96
|
+
} : { status: "pass" });
|
|
97
|
+
judgeTest(task, subject, cleanupError, takePreventedNavigations());
|
|
98
|
+
}
|
|
99
|
+
/** The case and target a test verifies, with the run's quarantine. */
|
|
100
|
+
function subjectOf(task) {
|
|
101
|
+
const harness = inject("ufHarness");
|
|
102
|
+
return {
|
|
103
|
+
case: caseOfFile(task.file.filepath, harness),
|
|
104
|
+
target: currentTarget(),
|
|
105
|
+
quarantine: harness.quarantine
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Leaves the page as the next test expects it, since every test of a file shares it: the mouse
|
|
110
|
+
* in the frame's corner, off every root (a hover changes pixels and `:hover` geometry), no key
|
|
111
|
+
* held, and the focus nowhere, with the frame focused again (a blur leaves the sequential focus
|
|
112
|
+
* where it was, so a later Tab would start there, or leave the frame).
|
|
113
|
+
*/
|
|
114
|
+
async function resetInput() {
|
|
115
|
+
await commands.ufResetInput();
|
|
116
|
+
await releaseKeys();
|
|
117
|
+
await userEvent.cleanup();
|
|
118
|
+
const active = document.activeElement;
|
|
119
|
+
if (active instanceof HTMLElement || active instanceof SVGElement) active.blur();
|
|
120
|
+
window.focus();
|
|
121
|
+
}
|
|
122
|
+
afterAll(async ({}, suite) => {
|
|
123
|
+
await settleTeardown();
|
|
124
|
+
const late = unexpectedConsole();
|
|
125
|
+
endTestConsole();
|
|
126
|
+
const file = suite.file;
|
|
127
|
+
const harness = inject("ufHarness");
|
|
128
|
+
const caseId = caseOfFile(file.filepath, harness);
|
|
129
|
+
endSpecFileConsole(caseId);
|
|
130
|
+
if (!late.length) return;
|
|
131
|
+
const recorded = recordLayer(file, {
|
|
132
|
+
case: caseId,
|
|
133
|
+
target: currentTarget(),
|
|
134
|
+
quarantine: harness.quarantine
|
|
135
|
+
}, "L13", {
|
|
136
|
+
status: "fail",
|
|
137
|
+
message: `after the last test of this file (a late teardown or an afterAll hook): ${describeConsole(late)}`
|
|
138
|
+
});
|
|
139
|
+
if (recorded.status === "fail") throw new Error(`L13: ${recorded.message}`);
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* Lets work a teardown scheduled run before the console is judged: a task, then a frame. A
|
|
143
|
+
* framework scheduler's warning after unmount then lands in the test that unmounted.
|
|
144
|
+
*/
|
|
145
|
+
async function settleTeardown() {
|
|
146
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
147
|
+
await new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SsrCase } from "../harness.js";
|
|
2
|
+
//#region src/ssr/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Declares the server render's tests for `cases`, in a `describe` titled `ssr [<target>]`, as
|
|
5
|
+
* `describeTargets` titles its own. It reads the project's provided `target`, `ufHarness` and
|
|
6
|
+
* `ufServer`, and throws in a project that lacks them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function describeServerRender(cases: readonly SsrCase[]): void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export type { SsrCase };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ssrScenarios } from "../harness.js";
|
|
2
|
+
import { sharedArtefactContext } from "../node/context.js";
|
|
3
|
+
import { diffLines } from "../diff.js";
|
|
4
|
+
import { settleArtefact } from "../node/policy.js";
|
|
5
|
+
import { formatConsoleArgs } from "../browser/console.js";
|
|
6
|
+
import { checkLayers } from "../layers.js";
|
|
7
|
+
import { isNormalizeTarget } from "../normalize/targets.js";
|
|
8
|
+
import { normalizeHtml } from "../normalize/index.js";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { beforeAll, describe, inject, it } from "vitest";
|
|
11
|
+
//#region src/ssr/index.ts
|
|
12
|
+
/**
|
|
13
|
+
* Declares the server render's tests for `cases`, in a `describe` titled `ssr [<target>]`, as
|
|
14
|
+
* `describeTargets` titles its own. It reads the project's provided `target`, `ufHarness` and
|
|
15
|
+
* `ufServer`, and throws in a project that lacks them.
|
|
16
|
+
*/
|
|
17
|
+
function describeServerRender(cases) {
|
|
18
|
+
const target = inject("target");
|
|
19
|
+
if (!isNormalizeTarget(target)) throw new Error(`The normaliser does not know the target "${target}": add its noise rules first.`);
|
|
20
|
+
const harness = inject("ufHarness");
|
|
21
|
+
const server = inject("ufServer");
|
|
22
|
+
if (server === void 0) throw new Error(`[uf] The ssr:${target} project provides no "ufServer": the server render runs only in an ssr project of the harness or of defineTestConfig.`);
|
|
23
|
+
const loadRenderer = rendererOf(server);
|
|
24
|
+
/**
|
|
25
|
+
* Renders once, collecting console.warn and console.error into `messages` (the originals still
|
|
26
|
+
* print). Tests in a file run one at a time, so patching the console is safe.
|
|
27
|
+
*/
|
|
28
|
+
async function render(component, props, messages) {
|
|
29
|
+
const originals = {
|
|
30
|
+
warn: console.warn,
|
|
31
|
+
error: console.error
|
|
32
|
+
};
|
|
33
|
+
for (const level of ["warn", "error"]) console[level] = (...args) => {
|
|
34
|
+
messages.push(`console.${level}: ${formatConsoleArgs(args)}`);
|
|
35
|
+
originals[level].apply(console, args);
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const html = await (await loadRenderer())(component, { props });
|
|
39
|
+
if (typeof html !== "string") throw new Error(`The ${target} renderer returned ${typeof html}, not HTML.`);
|
|
40
|
+
return html;
|
|
41
|
+
} finally {
|
|
42
|
+
console.warn = originals.warn;
|
|
43
|
+
console.error = originals.error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
describe(`ssr [${target}]`, () => {
|
|
47
|
+
beforeAll(async () => {
|
|
48
|
+
await loadRenderer().catch(() => void 0);
|
|
49
|
+
}, 3e5);
|
|
50
|
+
for (const info of cases) {
|
|
51
|
+
const config = harness.cases[info.id] ?? {};
|
|
52
|
+
for (const [scenario, { props = {} }] of Object.entries(ssrScenarios(config))) it(`${info.id} › ${scenario}`, async ({ task }) => {
|
|
53
|
+
if (info.failure !== void 0) throw new Error(info.failure);
|
|
54
|
+
const messages = [];
|
|
55
|
+
let rendered = false;
|
|
56
|
+
await checkLayers(task, {
|
|
57
|
+
case: info.id,
|
|
58
|
+
target,
|
|
59
|
+
quarantine: harness.quarantine
|
|
60
|
+
}, {
|
|
61
|
+
async L6() {
|
|
62
|
+
if (info.skip !== void 0) return { skip: info.skip };
|
|
63
|
+
const component = (await import(
|
|
64
|
+
/* @vite-ignore */
|
|
65
|
+
info.source
|
|
66
|
+
)).default;
|
|
67
|
+
const first = await render(component, props, messages);
|
|
68
|
+
const second = await render(component, props, messages);
|
|
69
|
+
rendered = true;
|
|
70
|
+
const html = normalizeHtml(first, { target });
|
|
71
|
+
const again = normalizeHtml(second, { target });
|
|
72
|
+
if (html !== again) throw new Error(`Two renders of the same props differ:\n${diffLines(html, again)}`);
|
|
73
|
+
const outcome = settleArtefact(join(info.dir, "__expected__", `ssr.${scenario}.html`), html, sharedArtefactContext(harness, target, info.id));
|
|
74
|
+
if (!outcome.pass) throw new Error(outcome.message);
|
|
75
|
+
},
|
|
76
|
+
L13: () => {
|
|
77
|
+
if (!messages.length && !rendered) return { skip: info.skip ?? "the component did not render (L6)" };
|
|
78
|
+
if (messages.length) throw new Error(`${messages.length} console message(s) during the server render:\n ${messages.join("\n ")}`);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The target's renderer, imported once, on first use, through the project's Vite pipeline (one
|
|
87
|
+
* framework copy).
|
|
88
|
+
*/
|
|
89
|
+
function rendererOf(server) {
|
|
90
|
+
let renderer;
|
|
91
|
+
return () => {
|
|
92
|
+
renderer ??= import(
|
|
93
|
+
/* @vite-ignore */
|
|
94
|
+
server
|
|
95
|
+
).then((module) => {
|
|
96
|
+
if (typeof module.renderToString !== "function") throw new Error(`${server} does not export renderToString.`);
|
|
97
|
+
return module.renderToString;
|
|
98
|
+
});
|
|
99
|
+
return renderer;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { describeServerRender };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/ssr/spec.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { describeServerRender } from "./index.js";
|
|
2
|
+
import { inject } from "vitest";
|
|
3
|
+
//#region src/ssr/spec.ts
|
|
4
|
+
const cases = inject("ufSsrCases");
|
|
5
|
+
if (cases === void 0) throw new Error(`[uf] The ssr:${inject("target")} project provides no "ufSsrCases": this spec runs only in an ssr project of defineTestConfig.`);
|
|
6
|
+
describeServerRender(cases);
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/visual-types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* L10's skip reason for the reference with live pixels: its capture is the expectation the
|
|
4
|
+
* followers compare against, so nothing was compared, and a pass would claim otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LIVE_REFERENCE_SKIP = "live pixels: the reference's capture is this run's expectation";
|
|
7
|
+
/**
|
|
8
|
+
* L10's skip on a follower whose reference project is in the run but never finished the case's
|
|
9
|
+
* spec file (ADR-0091): there was nothing to compare with. The summary never accepts it, and
|
|
10
|
+
* folds every such cell into one problem that names the reference project (`REFERENCE_NOT_RUN_SKIP`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function referenceNotRunSkip(project: string): string;
|
|
13
|
+
/** Matches {@link referenceNotRunSkip}'s reason; group 1 is the reference project. */
|
|
14
|
+
export declare const REFERENCE_NOT_RUN_SKIP: RegExp;
|
|
15
|
+
/**
|
|
16
|
+
* Why L10 skips the font audit outside Chromium (ADR-0066). The audit asks CDP which font drew
|
|
17
|
+
* each glyph; Firefox and WebKit have no such protocol, and `document.fonts` only says a font
|
|
18
|
+
* loaded, not that the text used it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FONT_AUDIT_SKIP = "CDP reports the font each glyph used, and only Chromium has CDP";
|
|
21
|
+
/** `[x, y, width, height]`, relative to the capture container. */
|
|
22
|
+
export type GeometryBox = [x: number, y: number, width: number, height: number];
|
|
23
|
+
/**
|
|
24
|
+
* One element (its border box and computed styles), text node (one box per line fragment), or
|
|
25
|
+
* `::before` or `::after` pseudo-element (its computed styles and `content`: the DOM gives it
|
|
26
|
+
* no box).
|
|
27
|
+
*/
|
|
28
|
+
export interface GeometryNode {
|
|
29
|
+
box?: GeometryBox | GeometryBox[];
|
|
30
|
+
style?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/** The committed `__expected__/geometry.<name>.json`. */
|
|
33
|
+
export interface GeometrySnapshot {
|
|
34
|
+
version: 1;
|
|
35
|
+
nodes: Record<string, GeometryNode>;
|
|
36
|
+
}
|
|
37
|
+
/** A pixel tolerance; zero by default, and never without a reason. */
|
|
38
|
+
export interface PixelTolerance {
|
|
39
|
+
maxDiffPixels: number;
|
|
40
|
+
reason: string;
|
|
41
|
+
}
|
|
42
|
+
/** What the browser sends to `ufVisualCapture`. */
|
|
43
|
+
export interface CaptureRequest {
|
|
44
|
+
/** The serialised locator of the capture container. */
|
|
45
|
+
element: {
|
|
46
|
+
selector: string;
|
|
47
|
+
locator: string;
|
|
48
|
+
};
|
|
49
|
+
case: string;
|
|
50
|
+
/** The scenario, such as `"initial"`. */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Captured in the browser right before the command. */
|
|
53
|
+
geometry: GeometrySnapshot;
|
|
54
|
+
/** The marker attribute value on the container, which the font audit queries. */
|
|
55
|
+
marker: string;
|
|
56
|
+
tolerance?: PixelTolerance;
|
|
57
|
+
}
|
|
58
|
+
/** How a capture ended. */
|
|
59
|
+
export type CaptureOutcome = "matched" | "matched-within-tolerance" | "published-reference" | "wrote-reference" | "refused-write" | "missing-artefact" | "missing-reference-capture" | "reference-not-run" | "geometry-mismatch" | "pixel-mismatch" | "size-mismatch" | "font-fallback" | "unstable";
|
|
60
|
+
/** An image a failed capture leaves behind, in the shape Vitest's visual artifacts use. */
|
|
61
|
+
export interface CaptureAttachment {
|
|
62
|
+
name: "reference" | "actual" | "diff";
|
|
63
|
+
path: string;
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
}
|
|
67
|
+
/** One difference between two geometry snapshots, at an element path. */
|
|
68
|
+
export interface GeometryDelta {
|
|
69
|
+
path: string;
|
|
70
|
+
/** `box`, `(node)` for an element on one side only, or a computed style's name. */
|
|
71
|
+
property: string;
|
|
72
|
+
expected: unknown;
|
|
73
|
+
actual: unknown;
|
|
74
|
+
}
|
|
75
|
+
/** What `ufVisualCapture` returns. */
|
|
76
|
+
export interface CaptureResult {
|
|
77
|
+
pass: boolean;
|
|
78
|
+
/** `check+baseline`, `update+live`, …: how the run treated this capture. */
|
|
79
|
+
mode: string;
|
|
80
|
+
role: "reference" | "follower";
|
|
81
|
+
outcome: CaptureOutcome;
|
|
82
|
+
message: string;
|
|
83
|
+
diffPixels?: number;
|
|
84
|
+
attachments: CaptureAttachment[];
|
|
85
|
+
/** `reference-not-run`: the reference's browser project, which did not finish the case. */
|
|
86
|
+
referenceProject?: string;
|
|
87
|
+
/** A failed comparison: the geometry and computed-style deltas, which may be none. */
|
|
88
|
+
deltas?: GeometryDelta[];
|
|
89
|
+
/** Where the capture was written, when its location keeps every capture (ADR-0087). */
|
|
90
|
+
capture?: string;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/visual-types.ts
|
|
2
|
+
/**
|
|
3
|
+
* L10's skip reason for the reference with live pixels: its capture is the expectation the
|
|
4
|
+
* followers compare against, so nothing was compared, and a pass would claim otherwise.
|
|
5
|
+
*/
|
|
6
|
+
const LIVE_REFERENCE_SKIP = "live pixels: the reference's capture is this run's expectation";
|
|
7
|
+
/**
|
|
8
|
+
* L10's skip on a follower whose reference project is in the run but never finished the case's
|
|
9
|
+
* spec file (ADR-0091): there was nothing to compare with. The summary never accepts it, and
|
|
10
|
+
* folds every such cell into one problem that names the reference project (`REFERENCE_NOT_RUN_SKIP`).
|
|
11
|
+
*/
|
|
12
|
+
function referenceNotRunSkip(project) {
|
|
13
|
+
return `reference not run: ${project} did not finish this case's spec file in this run`;
|
|
14
|
+
}
|
|
15
|
+
/** Matches {@link referenceNotRunSkip}'s reason; group 1 is the reference project. */
|
|
16
|
+
const REFERENCE_NOT_RUN_SKIP = /^reference not run: (.+) did not finish this case's spec file in this run$/s;
|
|
17
|
+
/**
|
|
18
|
+
* Why L10 skips the font audit outside Chromium (ADR-0066). The audit asks CDP which font drew
|
|
19
|
+
* each glyph; Firefox and WebKit have no such protocol, and `document.fonts` only says a font
|
|
20
|
+
* loaded, not that the text used it.
|
|
21
|
+
*/
|
|
22
|
+
const FONT_AUDIT_SKIP = "CDP reports the font each glyph used, and only Chromium has CDP";
|
|
23
|
+
//#endregion
|
|
24
|
+
export { FONT_AUDIT_SKIP, LIVE_REFERENCE_SKIP, REFERENCE_NOT_RUN_SKIP, referenceNotRunSkip };
|
package/package.json
CHANGED
|
@@ -1,6 +1,138 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unframework.dev/testing",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "The cross-target test API: describeTargets, it, mount, mountScenario, the View with its parity checks, and the axe and ARIA matchers. The harness's machinery, the mount adapters, the SSR renderers and normalisation are internal subpaths. Private until its first release.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"testing",
|
|
7
|
+
"unframework",
|
|
8
|
+
"vitest"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/uxfront-com/unframework/tree/main/packages/testing#readme",
|
|
11
|
+
"bugs": "https://github.com/uxfront-com/unframework/issues",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/uxfront-com/unframework.git",
|
|
16
|
+
"directory": "packages/testing"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./src/setup.ts",
|
|
24
|
+
"./src/targets/*.ts",
|
|
25
|
+
"./src/ssr/spec.ts",
|
|
26
|
+
"./dist/setup.js",
|
|
27
|
+
"./dist/targets/*.js",
|
|
28
|
+
"./dist/ssr/spec.js"
|
|
29
|
+
],
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./harness": {
|
|
36
|
+
"types": "./dist/internal.d.ts",
|
|
37
|
+
"default": "./dist/internal.js"
|
|
38
|
+
},
|
|
39
|
+
"./config": {
|
|
40
|
+
"types": "./dist/config/index.d.ts",
|
|
41
|
+
"default": "./dist/config/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./cli": {
|
|
44
|
+
"types": "./dist/cli.d.ts",
|
|
45
|
+
"default": "./dist/cli.js"
|
|
46
|
+
},
|
|
47
|
+
"./ssr": {
|
|
48
|
+
"types": "./dist/ssr/index.d.ts",
|
|
49
|
+
"default": "./dist/ssr/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./ssr/spec": {
|
|
52
|
+
"types": "./dist/ssr/spec.d.ts",
|
|
53
|
+
"default": "./dist/ssr/spec.js"
|
|
54
|
+
},
|
|
55
|
+
"./setup": {
|
|
56
|
+
"types": "./dist/setup.d.ts",
|
|
57
|
+
"default": "./dist/setup.js"
|
|
58
|
+
},
|
|
59
|
+
"./normalize": {
|
|
60
|
+
"types": "./dist/normalize/index.d.ts",
|
|
61
|
+
"default": "./dist/normalize/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./node": {
|
|
64
|
+
"types": "./dist/node/index.d.ts",
|
|
65
|
+
"default": "./dist/node/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./react": {
|
|
68
|
+
"types": "./dist/targets/react.d.ts",
|
|
69
|
+
"default": "./dist/targets/react.js"
|
|
70
|
+
},
|
|
71
|
+
"./vue": {
|
|
72
|
+
"types": "./dist/targets/vue.d.ts",
|
|
73
|
+
"default": "./dist/targets/vue.js"
|
|
74
|
+
},
|
|
75
|
+
"./svelte": {
|
|
76
|
+
"types": "./dist/targets/svelte.d.ts",
|
|
77
|
+
"default": "./dist/targets/svelte.js"
|
|
78
|
+
},
|
|
79
|
+
"./solid": {
|
|
80
|
+
"types": "./dist/targets/solid.d.ts",
|
|
81
|
+
"default": "./dist/targets/solid.js"
|
|
82
|
+
},
|
|
83
|
+
"./angular": {
|
|
84
|
+
"types": "./dist/targets/angular.d.ts",
|
|
85
|
+
"default": "./dist/targets/angular.js"
|
|
86
|
+
},
|
|
87
|
+
"./qwik": {
|
|
88
|
+
"types": "./dist/targets/qwik.d.ts",
|
|
89
|
+
"default": "./dist/targets/qwik.js"
|
|
90
|
+
},
|
|
91
|
+
"./astro": {
|
|
92
|
+
"types": "./dist/targets/astro.d.ts",
|
|
93
|
+
"default": "./dist/targets/astro.js"
|
|
94
|
+
},
|
|
95
|
+
"./package.json": "./package.json"
|
|
96
|
+
},
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public"
|
|
99
|
+
},
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"@fontsource/inter": "^5.3.0",
|
|
102
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
103
|
+
"@unframework.dev/codegen": "0.0.0",
|
|
104
|
+
"@unframework.dev/compiler": "0.0.0",
|
|
105
|
+
"@unframework.dev/ir": "0.0.0",
|
|
106
|
+
"@unframework.dev/target-angular": "0.0.0",
|
|
107
|
+
"@unframework.dev/target-astro": "0.0.0",
|
|
108
|
+
"@unframework.dev/target-qwik": "0.0.0",
|
|
109
|
+
"@unframework.dev/target-react": "0.0.0",
|
|
110
|
+
"@unframework.dev/target-solid": "0.0.0",
|
|
111
|
+
"@unframework.dev/target-svelte": "0.0.0",
|
|
112
|
+
"@unframework.dev/target-vue": "0.0.0",
|
|
113
|
+
"@unframework.dev/unplugin": "0.0.0",
|
|
114
|
+
"axe-core": "4.13.0",
|
|
115
|
+
"parse5": "^8.0.1",
|
|
116
|
+
"pixelmatch": "^7.2.0",
|
|
117
|
+
"pngjs": "^7.0.0"
|
|
118
|
+
},
|
|
119
|
+
"devDependencies": {
|
|
120
|
+
"@types/node": "^24.19.0",
|
|
121
|
+
"@types/pngjs": "^6.0.5",
|
|
122
|
+
"@uxfront/typescript-config": "^0.1.0",
|
|
123
|
+
"@vitest/browser-playwright": "5.0.3",
|
|
124
|
+
"playwright": "1.63.0",
|
|
125
|
+
"tsdown": "^0.23.0",
|
|
126
|
+
"vite": "8.3.1",
|
|
127
|
+
"vitest": "5.0.3"
|
|
128
|
+
},
|
|
129
|
+
"peerDependencies": {
|
|
130
|
+
"@vitest/browser-playwright": "5.0.3",
|
|
131
|
+
"vitest": "5.0.3"
|
|
132
|
+
},
|
|
133
|
+
"scripts": {
|
|
134
|
+
"build": "tsdown",
|
|
135
|
+
"check-types": "tsc --noEmit",
|
|
136
|
+
"test": "vitest run && vitest run --config test/parity/vitest.config.ts"
|
|
137
|
+
}
|
|
6
138
|
}
|