The root .gitignore's bare `dist` pattern matches at any depth, which was also silently excluding sdk/js/test/dist/ -- a real, hand-written test suite (cjs.dist.ts/esm.dist.ts/types.dist-d.ts/helpers.ts) that verifies the published package's actual compiled exports, not build output. `git log --all` shows zero commits ever touched this path: it has been untracked since the repo's initial commit, so a fresh clone (CI, another machine, a contributor) silently never had these tests. Un-ignore sdk/js/test/dist/ explicitly while leaving the real build output (sdk/js/dist/) ignored. Also fixed the EXPECTED_VALUE_EXPORTS list in helpers.ts, which had drifted from src/index.ts's deprecated OpenTypeSafeClient/OpenTypeSafeError aliases and was failing both dist tests the moment they actually ran. This also resolves the "biome: command not found" report from the 2026-11-09 npm publish --dry-run attempt: @biomejs/biome was already a correct devDependency, the real missing step was `npm install` (never run that session). Verified live: fresh npm install + npm run check (lint/typecheck/test:coverage/build/test:dist/check:package) + npm publish --dry-run all pass clean end to end now. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { createRequire } from "node:module";
|
|
import { describe, expect, it } from "vitest";
|
|
import type * as Esm from "../../dist/index.mjs";
|
|
import { BASE_URL, cannedFetch, EXPECTED_VALUE_EXPORTS, pkg, SYSTEM_ONE_BODY } from "./helpers";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
// The CJS build exposes the same API as the ESM build; borrow its types.
|
|
const sdk = require("../../dist/index.cjs") as typeof Esm;
|
|
|
|
describe("dist/index.cjs (CommonJS build)", () => {
|
|
it("exposes exactly the documented value exports", () => {
|
|
expect(Object.keys(sdk).sort()).toEqual(EXPECTED_VALUE_EXPORTS);
|
|
});
|
|
|
|
it("reports the package.json version", () => {
|
|
expect(sdk.VERSION).toBe(pkg.version);
|
|
});
|
|
|
|
it("makes a round trip through the bundle", async () => {
|
|
const { fetch } = cannedFetch(SYSTEM_ONE_BODY);
|
|
const client = new sdk.TypeSafeClient({
|
|
apiKey: "k",
|
|
baseURL: BASE_URL,
|
|
fetch,
|
|
retry: { maxRetries: 0 },
|
|
});
|
|
const result = await client.systemOne({
|
|
state: "hi",
|
|
questions: { ok: sdk.noul("ok?"), tone: sdk.choice("tone?", { warm: null, cold: null }) },
|
|
});
|
|
expect(result.answers.tone.probabilities.warm).toBe(0.8);
|
|
});
|
|
|
|
it("resolves through the package.json exports map", () => {
|
|
const exportsMap = pkg.exports["."] as { require: { default: string; types: string } };
|
|
expect(exportsMap.require.default).toBe("./dist/index.cjs");
|
|
expect(exportsMap.require.types).toBe("./dist/index.d.cts");
|
|
expect(require.resolve("../../dist/index.cjs")).toMatch(/dist\/index\.cjs$/);
|
|
});
|
|
});
|