test: jsdom + Testing Library component smoke tests#7
Closed
abk1969 wants to merge 1 commit into
Closed
Conversation
…ests Closes the highest-impact gap from the TDD audit: 0 → 4 component-level tests that exercise the React tree and would have caught C2's roleNotes scope error (defined in App, consumed in Result — green unit tests + green build, but runtime ReferenceError at verdict screen). Infrastructure: - devDeps: @testing-library/react, @testing-library/jest-dom, @testing-library/user-event, jsdom - vitest.config.js: per-file environment via environmentMatchGlobs so only *.dom.test.jsx files spin up jsdom (keeps the existing 109 node-env tests fast). Adds @vitejs/plugin-react for JSX transform. - src/test-setup.js: jest-dom matchers + stub window.scrollTo (jsdom doesn't implement it; the App calls it on step change). Tests (src/app.dom.test.jsx): - App mounts welcome screen without throwing - Welcome → Step 1 navigation - Continue button enables after role selection - deployerKind sub-question conditional visibility (would catch the C2 bug class: if roleNotes/computeRoleNotes were broken, the dependent UI bits would fail to render here) Total: 113 tests pass (109 + 4), build green, ~5 s suite runtime. The deeper Result-screen walk-throughs are intentionally deferred to a future Playwright E2E pass — getting to step 7 in jsdom with the current UI requires more selector engineering than the safety net warrants. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
Owner
Author
|
Merged into main via rebase fast-forward (commits applied via stack rebase, see main's history). Branch deleted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the highest-impact gap from the TDD audit retrospective: the project had zero component-level tests. The C2 `roleNotes` scope error in PR #3 (caught only by spec review) is the canonical example — green unit tests + green build, yet a runtime `ReferenceError` when reaching the verdict screen.
Stacks on PR #6.
What's set up
New devDeps: `@testing-library/react`, `@testing-library/jest-dom`, `@testing-library/user-event`, `jsdom`.
vitest.config.js: per-file environment via `environmentMatchGlobs`. Only `*.dom.test.jsx` files spin up jsdom — the existing 109 node-env tests stay fast. Adds `@vitejs/plugin-react` for JSX transform.
src/test-setup.js: jest-dom matchers (`toBeInTheDocument`, `toBeEnabled`, …) + a stub for `window.scrollTo` (jsdom doesn't implement it; the App calls it on step change → otherwise produces noisy stderr).
Tests added (`src/app.dom.test.jsx`)
4 component smoke tests:
Tests
What's deferred
Deep Result-screen walk-throughs (advancing all 7 steps to verify the verdict renders) are NOT in this PR. Getting there in jsdom with the current UI requires selector engineering that's high-effort for limited additional safety. The correct path forward is Playwright E2E (Playwright is already a devDep, used by `make-demo.cjs` to record the demo video).
A natural follow-up would be a single `tests/e2e/result.spec.js` that walks each verdict path end-to-end with screenshot assertions.
Test plan
🤖 Generated with Claude Code