Lines 1-29javascript
2import { spawnSync } from "node:child_process";
3import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
4import { tmpdir } from "node:os";
5import { dirname, join, resolve } from "node:path";
6import { fileURLToPath, pathToFileURL } from "node:url";
8const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
9const cli = join(root, "bin", "screenshotter.mjs");
10const api = await import(pathToFileURL(join(root, "index.mjs")).href);
11const workDir = mkdtempSync(join(tmpdir(), "screenshotter-smoke-"));
MediumDynamic Require
Package source references dynamic require/import behavior.
scripts/smoke-test.mjsView on unpkg · L9 12const dataDir = join(workDir, "store");
13const imagePath = join(workDir, "input.png");
16 writeFileSync(imagePath, Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgwJ/lmV5xwAAAABJRU5ErkJggg==", "base64"));
18 const doctor = run(["doctor", "--data-dir", dataDir, "--json"]);
19 assert(doctor.ok === true, "doctor should pass required checks");
20 assert(doctor.defaultProfile?.profile === "readability", "doctor should report readability as the default profile");
21 assert(doctor.autoWatch?.clipboard === true, "watch should copy optimized screenshots to clipboard by default");
23 const originalProcessList = process.env.SCREENSHOTTER_PROCESS_LIST;
24 process.env.SCREENSHOTTER_PROCESS_LIST = "100 /Applications/Codex.app/Contents/Resources/codex /Applications/Codex.app/Contents/Resources/codex app-server --listen stdio://";
25 const codexDoctor = run(["doctor", "--data-dir", dataDir, "--json"]);
26 assert(codexDoctor.autoWatch?.target === "codex-app", "doctor should auto-detect Codex app for watch");
27 assert(codexDoctor.autoWatch?.clipboard === true, "Codex app auto-detect should enable clipboard handoff");
28 process.env.SCREENSHOTTER_PROCESS_LIST = "101 /usr/local/bin/codex codex exec review";
29 const codexCliDoctor = run(["doctor", "--data-dir", dataDir, "--json"]);