Files
clean-architecture-frontend…/tests/unit/product-index-entrypoints.test.ts
T
DongHyeonkaandClaude Opus 5.5 f0d3953ef2 fix(build): render product index before entry points (R-0)
src/.generated is gitignored, but no entry point rendered it, so a fresh
checkout failed check:architecture, check:types:app/node/test, unit and
component tests, verify:documentation, dev and build.

- run-vitest renders the index before starting Vitest (all vitest suites)
- package scripts that load src (dev, build, storybook, architecture,
  app/node/test type checks, the five fixtures that reach the index,
  verify:documentation) render it first; CI runs these scripts by name
- tests/unit/product-index-entrypoints.test.ts guards the wiring

Verified from a fresh state (src/.generated removed before each gate):
architecture, types app/node/test, lint, unit 1781/1781, component 132/132,
verify:documentation, build, dev (HTTP 200), check:ci all pass;
fixture route-runtime still fails with its expected TS2740.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 11:52:34 +09:00

44 lines
1.5 KiB
TypeScript

import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
// src/.generated is gitignored (R-0): every entry point that loads the product
// index must render it first, or a fresh checkout cannot run the gates.
const GENERATE = "node scripts/generate-product-feature-index.ts && ";
const ENTRY_SCRIPTS = [
"dev",
"build",
"build:app-only",
"storybook",
"build:storybook",
"check:architecture",
"check:types:app",
"check:types:node",
"check:types:test",
"check:types:fixture:route-runtime",
"check:types:fixture:page-action",
"check:types:fixture:icon-button",
"check:types:fixture:i18n-key",
"check:types:fixture:i18n-params",
"verify:documentation",
] as const;
describe("product index entry points", () => {
it("renders the generated index before scripts that load src", async () => {
const { scripts } = JSON.parse(await readFile("package.json", "utf8")) as {
scripts: Record<string, string>;
};
for (const name of ENTRY_SCRIPTS) {
expect(scripts[name], name).toMatch(new RegExp(`^${GENERATE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`));
}
});
it("renders the generated index before every Vitest run", async () => {
const runner = await readFile("scripts/run-vitest.ts", "utf8");
expect(runner.indexOf("generate-product-feature-index.ts")).toBeGreaterThan(-1);
expect(runner.indexOf("generate-product-feature-index.ts")).toBeLessThan(
runner.indexOf("vitestEntry, ...process.argv"),
);
});
});