@joiner-platform/cli 0.1.17 → 0.1.19

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 (38) hide show
  1. package/package.json +2 -2
  2. package/skills/tile-creator/references/cli.md +1 -1
  3. package/skills/tile-creator/references/client-api.md +16 -6
  4. package/src/commands/init/scaffold.ts +2 -9
  5. package/src/commands/init/sdk-tarball-url.generated.ts +2 -2
  6. package/src/commands/init/template-names.ts +18 -0
  7. package/bundled-resources/poe-tile-templates/coverage.config.json +0 -6
  8. package/bundled-resources/poe-tile-templates/index.ts +0 -27
  9. package/bundled-resources/poe-tile-templates/package.json +0 -31
  10. package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +0 -10
  11. package/bundled-resources/poe-tile-templates/scripts/generate.ts +0 -57
  12. package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +0 -52
  13. package/bundled-resources/poe-tile-templates/scripts/paths.ts +0 -7
  14. package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +0 -288
  15. package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +0 -132
  16. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +0 -30
  17. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +0 -397
  18. package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +0 -131
  19. package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +0 -166
  20. package/bundled-resources/poe-tile-templates/tests/doctor-launcher.test.ts +0 -48
  21. package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +0 -67
  22. package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +0 -106
  23. package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +0 -103
  24. package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +0 -67
  25. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +0 -85
  26. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +0 -69
  27. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +0 -73
  28. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +0 -54
  29. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +0 -70
  30. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +0 -85
  31. package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +0 -278
  32. package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +0 -27
  33. package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +0 -99
  34. package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +0 -23
  35. package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +0 -84
  36. package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +0 -56
  37. package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +0 -129
  38. package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +0 -90
