Skip to content

fix: import builtinEnvironments from vitest/runtime#36

Merged
codepunkt merged 1 commit into
mainfrom
fix/vitest-runtime-import
Jun 11, 2026
Merged

fix: import builtinEnvironments from vitest/runtime#36
codepunkt merged 1 commit into
mainfrom
fix/vitest-runtime-import

Conversation

@codepunkt

@codepunkt codepunkt commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

Vitest 4.1 deprecated the vitest/environments entry point in favor of vitest/runtime, which prints this warning every time the environment is imported:

Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.

This switches the environment (and its test mock) to vitest/runtime, which re-exports both builtinEnvironments (value) and the Environment (type) we use.

Changes

  • src/index.ts: import Environment + builtinEnvironments from vitest/runtime.
  • src/index.test.ts: update vi.mock('vitest/environments')vi.mock('vitest/runtime').
  • package.json: raise the vitest peer dependency floor to >=4.1 <5 and bump dev deps vitest / @vitest/coverage-v8 to 4.1.8.
  • README.md: note the peer requirement is now vitest 4.1 or newer.

Compatibility note

vitest/runtime does not exist before 4.1 (verified against the npm registry: 4.0.x exposes only ./environments). Switching the import therefore requires raising the peer floor to 4.1, which drops support for vitest 4.0.x. Flagging so the release type can be chosen accordingly.

Lint, format, typecheck, tests (10/10, 100% coverage) and build all pass locally on vitest 4.1.8.

Summary by CodeRabbit

  • Chores

    • Updated Vitest development dependency from 4.0.16 to 4.1.8.
    • Updated minimum peer dependency requirement for Vitest from 4.x to 4.1 or newer.
  • Tests

    • Updated test configuration for compatibility with Vitest 4.1 and newer versions.

Vitest 4.1 deprecated the `vitest/environments` entry point in favor of
`vitest/runtime`, emitting a runtime warning on every import:

  Importing from "vitest/environments" is deprecated since Vitest 4.1.
  Please use "vitest/runtime" instead.

Switch the environment and its test mock to `vitest/runtime`, which
re-exports both `builtinEnvironments` and the `Environment` type.

Since `vitest/runtime` only exists from 4.1 onward, raise the vitest peer
dependency floor to `>=4.1 <5` and bump the dev dependencies to 4.1.8.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "review"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81303ed1-c514-4d79-a38f-d38d5a49f8a6

📥 Commits

Reviewing files that changed from the base of the PR and between fbec41a and 1ec2cdd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • README.md
  • package.json
  • src/index.test.ts
  • src/index.ts

📝 Walkthrough

Walkthrough

This PR upgrades vitest to version 4.1.8 and adapts the codebase to the API changes in that release. The environment exports moved from vitest/environments to vitest/runtime, requiring updates to both the package dependencies and the corresponding import statements in source and test files.

Changes

Vitest 4.1 Upgrade

Layer / File(s) Summary
Version and documentation alignment
package.json, README.md
The dev dependency is bumped from 4.0.16 to 4.1.8, peer dependency constraint remains >=4.1 <5, and README documentation is updated to specify vitest 4.1 or newer.
Runtime import source updates
src/index.ts, src/index.test.ts
Imports for Environment and builtinEnvironments are moved from vitest/environments to vitest/runtime, and the test mock target is updated to match.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through vitest's growing maze,
From old /environments to bright runtime ways,
With version bumped to 4.1 and true,
The imports align, and tests pass through! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: switching imports from 'vitest/environments' to 'vitest/runtime' to address Vitest 4.1 deprecation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vitest-runtime-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f95fc65) to head (1ec2cdd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #36   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           56        58    +2     
  Branches         6         7    +1     
=========================================
+ Hits            56        58    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codepunkt codepunkt merged commit 9924419 into main Jun 11, 2026
4 checks passed
@codepunkt codepunkt deleted the fix/vitest-runtime-import branch June 11, 2026 15:05
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