chore(deps-dev): bump vitest from 3.2.4 to 4.1.4#648
chore(deps-dev): bump vitest from 3.2.4 to 4.1.4#648dependabot[bot] wants to merge 1 commit intomainfrom
Conversation
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 3.2.4 to 4.1.4. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.4/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-version: 4.1.4 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change updates the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package.json`:
- Line 44: Update the Vite dependency in package.json to a version compatible
with Vitest v4 by changing the "vite" entry (currently "vite": "^5.4.11") to at
least v6 (for example "vite": "^6.0.0"), then run dependency install and verify
tests; ensure the package.json "vite" field is the only change and update
lockfile accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 491e7bbd-6870-4612-8c69-f0d2973196a2
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
package.json
| "typescript": "^5.5.4", | ||
| "vite": "^5.4.11", | ||
| "vitest": "^3.2.4" | ||
| "vitest": "^4.1.4" |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Vitest v4 migration guide breaking changes from v3
💡 Result:
Vitest v4 migration (from v3): breaking changes / required updates
- Prereqs: Vitest 4 requires Node.js ≥ 20 and Vite ≥ 6. Update these first. [1]
- Coverage (V8 provider):
- Coverage remapping changed (expect different numbers). [1]
- Updated ignore-hints behavior;
coverage.ignoreEmptyLinesremoved;coverage.experimentalAstAwareRemappingremoved (now default). [1] coverage.allandcoverage.extensionsremoved; you should setcoverage.includeexplicitly (v4 defaults to “only covered files”). [1]
- Default
test.excludeis much less aggressive: by default it mainly excludesnode_modulesand.git, so folders likedist/,cypress/, and various dot-folders/config files may now be considered unless you add exclusions or usetest.dir. [1] - Mocking changes (can break snapshots/assertions):
vi.spyOn/vi.fnnow support constructors; arrow-function implementations will fail when called withnew. [1]vi.fn().getMockName()default changes (can affect snapshots). [1]vi.restoreAllMocks()no longer resets spy state the same way (and automocks aren’t affected). [1]vi.fn().mock.invocationCallOrdernow starts at 1 (Jest-aligned). [1]
- Pools/workers rework (config renames/removals):
maxThreads/maxForks→maxWorkers(env vars changed too). [1]singleThread/singleFork→maxWorkers: 1, isolate: false(addvi.resetModules()in setup if you relied on resets). [1]poolOptionsremoved; many pool options are now top-level; VM poolmemoryLimit→vmMemoryLimit. [1]
- CLI behavior:
--standalone+ filename filter now runs matched files immediately (v3 ignored the filter). [1] - Runtime internals: Vitest replaces
vite-nodeusage with Vite’s Module Runner:vitest/executeentry removed; env varVITE_NODE_DEPS_MODULE_DIRECTORIES→VITEST_MODULE_DIRECTORIES; some custom-environment fields change. [1]
- Config/workspace:
workspaceis replaced by/renamed toprojects(if you still used the old pattern). [1] - Browser mode provider changes: provider setup moved to separate packages (e.g.
@vitest/browser-playwright),previewis no longer the default, and imports like@vitest/browser/contextshould move tovitest/browser(transition period noted). [1][2] - Reporters:
- Legacy reporter hooks (
onCollected,onFinished, etc.) removed;basicreporter removed;verboseformatting behavior changed (usetreereporter to restore prior style). [1][2]
- Legacy reporter hooks (
- Snapshots: snapshots including custom elements now print shadow root by default (
printShadowRoot: falseto revert). [1] - Deprecated APIs removed: e.g.
poolMatchGlobs,environmentMatchGlobs, olddeps.*options in favor ofserver.deps.*,browser.testerScripts,minWorkers, and passing a test-options object as the 3rd arg totest/describe. [1]
Primary reference: Vitest’s official Migration Guide (Migrating to Vitest 4.0). [1]
Sources: [1] Vitest Migration Guide, [2] “Vitest 4.0 is out!” announcement.
🌐 Web query:
Vitest 4 globals API changes and vitest/globals types compatibility
💡 Result:
Vitest v4 “globals” API (runtime) — what changed
- Vitest still does not enable Jest-like globals by default; you must opt in via
test.globals: true(config) or--globals(CLI). (vitest.dev) - In the v4 migration, one “globals-adjacent” breaking change that often surfaces in test files is that
test()/describe()no longer accept the test-options object as a 3rd argument (it must be the 2nd argument now). (vitest.dev) - Vitest v4 also removed deprecated types, which (among other things) fixed an issue where Vitest could accidentally pull in
@types/node. If you relied on Node typings being implicitly present, you may now need to add them explicitly in your TS config. (vitest.dev)
vitest/globals TypeScript types — compatibility rules / common pitfalls
- To get TypeScript to recognize
describe/it/expect/vias globals, add this to the relevanttsconfig:"types": ["vitest/globals"](vitest.dev)
- If you customized
"typeRoots", you must ensurenode_modulesis still discoverable (otherwise TS may fail to findvitest/globals). (vitest.dev) - Once you include
"vitest/globals"in atsconfigthat covers non-test files, those files will also type-check withdescribe/it/expectavailable, and TypeScript can’t “only applytypesto*.spec.ts” within a single TS program. Maintainer guidance: you basically can’t scope it that way; prefer importing fromvitestand keepingglobalsoff. (github.com)
Practical recommendations (v4-safe)
- Best isolation: keep
test.globals = false, and in each test fileimport { describe, it, expect, vi } from 'vitest'. (github.com) - If you must use globals, use a separate TS project/tsconfig for tests (so app code isn’t compiled with
vitest/globals). (This is the standard workaround implied by the TS limitation noted above.) (github.com)
Citations:
- 1: https://vitest.dev/config/globals
- 2: https://vitest.dev/guide/migration
- 3: https://vitest.dev/guide/migration
- 4: https://vitest.dev/config/globals
- 5: https://vitest.dev/config/globals
- 6: How to add `"types": ["vitest/globals"]` only for test `**/*.spec.ts` files vitest-dev/vitest#5086
- 7: How to add `"types": ["vitest/globals"]` only for test `**/*.spec.ts` files vitest-dev/vitest#5086
- 8: How to add `"types": ["vitest/globals"]` only for test `**/*.spec.ts` files vitest-dev/vitest#5086
🏁 Script executed:
#!/bin/bash
# Check package.json for Node.js and Vite versions
echo "=== package.json versions ==="
cat package.json | grep -E '"(node|vite|engines)"' -A 2
# Check for vitest/vite config files
echo -e "\n=== Config files present ==="
ls -la | grep -E '(vitest|vite)\.config'
# Check tsconfig.json for types configuration
echo -e "\n=== tsconfig.json content ==="
if [ -f tsconfig.json ]; then
cat tsconfig.json
fi
# Check test files for test-options patterns (3rd argument usage)
echo -e "\n=== Test file patterns (3rd argument in test/describe) ==="
rg -n "describe\s*\([^)]+,\s*[^)]+,\s*\{" --type js --type ts || echo "No 3rd-arg pattern found"
rg -n "it\s*\([^)]+,\s*[^)]+,\s*\{" --type js --type ts || echo "No 3rd-arg pattern found"Repository: lokalise/npm-package-template
Length of output: 803
🏁 Script executed:
#!/bin/bash
# Check vite.config.ts content
echo "=== vite.config.ts content ==="
cat vite.config.ts
# Check if any test files import `@types/node` or use Node types
echo -e "\n=== Node types usage in test files ==="
rg "import.*node" src/index.test.ts || echo "No explicit node imports in test file"
cat src/index.test.ts | head -20Repository: lokalise/npm-package-template
Length of output: 659
Update Vite to version 6 or higher before merging.
Vitest v4 requires Vite ≥ 6, but package.json specifies "vite": "^5.4.11". This incompatibility will prevent the project from running. Update the vite dependency to at least v6 (e.g., "vite": "^6.0.0").
The project's Node.js version (≥20), vitest/globals TypeScript configuration, and test files are already compatible with Vitest v4.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@package.json` at line 44, Update the Vite dependency in package.json to a
version compatible with Vitest v4 by changing the "vite" entry (currently
"vite": "^5.4.11") to at least v6 (for example "vite": "^6.0.0"), then run
dependency install and verify tests; ensure the package.json "vite" field is the
only change and update lockfile accordingly.
Bumps vitest from 3.2.4 to 4.1.4.
Release notes
Sourced from vitest's releases.
... (truncated)
Commits
ac04bacchore: release v4.1.482c858dchore: Remove no-op function in plugin config logic (#8501)d4fbb5cfeat(experimental): support aria snapshot (#9668)b77de96feat(reporter): add filterMeta option to json reporter (#10078)a120e3afeat(experimental): exposeassertionas a public field (#10095)5375780feat(coverage): default to text reporterskipFullif agent detected (#10018)a1b5f0ffix: makeexpect(..., message)consistent as error message prefix (#10068)203f07afix: use "black" foreground for labeled terminal message to ensure contrast (...2dc0d62chore: release v4.1.37827363feat: addexperimental.preParseflag (#10070)Maintainer changes
This version was pushed to npm by [GitHub Actions](https://www.npmjs.com/~GitHub Actions), a new releaser for vitest since your current version.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)