@@ -1,99 +0,0 @@
1
- import { afterEach, expect, test } from "bun:test";
2
- import {
3
- existsSync,
4
- mkdirSync,
5
- mkdtempSync,
6
- readFileSync,
7
- realpathSync,
8
- rmSync,
9
- writeFileSync,
10
- } from "node:fs";
11
- import { createRequire } from "node:module";
12
- import { tmpdir } from "node:os";
13
- import { join } from "node:path";
14
- import { saveInstallDiagnostics } from "../scripts/install-diagnostics";
15
-
16
- const roots: string[] = [];
17
- afterEach(() => {
18
- for (const root of roots.splice(0))
19
- rmSync(root, { recursive: true, force: true });
20
- });
21
-
22
- function fixture() {
23
- const root = realpathSync(
24
- mkdtempSync(join(tmpdir(), "install-diagnostics-")),
25
- );
26
- roots.push(root);
27
- const app = join(root, "app");
28
- const output = join(root, "evidence");
29
- mkdirSync(app);
30
- writeFileSync(join(app, "package.json"), '{"name":"test-app"}');
31
- return { app, output };
32
- }
33
-
34
- test("missing native dependency evidence survives scaffold cleanup", () => {
35
- const { app, output } = fixture();
36
- writeFileSync(join(app, "bun.lock"), '{"lockfileVersion":1}');
37
- writeFileSync(join(app, ".env"), "PRIVATE_TEST_VALUE=do-not-copy");
38
- writeFileSync(join(app, ".npmrc"), "//example.test/:_authToken=do-not-copy");
39
- const vite = join(app, "node_modules/vite");
40
- const rollup = join(vite, "node_modules/rollup");
41
- mkdirSync(rollup, { recursive: true });
42
- writeFileSync(
43
- join(vite, "package.json"),
44
- '{"name":"vite","version":"6.0.0"}',
45
- );
46
- const native = "@rollup/rollup-linux-x64-gnu";
47
- const rollupPackage = JSON.stringify({
48
- name: "rollup",
49
- version: "4.0.0",
50
- main: "index.cjs",
51
- optionalDependencies: { [native]: "4.0.0", "installed-native": "1.0.0" },
52
- });
53
- writeFileSync(join(rollup, "package.json"), rollupPackage);
54
- writeFileSync(
55
- join(rollup, "index.cjs"),
56
- `module.exports = require(${JSON.stringify(native)});`,
57
- );
58
- const installed = join(rollup, "node_modules/installed-native");
59
- mkdirSync(installed, { recursive: true });
60
- writeFileSync(join(installed, "index.js"), "module.exports = {};");
61
-
62
- // Node really fails to load the optional native dependency, as Vite did in CI.
63
- expect(() => createRequire(join(vite, "package.json"))("rollup")).toThrow(
64
- native,
65
- );
66
- saveInstallDiagnostics(app, output);
67
- rmSync(app, { recursive: true });
68
-
69
- expect(readFileSync(join(output, "bun.lock"), "utf8")).toBe(
70
- '{"lockfileVersion":1}',
71
- );
72
- expect(readFileSync(join(output, "rollup-package.json"), "utf8")).toBe(
73
- rollupPackage,
74
- );
75
- const report = JSON.parse(
76
- readFileSync(join(output, "resolution.json"), "utf8"),
77
- );
78
- expect(report.resolutions.rollup).toBe(join(rollup, "package.json"));
79
- expect(report.resolutions[native]).toContain("Cannot find module");
80
- expect(report.resolutions["installed-native"]).toBe(
81
- join(installed, "index.js"),
82
- );
83
- expect(existsSync(join(output, ".env"))).toBe(false);
84
- expect(existsSync(join(output, ".npmrc"))).toBe(false);
85
- expect(existsSync(join(output, "node_modules"))).toBe(false);
86
- });
87
-
88
- test("an incomplete install still saves the manifest and resolution error", () => {
89
- const { app, output } = fixture();
90
- saveInstallDiagnostics(app, output);
91
- expect(readFileSync(join(output, "package.json"), "utf8")).toBe(
92
- '{"name":"test-app"}',
93
- );
94
- expect(existsSync(join(output, "bun.lock"))).toBe(false);
95
- const report = JSON.parse(
96
- readFileSync(join(output, "resolution.json"), "utf8"),
97
- );
98
- expect(report.resolutions.error).toContain("vite/package.json");
99
- });
@@ -1,23 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { readFileSync } from "node:fs";
3
- import { join } from "node:path";
4
-
5
- const templatesPackageDir = join(import.meta.dir, "..");
6
- const entryFiles = [
7
- "react/tile/src/entry.tsx",
8
- "preact/tile/src/entry.tsx",
9
- "solidjs/tile/src/entry.tsx",
10
- "vanilla-js/tile/src/entry.ts",
11
- "phaserjs/tile/src/entry.ts",
12
- ];
13
-
14
- test("player-facing scaffold entries enable native gesture overrides", () => {
15
- for (const entryFile of entryFiles) {
16
- const source = readFileSync(join(templatesPackageDir, entryFile), "utf8");
17
- expect(source).toContain("applyNativeAppGestureOverrides,");
18
- expect(source).toContain("applyNativeAppGestureOverrides();");
19
- expect(source).not.toContain(
20
- "// import { applyNativeAppGestureOverrides }",
21
- );
22
- }
23
- });
@@ -1,84 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { readFileSync } from "node:fs";
3
- import { join } from "node:path";
4
-
5
- const templatesPackageDir = join(import.meta.dir, "..");
6
-
7
- function documentedPlaywrightVersion(doc: string): string | undefined {
8
- const section = doc
9
- .split(/^### .*`generated-apps`.*$/m)[1]
10
- ?.split(/^#{1,3} /m)[0];
11
- return section?.match(
12
- /`npx --yes --package=playwright@(\S+) playwright\s+install\s+chromium(?:\s|$)/,
13
- )?.[1];
14
- }
15
-
16
- test("creator sandbox, CI, and docs use the Playwright browser required by generated apps", () => {
17
- const templatePackage = JSON.parse(
18
- readFileSync(join(templatesPackageDir, "base/package.json"), "utf8"),
19
- ) as { devDependencies: { "@playwright/test": string } };
20
- const dockerfile = readFileSync(
21
- join(
22
- templatesPackageDir,
23
- "../../projects/creator-v2-sandbox/container/Dockerfile",
24
- ),
25
- "utf8",
26
- );
27
- const prCheckWorkflow = readFileSync(
28
- join(templatesPackageDir, "../../.github/workflows/pr-check.yml"),
29
- "utf8",
30
- );
31
- const blockingChecksDoc = readFileSync(
32
- join(templatesPackageDir, "../../docs/blocking-pr-checks.md"),
33
- "utf8",
34
- );
35
- const requiredPlaywrightVersion =
36
- templatePackage.devDependencies["@playwright/test"];
37
- const bakedVersion = dockerfile.match(/^ARG PLAYWRIGHT_VERSION=(\S+)$/m)?.[1];
38
- const ciInstalls = [
39
- ...prCheckWorkflow.matchAll(
40
- /^\s*npx --yes --package=playwright@(\S+) playwright install (chromium(?:-headless-shell)?)$/gm,
41
- ),
42
- ].map((match) => ({ version: match[1], browser: match[2] }));
43
- const documentedVersion = documentedPlaywrightVersion(blockingChecksDoc);
44
-
45
- expect(bakedVersion).toBe(requiredPlaywrightVersion);
46
- expect(ciInstalls).toEqual([
47
- { version: requiredPlaywrightVersion, browser: "chromium" },
48
- { version: requiredPlaywrightVersion, browser: "chromium-headless-shell" },
49
- ]);
50
- expect(documentedVersion).toBe(requiredPlaywrightVersion);
51
- });
52
-
53
- test("documented Playwright version rejects a headless-shell-only install", () => {
54
- const headlessOnlyCommand = `### \`Generated app tests\` (\`generated-apps\` job ID)
55
-
56
- **Reproduce:** \`npx --yes --package=playwright@1.61.1 playwright install chromium-headless-shell\`.
57
- `;
58
-
59
- expect(documentedPlaywrightVersion(headlessOnlyCommand)).toBeUndefined();
60
- });
61
-
62
- test("documented Playwright version ignores installs in the next check", () => {
63
- const otherCheckCommand = `### \`Generated app tests\` (\`generated-apps\` job ID)
64
-
65
- **Reproduce:** See CI.
66
-
67
- ### Another check
68
-
69
- **Reproduce:** \`npx --yes --package=playwright@1.61.1 playwright install chromium\`.
70
- `;
71
-
72
- expect(documentedPlaywrightVersion(otherCheckCommand)).toBeUndefined();
73
- });
74
-
75
- test("generated-app tests repair the scaffold's pinned browser cache", () => {
76
- const generatedTemplatesTest = readFileSync(
77
- join(templatesPackageDir, "tests/generated-templates.test.ts"),
78
- "utf8",
79
- );
80
-
81
- expect(generatedTemplatesTest).toMatch(
82
- /\[\s*"bunx",\s*"playwright",\s*"install",\s*"--force",\s*"chromium-headless-shell",?\s*\]/,
83
- );
84
- });
@@ -1,56 +0,0 @@
1
- // The scaffold's render check is three pieces that must agree: the gated test
2
- // file, its entry in the `mobile-viewport` Playwright project, and the
3
- // `render-check` package script that runs it. A scaffold missing any one of
4
- // them hands the Creator agent a command that does nothing.
5
- import { expect, test } from "bun:test";
6
- import { readFileSync } from "node:fs";
7
- import { join } from "node:path";
8
-
9
- const base = join(import.meta.dir, "../base");
10
-
11
- test("the render-check test file is gated on RENDER_CHECK and imports the SDK's render-check entry", () => {
12
- const source = readFileSync(
13
- join(base, "tests/render-check.test.playwright.ts"),
14
- "utf8",
15
- );
16
- expect(source).toContain('from "joiner-sdk/v1/test-utils/render-check.js"');
17
- expect(source).toContain(
18
- "const { RENDER_CHECK, RENDER_CHECK_REPORT_ONLY } = process.env;",
19
- );
20
- expect(source).toContain("test.skip(\n\t!RENDER_CHECK,");
21
- expect(source).toContain("renderCheckTimeoutMs(screens.length)");
22
- expect(source).toContain("renderCheckDeadlineMs(screens.length)");
23
- expect(source).toContain('visualCheckPath("render-check.json", TILE_DIR)');
24
- expect(source).toContain("test.afterEach(");
25
- expect(source).toContain('kind: "unknown"');
26
- });
27
-
28
- test("the render-check test runs in the mobile-viewport project and nowhere else", () => {
29
- const config = readFileSync(join(base, "playwright.config.ts"), "utf8");
30
- const desktop = config.slice(
31
- config.indexOf('name: "desktop"'),
32
- config.indexOf('name: "mobile-viewport"'),
33
- );
34
- const mobile = config.slice(config.indexOf('name: "mobile-viewport"'));
35
- expect(desktop).toContain('"**/render-check.test.playwright.ts"');
36
- expect(desktop).toContain("testIgnore");
37
- expect(mobile).toContain('"**/render-check.test.playwright.ts"');
38
- expect(mobile).toContain("testMatch");
39
- });
40
-
41
- test("the render-check script mirrors regenerate-screenshot and verify is untouched by it", () => {
42
- const pkg = JSON.parse(readFileSync(join(base, "package.json"), "utf8")) as {
43
- scripts: {
44
- verify: string;
45
- "render-check": string;
46
- "regenerate-screenshot": string;
47
- };
48
- };
49
- expect(pkg.scripts["render-check"]).toBe(
50
- "bun run build && bunx playwright install chromium && RENDER_CHECK=1 bunx playwright test tests/render-check.test.playwright.ts",
51
- );
52
- expect(pkg.scripts["regenerate-screenshot"]).toBe(
53
- "bun run build && bunx playwright install chromium && REGEN_SCREENSHOTS=1 bunx playwright test tests/screenshot.test.playwright.ts",
54
- );
55
- expect(pkg.scripts.verify).not.toContain("render-check");
56
- });
@@ -1,129 +0,0 @@
1
- // owner: jyoung-q
2
- import { afterEach, describe, expect, test } from "bun:test";
3
- import {
4
- mkdirSync,
5
- mkdtempSync,
6
- readFileSync,
7
- rmSync,
8
- writeFileSync,
9
- } from "node:fs";
10
- import { tmpdir } from "node:os";
11
- import { join } from "node:path";
12
- import {
13
- parseVerifyOptions,
14
- renameSdkSelfImports,
15
- rewriteSdkSpecifiers,
16
- useSdkDependencyKey,
17
- } from "../scripts/sdk-dependency-key";
18
-
19
- const dirs: string[] = [];
20
- afterEach(() => {
21
- for (const dir of dirs.splice(0))
22
- rmSync(dir, { recursive: true, force: true });
23
- });
24
-
25
- describe("parseVerifyOptions", () => {
26
- test("defaults to the scaffold key and the packed name", () => {
27
- expect(parseVerifyOptions([])).toEqual({
28
- dependencyKey: "joiner-sdk",
29
- tarballName: undefined,
30
- });
31
- });
32
-
33
- test("reads both options", () => {
34
- expect(
35
- parseVerifyOptions([
36
- "--dependency-key",
37
- "poe-tiles-sdk",
38
- "--tarball-name",
39
- "poe-tiles-sdk",
40
- ]),
41
- ).toEqual({ dependencyKey: "poe-tiles-sdk", tarballName: "poe-tiles-sdk" });
42
- });
43
-
44
- test("rejects an unknown key or option", () => {
45
- expect(() => parseVerifyOptions(["--dependency-key", "x-sdk"])).toThrow(
46
- /--dependency-key must be one of/,
47
- );
48
- expect(() => parseVerifyOptions(["--key", "joiner-sdk"])).toThrow(
49
- /Unknown option/,
50
- );
51
- });
52
- });
53
-
54
- test("rewriteSdkSpecifiers moves imports and installed paths, nothing else", () => {
55
- const source = [
56
- 'import { a } from "joiner-sdk/v1/client.js";',
57
- "import b from 'joiner-sdk/vite';",
58
- "const c = await import(`joiner-sdk/v1/backend.js`);",
59
- '/// <reference types="joiner-sdk/vite-client" />',
60
- '"render-check": "bun node_modules/joiner-sdk/bin/x.js"',
61
- "// The joiner-sdk docs stay as they are.",
62
- '"@scope/joiner-sdk-extra"',
63
- ].join("\n");
64
- expect(rewriteSdkSpecifiers(source, "poe-tiles-sdk")).toBe(
65
- [
66
- 'import { a } from "poe-tiles-sdk/v1/client.js";',
67
- "import b from 'poe-tiles-sdk/vite';",
68
- "const c = await import(`poe-tiles-sdk/v1/backend.js`);",
69
- '/// <reference types="poe-tiles-sdk/vite-client" />',
70
- '"render-check": "bun node_modules/poe-tiles-sdk/bin/x.js"',
71
- "// The joiner-sdk docs stay as they are.",
72
- '"@scope/joiner-sdk-extra"',
73
- ].join("\n"),
74
- );
75
- expect(rewriteSdkSpecifiers(source, "joiner-sdk")).toBe(source);
76
- });
77
-
78
- test("useSdkDependencyKey renames the dependency in place and rewrites source", () => {
79
- const dir = mkdtempSync(join(tmpdir(), "sdk-key-"));
80
- dirs.push(dir);
81
- mkdirSync(join(dir, "src"));
82
- mkdirSync(join(dir, "node_modules/x"), { recursive: true });
83
- writeFileSync(
84
- join(dir, "package.json"),
85
- JSON.stringify({
86
- dependencies: { a: "1", "joiner-sdk": "file:///sdk.tgz", z: "2" },
87
- }),
88
- );
89
- writeFileSync(
90
- join(dir, "src/entry.ts"),
91
- 'import { createPoe } from "joiner-sdk/v1/client.js";\n',
92
- );
93
- const vendored = 'import "joiner-sdk/v1/client.js";\n';
94
- writeFileSync(join(dir, "node_modules/x/index.js"), vendored);
95
- writeFileSync(join(dir, "README.md"), 'Run "joiner-sdk/vite".\n');
96
-
97
- useSdkDependencyKey(dir, "poe-tiles-sdk");
98
-
99
- const manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
100
- expect(Object.entries(manifest.dependencies)).toEqual([
101
- ["a", "1"],
102
- ["poe-tiles-sdk", "file:///sdk.tgz"],
103
- ["z", "2"],
104
- ]);
105
- expect(readFileSync(join(dir, "src/entry.ts"), "utf8")).toBe(
106
- 'import { createPoe } from "poe-tiles-sdk/v1/client.js";\n',
107
- );
108
- expect(readFileSync(join(dir, "node_modules/x/index.js"), "utf8")).toBe(
109
- vendored,
110
- );
111
- expect(readFileSync(join(dir, "README.md"), "utf8")).toBe(
112
- 'Run "joiner-sdk/vite".\n',
113
- );
114
- });
115
-
116
- test("renameSdkSelfImports renames self-imports and keeps the wire specifier", () => {
117
- const packed = [
118
- 'import { h } from "joiner-sdk/v1/test-utils/harness.js";',
119
- "export * from 'joiner-sdk/v1/test-utils.js';",
120
- 'const sdk = await import("poe-tiles-sdk/v1/client.js");',
121
- ].join("\n");
122
- expect(renameSdkSelfImports(packed, "poe-tiles-sdk")).toBe(
123
- [
124
- 'import { h } from "poe-tiles-sdk/v1/test-utils/harness.js";',
125
- "export * from 'poe-tiles-sdk/v1/test-utils.js';",
126
- 'const sdk = await import("poe-tiles-sdk/v1/client.js");',
127
- ].join("\n"),
128
- );
129
- });
@@ -1,90 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { existsSync, mkdtempSync, rmSync, statSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import {
6
- VISUAL_CHECKS_DIR,
7
- visualCheckPath,
8
- } from "../base/scripts/visual-check";
9
-
10
- /**
11
- * Runs `body` inside `runVisualCheck` in a child process. The trailing
12
- * "unreachable" line proves the wrapper ends the process: no case may print it.
13
- */
14
- function spawnCheck(body: string) {
15
- const wrapper = join(import.meta.dir, "../base/scripts/visual-check.ts");
16
- return Bun.spawnSync(
17
- [
18
- process.execPath,
19
- "--eval",
20
- `import { runVisualCheck } from ${JSON.stringify(wrapper)}; await runVisualCheck(async () => { ${body} }); console.log("unreachable");`,
21
- ],
22
- { stdout: "pipe", stderr: "pipe", timeout: 5_000 },
23
- );
24
- }
25
-
26
- test("a passing visual check exits 0 even when it leaves a server open", () => {
27
- // A check that never closes its TestServer (or calls its nonexistent
28
- // `stop`) kept the event loop alive after its last screenshot, so the
29
- // command ran until a timeout killed it. spawnCheck's 5 s timeout kills
30
- // such a child, which then has no exit code 0.
31
- const result = spawnCheck(
32
- 'Bun.serve({ port: 0, fetch: () => new Response("ok") }); setInterval(() => {}, 1_000); console.log("checked");',
33
- );
34
- expect(result.exitCode).toBe(0);
35
- expect(result.signalCode).toBeFalsy();
36
- expect(result.stdout.toString()).toBe("checked\n");
37
- expect(result.stderr.toString()).toBe("");
38
- });
39
-
40
- test("a passing visual check waits for its async work before exiting", () => {
41
- const result = spawnCheck(
42
- 'await new Promise((resolve) => setTimeout(resolve, 200)); console.log("after the wait");',
43
- );
44
- expect(result.exitCode).toBe(0);
45
- expect(result.stdout.toString()).toBe("after the wait\n");
46
- });
47
-
48
- test.each([
49
- {
50
- expression: 'new Error("Locator failed\\nCall log:\\nwaiting for button")',
51
- expected: "Locator failed\nCall log:\nwaiting for button\n",
52
- },
53
- {
54
- expression:
55
- 'Object.assign(new Error("Locator failed"), { callLog: ["Call log:", "waiting for button"] })',
56
- expected: "Locator failed\nCall log:\nwaiting for button\n",
57
- },
58
- {
59
- expression:
60
- 'Object.assign(new Error("Locator failed\\nwaiting for button"), { callLog: "waiting for button" })',
61
- expected: "Locator failed\nwaiting for button\n",
62
- },
63
- { expression: '"Visual check failed"', expected: "Visual check failed\n" },
64
- ])("visual-check failure exits 1 with only its message and call log: $expression", ({
65
- expression,
66
- expected,
67
- }) => {
68
- const result = spawnCheck(`throw ${expression};`);
69
- expect(result.exitCode).toBe(1);
70
- expect(result.stdout.toString()).toBe("");
71
- expect(result.stderr.toString()).toBe(expected);
72
- });
73
-
74
- test("visualCheckPath creates the ignored frames directory and names a file inside it", () => {
75
- // `.visual-checks/` is what the scaffold's .gitignore and the CLI's source
76
- // bundle both exclude, so frames written here never reach a publish.
77
- const root = mkdtempSync(join(tmpdir(), "visual-check-"));
78
- try {
79
- const path = visualCheckPath("phone-dark.png", root);
80
- expect(path).toBe(join(root, VISUAL_CHECKS_DIR, "phone-dark.png"));
81
- expect(statSync(join(root, VISUAL_CHECKS_DIR)).isDirectory()).toBe(true);
82
- expect(existsSync(path)).toBe(false);
83
- // Idempotent: a second frame does not trip over the existing directory.
84
- expect(visualCheckPath("phone-light.png", root)).toContain(
85
- VISUAL_CHECKS_DIR,
86
- );
87
- } finally {
88
- rmSync(root, { recursive: true, force: true });
89
- }
90
- });