Skip to content

fix: don't assume a test section when vite runs in test mode - #302

Merged
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-marko-website-3w77hx
Jul 28, 2026
Merged

fix: don't assume a test section when vite runs in test mode#302
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-marko-website-3w77hx

Conversation

@DylanPiercey

@DylanPiercey DylanPiercey commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

In test mode the plugin destructured config.test and read test.environment without guarding it. vitest resolves a plain vite.config.ts — which has no test section — so merely having @marko/vite installed made vitest run fail before a single test loaded:

TypeError: Cannot read properties of undefined (reading 'environment')
    at BasicMinimalPluginContext.config (@marko/vite/dist/index.mjs)

That pushes consumers into maintaining a separate vitest.config.ts purely to keep the site plugins out of the way, which is what surfaced this on markojs.com.

The dom-environment branch is unchanged when a test section is present; test.execArgv is only touched inside that branch, where test is known to exist.

Verified against the real failure: with a locally built dist swapped into markojs.com's node_modules, vitest run --config vite.config.ts goes from the TypeError above to Test Files 1 passed / Tests 6 passed.

@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 038e45d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@marko/vite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a0c04ca-2ca8-4c4f-9b18-89ad06d5c58e

📥 Commits

Reviewing files that changed from the base of the PR and between 69eb53f and 038e45d.

📒 Files selected for processing (2)
  • .changeset/vitest-without-test-config.md
  • src/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dpiercey-ws-marko-website-3w77hx

Comment @coderabbitai help to get the list of available commands.

vitest resolves a plain vite config, which has no `test` section, so
destructuring it and reading `test.environment` threw before any test
loaded. Having `@marko/vite` installed was enough to make `vitest run`
fail with `Cannot read properties of undefined (reading 'environment')`,
which pushed consumers into keeping a separate vitest config.

The dom-environment branch still runs when a `test` section is present.
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-website-3w77hx branch from a0771fb to 038e45d Compare July 28, 2026 18:46
@DylanPiercey
DylanPiercey merged commit 0a401ca into main Jul 28, 2026
7 checks passed
@DylanPiercey
DylanPiercey deleted the dpiercey-ws-marko-website-3w77hx branch July 28, 2026 18:52
@github-actions github-actions Bot mentioned this pull request Jul 28, 2026
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Jul 31, 2026
@DylanPiercey DylanPiercey self-assigned this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant