fix: import builtinEnvironments from vitest/runtime#36
Conversation
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.
|
Note
|
| 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/environmentsto 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Summary
Vitest 4.1 deprecated the
vitest/environmentsentry point in favor ofvitest/runtime, which prints this warning every time the environment is imported:This switches the environment (and its test mock) to
vitest/runtime, which re-exports bothbuiltinEnvironments(value) and theEnvironment(type) we use.Changes
src/index.ts: importEnvironment+builtinEnvironmentsfromvitest/runtime.src/index.test.ts: updatevi.mock('vitest/environments')→vi.mock('vitest/runtime').package.json: raise thevitestpeer dependency floor to>=4.1 <5and bump dev depsvitest/@vitest/coverage-v8to4.1.8.README.md: note the peer requirement is nowvitest4.1or newer.Compatibility note
vitest/runtimedoes 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 to4.1, which drops support for vitest4.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
Tests