Skip to content

feat(extension-sdk): add the base element in unit tests - #3800

Merged
JammingBen merged 4 commits into
mainfrom
feat/extension-sdk-vitest-base
Oct 20, 2026
Merged

JammingBen merged 4 commits into
mainfrom
feat/extension-sdk-vitest-base

Conversation

@dschmidt

@dschmidt dschmidt commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Stacked on #3798.

Web always has <base href="/">, and since #3798 the web unit tests add it in vitest.init.ts. Extensions run their unit tests with the test config from defineConfig of the extension SDK, which had no setup file. So an extension test that reaches buildUrl had to add the element itself.

The SDK now ships dist/vitest.setup.js, which adds the element, and sets it as setupFiles in the test config. A setupFiles of the extension is merged in, not replaced (mergeConfig concatenates arrays).

The path is built from dirname(import.meta.url), because Vite turns new URL('./vitest.setup.js', import.meta.url) into an inlined asset at build time.

Related Issue

How Has This Been Tested?

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@dschmidt
dschmidt added this pull request to stack #3801 October 14, 2026 14:30
@dschmidt
dschmidt marked this pull request as ready for review October 14, 2026 14:37
Base automatically changed from feat/build-url-route-location to main October 20, 2026 08:55
Web always has <base href="/"> and helpers like buildUrl rely on it for history mode. Extensions run their unit tests with the SDK config, which had no setup file, so each spec had to add the element itself. The SDK now ships a setup file that adds it, like the web unit test setup.
@dschmidt
dschmidt force-pushed the feat/extension-sdk-vitest-base branch from f177b72 to 8718f5a Compare October 20, 2026 08:55
@JammingBen
JammingBen merged commit 12356f2 into main Oct 20, 2026
27 checks passed
@JammingBen
JammingBen deleted the feat/extension-sdk-vitest-base branch October 20, 2026 11:22
@openclouders openclouders mentioned this pull request Oct 20, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants