@design-embed/target-react 0.1.0 → 1.0.1
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 +1 -1
- package/README.md +66 -1
- package/dist/design-embed/src/core/diagnostics/diagnostic.d.mts +16 -0
- package/dist/design-embed/src/core/nodes.d.mts +63 -0
- package/dist/design-embed/src/core/plugins/pluginApi.d.mts +41 -0
- package/dist/design-embed/src/core/types.d.mts +98 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.mjs +964 -0
- package/dist/index.test.d.mts +1 -0
- package/dist/index.test.mjs +75 -0
- package/package.json +12 -10
- package/src/index.ts +699 -64
- package/dist/index.js +0 -744
- package/node_modules/@design-embed/config/README.md +0 -5
- package/node_modules/@design-embed/config/dist/index.js +0 -283
- package/node_modules/@design-embed/config/package.json +0 -19
- package/node_modules/@design-embed/config/src/index.ts +0 -518
- package/node_modules/@design-embed/core/README.md +0 -5
- package/node_modules/@design-embed/core/dist/diagnostics/diagnostic.js +0 -3
- package/node_modules/@design-embed/core/dist/diagnostics/jsonDiagnostic.js +0 -35
- package/node_modules/@design-embed/core/dist/index.js +0 -351
- package/node_modules/@design-embed/core/dist/pipeline/checkMode.js +0 -29
- package/node_modules/@design-embed/core/dist/plugins/pluginApi.js +0 -1
- package/node_modules/@design-embed/core/dist/plugins/pluginRegistry.js +0 -25
- package/node_modules/@design-embed/core/package.json +0 -19
- package/node_modules/@design-embed/core/src/diagnostics/diagnostic.ts +0 -18
- package/node_modules/@design-embed/core/src/diagnostics/jsonDiagnostic.ts +0 -51
- package/node_modules/@design-embed/core/src/index.ts +0 -591
- package/node_modules/@design-embed/core/src/pipeline/checkMode.ts +0 -46
- package/node_modules/@design-embed/core/src/plugins/pluginApi.ts +0 -78
- package/node_modules/@design-embed/core/src/plugins/pluginRegistry.ts +0 -37
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ReactTarget, emitReactView, reactTestGenerator } from "./index.mjs";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { describe, test } from "node:test";
|
|
4
|
+
//#region packages/target-react/src/index.test.ts
|
|
5
|
+
describe("React target", () => {
|
|
6
|
+
test("emits a React view from design nodes", () => {
|
|
7
|
+
assert.equal(emitReactView([{
|
|
8
|
+
kind: "element",
|
|
9
|
+
tagName: "section",
|
|
10
|
+
attributes: { "data-testid": "hero" },
|
|
11
|
+
styles: { width: "120px" },
|
|
12
|
+
children: [{
|
|
13
|
+
kind: "text",
|
|
14
|
+
text: "Hello"
|
|
15
|
+
}]
|
|
16
|
+
}], "HeroView"), `export function HeroView() {
|
|
17
|
+
\treturn (
|
|
18
|
+
\t\t<section data-testid="hero" style={{ width: "120px" }}>
|
|
19
|
+
\t\t\tHello
|
|
20
|
+
\t\t</section>
|
|
21
|
+
\t);
|
|
22
|
+
}
|
|
23
|
+
`);
|
|
24
|
+
});
|
|
25
|
+
test("emits deterministic React visual regression tests", () => {
|
|
26
|
+
const result = reactTestGenerator.generateTests({
|
|
27
|
+
html: "<section style=\"width: 120px\">Hello</section>",
|
|
28
|
+
config: {
|
|
29
|
+
output: {
|
|
30
|
+
target: new ReactTarget(),
|
|
31
|
+
viewName: "GeneratedCard",
|
|
32
|
+
viewsDir: "src/generated/views"
|
|
33
|
+
},
|
|
34
|
+
tests: {
|
|
35
|
+
outputDir: "tests/generated",
|
|
36
|
+
viewports: [{
|
|
37
|
+
name: "mobile",
|
|
38
|
+
width: 390,
|
|
39
|
+
height: 844
|
|
40
|
+
}],
|
|
41
|
+
states: [{
|
|
42
|
+
name: "hovered",
|
|
43
|
+
hover: "section"
|
|
44
|
+
}],
|
|
45
|
+
assertions: {
|
|
46
|
+
screenshot: true,
|
|
47
|
+
layout: true,
|
|
48
|
+
layoutTolerance: 1,
|
|
49
|
+
selectors: ["section"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
assert.deepEqual(result.diagnostics, []);
|
|
55
|
+
assert.deepEqual(result.files.map((file) => file.path), ["tests/generated/GeneratedCard.reference.html", "tests/generated/GeneratedCard.visual.spec.tsx"]);
|
|
56
|
+
assert.equal(result.files[0]?.contents, "<section style=\"width: 120px\">Hello</section>\n");
|
|
57
|
+
assert.match(result.files[1]?.contents ?? "", /import { GeneratedCard } from "..\/..\/src\/generated\/views\/GeneratedCard.view";/);
|
|
58
|
+
assert.match(result.files[1]?.contents ?? "", /const layoutTolerance = 1;/);
|
|
59
|
+
assert.match(result.files[1]?.contents ?? "", /await page.hover\(state.hover\);/);
|
|
60
|
+
});
|
|
61
|
+
test("reports unsupported React test runners", () => {
|
|
62
|
+
const result = reactTestGenerator.generateTests({
|
|
63
|
+
html: "<main></main>",
|
|
64
|
+
config: { tests: { runner: "vitest" } }
|
|
65
|
+
});
|
|
66
|
+
assert.deepEqual(result.files, []);
|
|
67
|
+
assert.deepEqual(result.diagnostics, [{
|
|
68
|
+
code: "TEST_RUNNER_UNSUPPORTED",
|
|
69
|
+
message: "Unsupported test runner: vitest",
|
|
70
|
+
severity: "error"
|
|
71
|
+
}]);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
75
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design-embed/target-react",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
8
9
|
},
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./src/index.ts",
|
|
12
13
|
"development": "./src/index.ts",
|
|
13
|
-
"default": "./dist/index.
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
@@ -19,12 +20,13 @@
|
|
|
19
20
|
"!src/**/*.test.ts",
|
|
20
21
|
"README.md"
|
|
21
22
|
],
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"@design-embed/core": "0.1.0"
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"design-embed": "*"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"design-embed": "0.2.1"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node --conditions=development --test src/**/*.test.ts"
|
|
31
|
+
}
|
|
30
32
|
}
|