Skip to content

[WIP] convert all test to vitest-browser - #2663

Open
matyasf wants to merge 3 commits into
masterfrom
vitest_browser_convert
Open

[WIP] convert all test to vitest-browser#2663
matyasf wants to merge 3 commits into
masterfrom
vitest_browser_convert

Conversation

@matyasf

@matyasf matyasf commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

The root tsconfig.json (which every packages/*/tsconfig.json extends, and which the IDE resolves for test files) used module Node16 / moduleResolution node16, while tsconfig.build.json (used by ts:check and build:types) used ESNext / bundler. Under node16 TS classifies every file as CommonJS, since no package sets "type": "module", so the browser-mode tests importing ESM-only vitest-browser-react and vitest/browser reported TS1479 in the editor while ts:check stayed green.

Make tsconfig.json extend tsconfig.build.json so the two cannot drift again. Only exclude is restated, since it replaces rather than merges. This clears 31 TS1479s plus ~90 related interop errors (TS2835, TS1541, TS2834) across the 15 browser-mode test files and packages/docs. The bundler model is the accurate one here: these tests are never compiled by tsc, Vite transforms them as ESM.

Also drop the tests exclude from the six tsconfig.build.json files that had it, so their tests are typechecked like the other 89 packages'. That exclude was hiding a real error in FocusRegion.test.tsx, where .element() returns HTMLElement | SVGElement; cast it to HTMLElement.

🤖 Generated with Claude Code

The root tsconfig.json (which every packages/*/tsconfig.json extends, and which the IDE
resolves for test files) used module Node16 / moduleResolution node16, while
tsconfig.build.json (used by ts:check and build:types) used ESNext / bundler. Under node16
TS classifies every file as CommonJS, since no package sets "type": "module", so the
browser-mode tests importing ESM-only vitest-browser-react and vitest/browser reported
TS1479 in the editor while ts:check stayed green.

Make tsconfig.json extend tsconfig.build.json so the two cannot drift again. Only exclude
is restated, since it replaces rather than merges. This clears 31 TS1479s plus ~90 related
interop errors (TS2835, TS1541, TS2834) across the 15 browser-mode test files and
packages/__docs__. The bundler model is the accurate one here: these tests are never
compiled by tsc, Vite transforms them as ESM.

Also drop the __tests__ exclude from the six tsconfig.build.json files that had it, so
their tests are typechecked like the other 89 packages'. That exclude was hiding a real
error in FocusRegion.test.tsx, where .element() returns HTMLElement | SVGElement; cast it
to HTMLElement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matyasf matyasf self-assigned this Jul 28, 2026
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2663/

Built to branch gh-pages at 2026-07-29 15:12 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

github-actions Bot pushed a commit that referenced this pull request Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Visual regression report

⚠️ Changes detected.

Status Count
Unchanged 0
Changed 1
New 96
Removed 32

📊 View full report

Diff images (33)

alert.png — baseline no longer produced

avatar.png — baseline no longer produced

badge.png — baseline no longer produced

billboard.png — baseline no longer produced

breadcrumb.png — baseline no longer produced

button-and-derivatives.png — baseline no longer produced

byline.png — baseline no longer produced

calendar.png — baseline no longer produced

checkbox.png — baseline no longer produced

checkboxgroup.png — baseline no longer produced

colorpicker.png — baseline no longer produced

contextview.png — baseline no longer produced

custom-and-lucide-icons.png — baseline no longer produced

dateinput-dateinput2.png — baseline no longer produced

datetimeinput.png — baseline no longer produced

diff-demo.png — 6324 pixels differ

drilldown.png — baseline no longer produced

filedrop.png — baseline no longer produced

form-errors.png — baseline no longer produced

heading.png — baseline no longer produced

img.png — baseline no longer produced

link.png — baseline no longer produced

menu.png — baseline no longer produced

metric-pill-tag-timeselect-text.png — baseline no longer produced

options.png — baseline no longer produced

pagination.png — baseline no longer produced

progressbar.png — baseline no longer produced

select-simpleselect.png — baseline no longer produced

table.png — baseline no longer produced

tabs.png — baseline no longer produced

tooltip.png — baseline no longer produced

treebrowser.png — baseline no longer produced

view.png — baseline no longer produced

Baselines come from the visual-baselines branch. They refresh on every merge to master.

Convert the unit tests of ui-billboard, ui-breadcrumb, ui-buttons, ui-byline, ui-calendar,
ui-checkbox and ui-color-picker to Vitest browser mode, and port the matching Cypress specs
(ToggleButton, ColorIndicator, ColorMixer, ColorPicker, ColorPreset) to the bottom of the
corresponding unit test files. The Cypress specs are removed.

Notable real-browser adaptations:
- `{ force: true }` where Playwright refuses to click disabled/aria-disabled or visually
  hidden elements
- native `ClipboardEvent` with a real `DataTransfer` instead of `fireEvent.paste`
- `fireEvent.focusIn/focusOut` instead of `blur`/`focus`, which React does not listen for
- hidden tooltips are queried from the DOM, since they are not in the accessibility tree
- `unhover` before hover/click assertions, because the pointer position persists between
  tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 29, 2026
Move ui-date-input, ui-date-time-input, ui-dom-utils, ui-drawer-layout and
ui-drilldown from the jsdom `web` project to the real-browser `browser` project,
and fold the matching Cypress component specs into the unit test files as
`Component tests` blocks.

Notable real-browser adaptations:
- computed `transition` is never empty, so DrawerContent asserts on
  `transitionDuration` instead
- Playwright refuses to click `aria-disabled`/`disabled` elements, so those tests
  click the inner label content or dispatch the event directly
- a real click lands on the innermost label element, so `event.target` is checked
  with `toContainElement`
- Drilldown keyboard nav needs a `cleanup()` + settle `afterEach` and an explicit
  re-focus after page transitions, because the Popover FocusRegion schedules an
  async focus return that otherwise swallows later key presses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 29, 2026
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