Skip to content

test: set IS_REACT_ACT_ENVIRONMENT once per package in a vitest setup file - #152

Open
librowski wants to merge 2 commits into
ds2-review-follow-upsfrom
ds2-ui-vitest-setup
Open

librowski wants to merge 2 commits into
ds2-review-follow-upsfrom
ds2-ui-vitest-setup

Conversation

@librowski

@librowski librowski commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

IS_REACT_ACT_ENVIRONMENT was set at the top of seven specs (six in ui, one in AI Studio), with two competing typings: a globalThis cast in five files and a declare global block with an eslint-disable no-var in the other two. Neither package has testing-library, so nothing set the flag centrally. In AI Studio the app tsconfig excludes spec files, so its declare global was never type-checked at all.

Changes

Per package (packages/ui, apps/ai-studio):

  • vitest.setup.ts sets the flag once; the vitest test block loads it through setupFiles.
  • types.d.ts declares var IS_REACT_ACT_ENVIRONMENT: boolean in declare global, so specs need no cast.
  • The specs drop their local copies.
  • ui only: tsconfig.json includes the setup file so tsc checks it (AI Studio picks it up by default, its tsconfig has no include), and vite-plugin-dts excludes it so nothing lands in dist.

Checks

  • vitest ui 74 and AI Studio 16 passing. Negative control with setupFiles removed: the ui menu spec logs 44 "not configured to support act" warnings and AI Studio logs 8; with the setup none.
  • A deliberate = 'x' in each setup file fails the package typecheck, so both files are type-checked.
  • ui dist has no new files, publint and check:built-css pass; AI Studio builds.
  • eslint and prettier clean on the touched files.

The flag was set ad hoc at the top of six specs, with two competing
typings (a globalThis cast and a declare global block). vitest.setup.ts
sets it for every test, types.d.ts declares it, and the setup file is
type-checked but excluded from the emitted declarations.
Same layout as packages/ui: vitest.setup.ts sets the flag, types.d.ts
declares it, the spec drops its declare global block.
@librowski librowski changed the title test(ui): set IS_REACT_ACT_ENVIRONMENT once in a vitest setup file test: set IS_REACT_ACT_ENVIRONMENT once per package in a vitest setup file Sep 15, 2026
@librowski
librowski marked this pull request as ready for review September 15, 2026 11:13
@librowski
librowski added this pull request to stack #151 September 15, 2026 11:13
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