TKW: clean up vitest stderr (act warning + jsdom nav)#8
Merged
Conversation
- 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
✅ Deploy Preview for theknownworld ready!
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
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
ResizeObservercallback inactinsidecomponents/MapStage/MapStage.test.tsxso the resultingsetSizeflushes without the "update toMapStageinside a test was not wrapped in act(...)" warning.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'sonClick={close}still fires, so the assertion is unchanged.Test plan
bun run test— 34 files, 351 tests, noact()warnings, no "Not implemented" messagestsc --noEmit(pre-commit / pre-push hooks)eslint(pre-commit hook)next build(pre-push hook)