fix: don't assume a test section when vite runs in test mode - #302
Conversation
🦋 Changeset detectedLatest commit: 038e45d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
a0771fb to
038e45d
Compare
In test mode the plugin destructured
config.testand readtest.environmentwithout guarding it. vitest resolves a plainvite.config.ts— which has notestsection — so merely having@marko/viteinstalled madevitest runfail before a single test loaded:That pushes consumers into maintaining a separate
vitest.config.tspurely 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
testsection is present;test.execArgvis only touched inside that branch, wheretestis known to exist.Verified against the real failure: with a locally built
distswapped into markojs.com'snode_modules,vitest run --config vite.config.tsgoes from the TypeError above toTest Files 1 passed / Tests 6 passed.