Skip to content

fix(scaffold): ship web projects test-ready (bun test + @types/bun)#12

Merged
agjs merged 2 commits into
mainfrom
fix/scaffold-test-setup
Jun 18, 2026
Merged

fix(scaffold): ship web projects test-ready (bun test + @types/bun)#12
agjs merged 2 commits into
mainfrom
fix/scaffold-test-setup

Conversation

@agjs

@agjs agjs commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Problem

Generated web apps shipped with no test runner and no bun:test types. So when TDD enforcement (default-on since 0.14.0) required a test for .ts logic, the model had to:

  • hand-roll a ~50-line src/bun-test.d.ts to get bun:test to type-check (TS2664/TS2307 under moduleResolution: bundler), and
  • improvise a test runner.

This wasted real turns on a freshly generated project — exactly the headline use case.

Fix

packages/core/src/web-templates.ts:

  • Both package.json templates (react + vanilla) now ship "test": "bun test" and @types/bun in devDependencies. installWebDeps runs bun install, so they're present at scaffold time. @types/bun is auto-included from node_modules/@types (no types array needed), so import { test, expect } from "bun:test" resolves with zero hand-rolled .d.ts.
  • Reconciled the build guidance, which previously told the model not to write tests (contradicting TDD-by-default). It now says the runner is already wired (don't set one up) and that .ts logic needs a co-located bun:test *.test.ts, while presentational .tsx components stay test-free.

discoverTestCommand already prefers a real test script, so the gate also recognizes/runs these tests. buildWebGate does not run bun test, so a freshly scaffolded app (test script present, no test files yet) won't fail the gate on zero tests — enforcement stays with the test-sibling-required meta-rule.

Verification

  • In a fresh dir with the scaffold's exact tsconfig (moduleResolution: bundler, no types array) and only @types/bun added — no hand-rolled .d.tstsc --noEmit is green (bun:test resolves) and bun test passes (1 pass).
  • detect-gate.test.ts (scaffold tests): 18 pass, 0 fail.
  • typecheck + lint + format: green.

Generated web apps shipped with no test runner and no bun:test types, so when TDD enforcement required a test the model wasted turns hand-rolling a bun-test.d.ts and wiring a runner (seen in a real generated project).

Both package.json templates (react + vanilla) now ship a "test": "bun test" script and @types/bun in devDependencies; installWebDeps installs them at scaffold time. The build guidance, which previously told the model not to write tests, now states the runner is already wired and that .ts logic needs a co-located bun:test *.test.ts while .tsx components stay test-free.

Verified: tsc resolves bun:test with @types/bun and no hand-rolled .d.ts; detect-gate scaffold tests 18 pass.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a test script and Bun types to the React and Vanilla web templates, while updating the developer guidance to emphasize logic-based TDD using bun:test. However, the package @types/bun does not exist on npm and will cause installation failures. The feedback recommends replacing it with the official bun-types package, updating the TypeScript configurations accordingly, and adjusting the guidance text to avoid split import statements.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/core/src/web-templates.ts
Comment thread packages/core/src/web-templates.ts
Comment thread packages/core/src/web-templates.ts Outdated
Comment thread packages/core/src/web-templates.ts Outdated
Addresses PR #12 review: the example import was split across a newline in the guidance string; the model could copy the break. Kept @types/bun (it exists on npm and is correct for auto-inclusion; bun-types is not auto-included under @types).
@agjs agjs merged commit 098d163 into main Jun 18, 2026
8 checks passed
@agjs agjs deleted the fix/scaffold-test-setup branch June 18, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant