Skip to content

Fix test cleanup and clarify Node.js LTS setup text - #41

Merged
DanWahlin merged 2 commits into
mainfrom
fix-test-cleanup-and-node-lts-docs
Oct 14, 2026
Merged

DanWahlin merged 2 commits into
mainfrom
fix-test-cleanup-and-node-lts-docs

Conversation

@DanWahlin

Copy link
Copy Markdown
Collaborator

Two fixes that came out of the review of #33.

1. Tests do not clean up between renders

tsconfig.json loads the vitest/globals types, but the test script did not run Vitest with --globals. Because of this, React Testing Library did not unmount components after each test.

When two tests in the same file render <App />, the second test fails:

TestingLibraryElementError: Found multiple elements with the text of: Search

In Chapter 06, the agent writes Clear filters tests that render App more than once, so learners can see this failure. #33 added afterEach(cleanup) to work around it.

Fix: "test": "vitest --environment jsdom --globals" in samples/book-app-web/package.json.

2. Node.js version text in setup

#40 changed the app to require Node 24 or later. 00-setup/README.md said "Node.js LTS or later", but Node 22 is also an LTS version. Learners on Node 22 would get EBADENGINE warnings.

Fix: Tell learners to compare the first number of node -v with the LTS version on the Node.js download page. The text has no pinned version number, so it stays correct when a new LTS version is released.

Validation

In samples/book-app-web, on Node 24.11.1:

  • With a temporary test that renders App twice: 6/6 tests pass (before the fix, 1 test failed). I removed the temporary test after the check.
  • npm test -- --run: 4/4 tests pass. The count is the same, so the Chapter 06 baseline screenshots are still correct.
  • npm run build: passes

Run Vitest with --globals so React Testing Library unmounts components
after each test. Without it, two tests that render App in the same file
fail with "Found multiple elements". tsconfig already loads the
vitest/globals types.

Tell learners to compare node -v with the LTS version on the Node.js
download page, so the setup text stays correct without a pinned version.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI max review requested due to automatic review settings October 14, 2026 18:54

Copilot AI 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.

🟢 Approval recommended

The changes are small, have reported test and build validation, and only non-blocking feedback remains.

0 open findings

What changed in this PR

Fixes test isolation in the course’s book app and clarifies Node.js setup requirements.

Changes:

  • Enables Vitest globals for automatic cleanup between tests.
  • Clarifies LTS selection and major-version checks.
File Description
samples/​book-app-web/​package.json Enables Vitest globals for test cleanup.
00-setup/​README.md Updates Node.js installation and version-check guidance.

🧠 Review effort: Max


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@DanWahlin
DanWahlin merged commit 1ba934e into main Oct 14, 2026
5 checks passed
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.

2 participants