Skip to content

TKW: clean up vitest stderr (act warning + jsdom nav)#8

Merged
codebend3r merged 9 commits into
mainfrom
vitest-output
Jun 8, 2026
Merged

TKW: clean up vitest stderr (act warning + jsdom nav)#8
codebend3r merged 9 commits into
mainfrom
vitest-output

Conversation

@codebend3r

Copy link
Copy Markdown
Owner

Summary

  • Wrap the fake ResizeObserver callback in act inside components/MapStage/MapStage.test.tsx so the resulting setSize flushes without the "update to MapStage inside a test was not wrapped in act(...)" warning.
  • Cancel the default anchor action in components/SiteMenu/SiteMenu.test.tsx's "closes when a nav link is activated" test, so jsdom stops printing "Not implemented: navigation to another Document". React's onClick={close} still fires, so the assertion is unchanged.

Test plan

  • bun run test — 34 files, 351 tests, no act() warnings, no "Not implemented" messages
  • tsc --noEmit (pre-commit / pre-push hooks)
  • eslint (pre-commit hook)
  • next build (pre-push hook)

- import `act` from `@testing-library/react`
- wrap each `observers[0].cb(...)` call so the `setSize` update is flushed inside `act`
- silences the "update to `MapStage` inside a test was not wrapped in act(...)" warnings
- attach a `preventDefault` listener on the `Maps` anchor before `fireEvent.click`
- jsdom no longer prints "Not implemented: navigation to another Document"
- React's `onClick={close}` still fires, so the assertion is unchanged
@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for theknownworld ready!

Name Link
🔨 Latest commit dd99f05
🔍 Latest deploy log https://app.netlify.com/projects/theknownworld/deploys/6a26d1a9de221500081daca4
😎 Deploy Preview https://deploy-preview-8--theknownworld.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

- add `@vitest/coverage-istanbul@4.1.7` as an exact-pinned devDependency
- `vitest.config.ts`: `reporters: ['dot']` and a `coverage` block (`provider: 'istanbul'`, reporters `text`, `text-summary`, `html`, `lcov`, scoped to `components/**` and `lib/**`)
- exclude `*.test.{ts,tsx}`, `index.ts` re-export barrels, `*.d.ts`, and `*.module.scss` from the coverage scope
- new `coverage` script runs `vitest run --coverage`; outputs land under the already-gitignored `coverage/` directory
- generated istanbul coverage reports include a `block-navigation.js` that trips ESLint with an unused-disable-directive warning
- ignore the whole `coverage/**` tree (already in `.gitignore`)
- every test name is now printed, with per-test timing
- `basic` was removed as a built-in reporter name in vitest 4
- `[['default', { summary: false }]]` reproduces the old basic behavior: one line per test file, no live-progress tree, totals at the end
- `coverage.thresholds`: statements 85, branches 75, functions 85, lines 90
- locked a few points below the current baseline (89/79/88/92) so normal churn doesn't fail CI but real regressions do
- `bun run coverage` errors and exits non-zero if any threshold falls below the floor
…tions.ts`

- new `DropCap.test.tsx`: renders children in a `<p>` with the `dropCap` class
- new `ParchmentLayout.test.tsx`: renders children in a `<main>` landmark with the `page` class
- new `Sources.test.tsx`: covers the empty-array short-circuit, awoiaf link rendering with default and explicit license, and the non-awoiaf span fallback chain (`ref` → `url` → `type`)
- new `MapLayerToggle.test.tsx`: one checkbox per `ALL_CASTLE_TYPES`, checked state mirrors the `enabled` set, `onToggle` fires with the right type, exposes a labelled `group` role
- new `MapMarker.test.tsx`: anchor href + aria-label + tabindex, label `<text>` offset, and one assertion per `Castle["type"]` glyph (`castle`, `town`, `ruin`, `watchtower`, `holdfast`)
- `lib/relations.test.ts`: cover `buildRelationGraph` paths where the castle has no `liege-house`, the character has a null `primary-house`, and events use raw coords vs a string location; new `findOrphanSlugs` tests for character ref arrays (parents/spouses/children/primary-house) and event refs (location/participant houses/casualties)
- coverage: 374/374 pass (was 351); statements 89.09 → 91.64, branches 79.10 → 82.83, functions 87.86 → 92.48, lines 92.10 → 94.53
- `HouseInfobox.test.tsx`: liege not in `housesBySlug` falls back to a plain span; singular vs plural "Cadet branch(es)" rows; `Founded` row for AC/BC; `formatDate` humanizes legendary fantasy eras with `(legendary)` suffix and non-legendary fantasy eras without it; `Extinct` row when present
- `WeaponInfobox.test.tsx`: "Destroyed" current-house label when null and status is destroyed; `current-house` populated renders the InfoRow with a link; `Forged` row for AC/BC; legendary-era `formatDate` suffix path; `Destroyed` date row when present
- `DragonInfobox.test.tsx`: legendary-era hatched date suffix; non-legendary fantasy era without suffix; missing-house slug falls back to humanized "House X" label without a link
- coverage: 389/389 pass (was 374); statements 91.64 → 92.96, branches 82.83 → 86.56, functions 92.48 → 94.5, lines 94.53 → 95.85
@codebend3r codebend3r merged commit 69fa10c into main Jun 8, 2026
5 checks passed
@codebend3r codebend3r deleted the vitest-output branch June 8, 2026 14:33
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