Skip to content

Stabilize frontend CI tests by adding global ResizeObserver test setup#33

Merged
AlanFokCo merged 2 commits into
mainfrom
copilot/fix-image-upload-failure
May 23, 2026
Merged

Stabilize frontend CI tests by adding global ResizeObserver test setup#33
AlanFokCo merged 2 commits into
mainfrom
copilot/fix-image-upload-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 23, 2026

The Studio Tests frontend job was still failing in CI due to ReferenceError: ResizeObserver is not defined under Vitest/jsdom. This surfaced in open-in-new-tab.test.tsx when components using responsive observers mounted during test execution.

  • Root cause

    • Vitest runs in jsdom, which does not provide ResizeObserver by default.
    • Components like ReportViewer/ReportLinkModal instantiate ResizeObserver in effects, causing runtime failure before test assertions.
  • Changes in this PR

    • Centralized test runtime shim
      • Added src/test/setup.ts to define a no-op ResizeObserver when absent in the test environment.
      • Stub matches expected API shape (observe, unobserve, disconnect) to avoid argument/signature drift.
    • Vitest configuration wiring
      • Updated vite.config.ts to load the shared setup via test.setupFiles.
  • Why this shape

    • Keeps component code unchanged and browser-faithful.
    • Prevents per-test ad hoc mocks and ensures consistent behavior across the frontend test suite.
// vite.config.ts
test: {
  environment: "jsdom",
  setupFiles: "./src/test/setup.ts",
  passWithNoTests: true,
}

Copilot AI and others added 2 commits May 23, 2026 05:01
@AlanFokCo AlanFokCo marked this pull request as ready for review May 23, 2026 05:26
@AlanFokCo AlanFokCo merged commit eca08bd into main May 23, 2026
@AlanFokCo AlanFokCo deleted the copilot/fix-image-upload-failure branch May 23, 2026 05:26
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