Skip to content

Configure Vitest environments centrally - #1872

Merged
BryonLewis merged 2 commits into
mainfrom
vitest-jsdom-default
Aug 29, 2026
Merged

Configure Vitest environments centrally#1872
BryonLewis merged 2 commits into
mainfrom
vitest-jsdom-default

Conversation

@PaulHax

@PaulHax PaulHax commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Configure Vitest environments centrally

Test files should not need repeated Vitest headers.

Changes

  • Select environments by directory. Component specs (src/components/**, dive-common/components/**) and everything under platform/web-girder/** run in a shared jsdom project; the rest stay in Vitest's Node environment.
  • Remove per-file jsdom directives and Vitest type references.
  • Upgrade jsdom 24 to 30.

The whole platform/web-girder tree needs a DOM: its plugin layer reads window at import time, so any spec that reaches the API layer fails without one. Naming the directory rather than individual files means a new spec added there needs no config edit.

jsdom 24 implements none of Blob.text(), Blob.arrayBuffer(), or Blob.stream(). Two specs in that tree build File objects and passed only because Node's File is more spec-compliant than the DOM environment's. jsdom 30 provides text() and arrayBuffer(). stream() is still absent, and is used only by the stereo tests, which stay in Node because they resolve binary fixtures through fileURLToPath(import.meta.url).

Four specs that carried @vitest-environment jsdom on main now run in Node: platform/desktop/backend/serializers/viame.spec.ts, platform/desktop/sharedUtils.spec.ts, and both src/alignedView/homography.spec.ts and src/alignedView/transform.spec.ts. They pass — the directives were unnecessary.

Validation

  • Client unit tests
  • Client lint
  • Client typecheck

The web-girder plugin layer reads `window` at import time, so every spec
under platform/web-girder needs a DOM; name the directory rather than the
individual files.

jsdom 30 implements Blob.text() and Blob.arrayBuffer(), which the
File-based specs in that tree rely on. jsdom 24 implements neither.
@PaulHax
PaulHax marked this pull request as ready for review August 29, 2026 13:39
@PaulHax
PaulHax requested a review from BryonLewis August 29, 2026 13:40
@BryonLewis
BryonLewis merged commit ad9382f into main Aug 29, 2026
3 checks passed
@BryonLewis
BryonLewis deleted the vitest-jsdom-default branch August 29, 2026 17:57
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