Skip to content

test(webmcp-polyfill): add browser-mode Vitest config & declarative DOM tool support - #145

Open
MiguelsPizza wants to merge 1 commit into
mainfrom
codex/polyfill-declarative-api-using-conformance-testing
Open

test(webmcp-polyfill): add browser-mode Vitest config & declarative DOM tool support#145
MiguelsPizza wants to merge 1 commit into
mainfrom
codex/polyfill-declarative-api-using-conformance-testing

Conversation

@MiguelsPizza

Copy link
Copy Markdown
Contributor

Motivation

  • The polyfill tests exercise browser globals (navigator, document) and need a browser-mode Vitest path to run conformance-style tests reliably.
  • Support declarative tool registration in the DOM so the polyfill can be validated against script/data-attribute based tool registrations used by consumers.

Description

  • Added a browser-specific Vitest config packages/webmcp-polyfill/vitest.browser.config.ts wired to Playwright/Chromium and added test:browser / test:browser:ui scripts in packages/webmcp-polyfill/package.json so browser-mode runs are explicit and opt-in.
  • Added browser testing dependencies to packages/webmcp-polyfill/package.json and updated pnpm-lock.yaml to include @vitest/browser, @vitest/browser-playwright, and playwright entries.
  • Implemented declarative tool parsing and synchronization in packages/webmcp-polyfill/src/index.ts (parse scripts of type application/webmcp+json, [data-webmcp-tool] elements, startDeclarativeToolSync with MutationObserver, integration into initializeWebMCPPolyfill and cleanup logic, and exposing serialized cross-document results to the testing shim).
  • Extended tests in packages/webmcp-polyfill/src/index.test.ts to assert parsing of declarative <script> entries and data-webmcp-tool elements and that declarative registrations are synchronized when DOM nodes are removed.

Testing

  • Ran pnpm --filter @mcp-b/webmcp-polyfill build and the build completed successfully (tsdown/tsc step passed).
  • Ran pnpm --filter @mcp-b/webmcp-polyfill test (Node-mode Vitest) and observed failures because the suite expects browser globals (navigator, document) in this environment; the Node-only run reported many failing tests (navigator is not defined).
  • Ran pnpm --filter @mcp-b/webmcp-polyfill test:browser which starts Vitest in browser mode, but the run could not complete because Playwright Chromium is not available in this environment and playwright install chromium failed (browser download blocked by network: 403 Domain forbidden).
  • Attempted pnpm --filter @mcp-b/webmcp-polyfill exec playwright install chromium and received a network/download failure preventing browser installation; this prevents executing the browser-mode tests here but the project is now wired so CI with an available Chromium (or allowed Playwright downloads) can run the conformance suite.

Codex Task

@MiguelsPizza
MiguelsPizza requested a review from a team as a code owner March 4, 2026 20:09
@MiguelsPizza
MiguelsPizza force-pushed the codex/polyfill-declarative-api-using-conformance-testing branch from 887ebbc to da3f3a6 Compare March 4, 2026 20:22
@github-actions github-actions Bot added testing Test-related changes config Configuration file changes dependencies Dependency updates labels Mar 4, 2026
@sentry

sentry Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.09677% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/webmcp-polyfill/src/index.ts 87.09% 11 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex config Configuration file changes dependencies Dependency updates testing Test-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant