Skip to content

Conversation

@danielroe
Copy link
Member

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@2110

commit: c3d6504

@cloudflare-workers-and-pages
Copy link

Deploying nuxt-image with Β Cloudflare Pages Β Cloudflare Pages

Latest commit: c3d6504
Status:Β βœ…Β  Deploy successful!
Preview URL: https://0910c007.nuxt-image.pages.dev
Branch Preview URL: https://chore-vitest.nuxt-image.pages.dev

View logs

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

πŸ“ Walkthrough

Walkthrough

This change adds a new .nuxtrc configuration file with a single test utilities version setting and updates three test-related dependencies in package.json. Specifically, @nuxt/test-utils is upgraded from ^3.23.0 to ^4.0.0, while @vitest/coverage-v8 and vitest are both upgraded from ^3.2.4 to ^4.0.18. No functional code, runtime logic, or public API declarations are modified.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is a template with no substantive content provided by the author, containing only unchecked checkboxes and contributor reminders unrelated to the changeset. Provide a meaningful description explaining the purpose of the dependency upgrades, any breaking changes, and rationale for the version bumps.
βœ… Passed checks (2 passed)
Check name Status Explanation
Title check βœ… Passed The title 'chore(deps): upgrade vitest + nuxt/test-utils' directly summarizes the main change: upgrading vitest and @nuxt/test-utils dependencies.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/vitest

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

πŸ€– Fix all issues with AI agents
In `@package.json`:
- Line 63: The dependency bump to "@nuxt/test-utils" v4 introduces breaking
changes that will break tests; update package.json and test code: upgrade Vitest
to v4 and any test runners, move top-level Nuxt composable calls (useRouter,
useRoute, useNuxtApp, etc.) into beforeAll/beforeEach hooks in your test files,
revise vi.mock() factories to explicitly return all required exports or use
importOriginal() to avoid unused-export errors, and adjust peer dependencies
(happy-dom/jsdom/@jest/globals/@cucumber/cucumber/@testing-library/vue) and any
Vitest v4-specific config (module runner/coverage) accordingly so tests run
under the new v4 contracts.
- Line 87: Remove the explicit dependency "vitest-environment-nuxt" from
package.json (delete the line listing "vitest-environment-nuxt": "^1.0.1") since
it is transitively provided by `@nuxt/test-utils` v4; after removal, run your
package manager's install command (npm install / yarn install / pnpm install) to
update the lockfile and ensure no direct references remain, and then run the
test suite (or `defineVitestProject()`-based setup) to confirm the Nuxt Vitest
environment still loads via `@nuxt/test-utils`.

"@nuxt/module-builder": "1.0.2",
"@nuxt/schema": "4.3.0",
"@nuxt/test-utils": "^3.23.0",
"@nuxt/test-utils": "^4.0.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

🧩 Analysis chain

🌐 Web query:

@nuxt/test-utils v4 breaking changes migration guide

πŸ’‘ Result:

@nuxt/test-utils v4 (v4.0.0) breaking changes + migration checklist

1) Upgrade required deps (Vitest v4)

Update @nuxt/test-utils, vitest, and coverage packages together (v4 now requires Vitest v4). [1]

devDependencies: {
- "@nuxt/test-utils": "^3.x",
- "vitest": "^3.x",
- "@vitest/coverage-v8": "^3.x"
+ "@nuxt/test-utils": "^4.0",
+ "vitest": "^4.0",
+ "@vitest/coverage-v8": "^4.0"
}

Also note tightened peer ranges (examples from the v4 release notes): happy-dom >=20.0.11, jsdom >=27.4.0, @jest/globals >=30.0.0, @cucumber/cucumber >=11.0.0, @testing-library/vue ^8.0.1. [1]

2) Nuxt test environment now starts in beforeAll (top-level composables will break)

Nuxt initialization moved from setupFiles to a beforeAll hook. If you call Nuxt composables at the top level inside a describe block, you’ll now hit [nuxt] instance unavailable. Move those calls into beforeAll / beforeEach / the test body. [1]

Example:

describe('my test', () => {
  let router: ReturnType<typeof useRouter>

  beforeAll(() => {
    router = useRouter()
  })

  // tests...
})

Applies to useRouter(), useRoute(), useNuxtApp(), and other Nuxt auto-imports/composables. [1]

3) Stricter vi.mock factory behavior (missing exports now throw)

If you use vi.mock('...', () => ({ ... })), accessing any export you didn’t return will now throw (instead of returning undefined). Fix by spreading importOriginal() (when possible) or explicitly returning every used export. [1]

vi.mock('./module', async (importOriginal) => ({
  ...(await importOriginal()),
  foo: 'mocked',
}))

4) Vitest v4 changes you may need to account for

Nuxt Test Utils v4 switches to Vite’s native Module Runner (Vitest v4 replaced vite-node), and Vitest v4 also includes config/behavior changes (coverage defaults/options, exclude behavior, etc.). Review Vitest’s v4 migration guide for anything your setup relies on. [1][2]

Sources: Nuxt Test Utils v4.0.0 release notes/migration notes [1]; Vitest Migration Guide (Vitest 4) [2].


@nuxt/test-utils v4 has breaking changes β€” verify and refactor tests accordingly.

Upgrading to v4 requires Vitest v4 and introduces breaking changes that will affect existing tests:

  • Top-level Nuxt composables (useRouter(), useRoute(), useNuxtApp(), etc.) must move into beforeAll/beforeEach hooks; they will throw "instance unavailable" at the top level.
  • vi.mock() factories are stricter β€” any unused exported property will throw instead of returning undefined; use importOriginal() or explicitly return all required exports.
  • Vitest v4 changes (Module Runner instead of vite-node, coverage defaults) may require adjustments to your test setup.
  • Peer dependencies have tightened for happy-dom, jsdom, @jest/globals, @cucumber/cucumber, and @testing-library/vue.
πŸ€– Prompt for AI Agents
In `@package.json` at line 63, The dependency bump to "@nuxt/test-utils" v4
introduces breaking changes that will break tests; update package.json and test
code: upgrade Vitest to v4 and any test runners, move top-level Nuxt composable
calls (useRouter, useRoute, useNuxtApp, etc.) into beforeAll/beforeEach hooks in
your test files, revise vi.mock() factories to explicitly return all required
exports or use importOriginal() to avoid unused-export errors, and adjust peer
dependencies
(happy-dom/jsdom/@jest/globals/@cucumber/cucumber/@testing-library/vue) and any
Vitest v4-specific config (module runner/coverage) accordingly so tests run
under the new v4 contracts.

"unbuild": "^3.6.1",
"vitest": "^3.2.4",
"vitest": "^4.0.18",
"vitest-environment-nuxt": "^1.0.1",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if vitest-environment-nuxt is actually used in test configs or test files
rg -n "vitest-environment-nuxt" --type-add 'config:*.config.*' -g '!node_modules' -g '!package.json' -g '!pnpm-lock.yaml' -g '!.lockfile'

Repository: nuxt/image

Length of output: 100


🏁 Script executed:

# Also check for references to "vitest-environment-nuxt" in config files more broadly
rg -n "vitest-environment-nuxt" . -g '!node_modules' -g '!package.json' -g '!pnpm-lock.yaml' -g '!.lockfile' 2>/dev/null | head -30

Repository: nuxt/image

Length of output: 102


🏁 Script executed:

# Check the current Vitest and `@nuxt/test-utils` versions in package.json
grep -n -E "(vitest|@nuxt/test-utils|vitest-environment-nuxt)" package.json

Repository: nuxt/image

Length of output: 275


🏁 Script executed:

# Look for vitest configuration in common config file locations
cat vitest.config.ts vitest.config.js vitest.config.mts nuxt.config.ts 2>/dev/null | head -100

Repository: nuxt/image

Length of output: 966


🏁 Script executed:

# Check knip.json to see why vitest-environment-nuxt is listed
cat knip.json | head -30

Repository: nuxt/image

Length of output: 805


🏁 Script executed:

# Check if there's any environment specification in the test project config
cat vitest.config.ts | grep -i "environment" -A 2 -B 2

Repository: nuxt/image

Length of output: 102


🏁 Script executed:

# Check `@nuxt/test-utils` package info to see if it bundles the environment
grep -A 5 -B 5 "environment" package.json

Repository: nuxt/image

Length of output: 324


🏁 Script executed:

# Search for any environment references in test files
rg "environment" test/ --type ts 2>/dev/null | head -20

Repository: nuxt/image

Length of output: 36


🏁 Script executed:

# Find the actual vitest config file
find . -name "vitest.config.*" -o -name "vitest.config.*" 2>/dev/null

Repository: nuxt/image

Length of output: 73


🏁 Script executed:

# Check if the config shown earlier is embedded in nuxt.config or build.config
find . -name "nuxt.config.*" -o -name "build.config.*" 2>/dev/null | xargs grep -l "defineVitestProject" 2>/dev/null

Repository: nuxt/image

Length of output: 38


🏁 Script executed:

# Let's search for where defineVitestProject is used
rg "defineVitestProject" -t ts -t js 2>/dev/null

Repository: nuxt/image

Length of output: 36


🏁 Script executed:

# Check the knip.json more completely to understand the ignoreDependencies setting
cat knip.json

Repository: nuxt/image

Length of output: 1356


🏁 Script executed:

# Read the vitest.config.mts file to see the full config
cat vitest.config.mts

Repository: nuxt/image

Length of output: 966


🏁 Script executed:

# Check if `@nuxt/test-utils` provides a built-in environment
rg "environment" --type ts --type js -g '!node_modules' 2>/dev/null | grep -i nuxt

Repository: nuxt/image

Length of output: 36


🏁 Script executed:

# Check what `@nuxt/test-utils` declares as dependencies in its package.json
npm view `@nuxt/test-utils`@4.0.0 dependencies 2>/dev/null | head -50

Repository: nuxt/image

Length of output: 771


🏁 Script executed:

# Check if vitest-environment-nuxt is mentioned in `@nuxt/test-utils` peer dependencies
npm view `@nuxt/test-utils`@4.0.0 peerDependencies 2>/dev/null

Repository: nuxt/image

Length of output: 324


🏁 Script executed:

# Check Vitest v4 changelog or docs for environment changes
web_search
Vitest v4 environment API changes from v3

Repository: nuxt/image

Length of output: 149


🌐 Web query:

@nuxt/test-utils v4 vitest-environment-nuxt

πŸ’‘ Result:

With @nuxt/test-utils v4, you generally do not need the separate vitest-environment-nuxt packageβ€”Nuxt’s Vitest environment is provided via @nuxt/test-utils/config, and you enable it with environment: 'nuxt'. [1][2]

Recommended (Vitest projects) setup

// vitest.config.ts
import { defineConfig } from 'vitest/config'
import { defineVitestProject } from '@nuxt/test-utils/config'

export default defineConfig({
  test: {
    projects: [
      {
        test: { name: 'unit', environment: 'node' },
      },
      await defineVitestProject({
        test: { name: 'nuxt', environment: 'nuxt' },
      }),
    ],
  },
})

[2]

Simple setup (all tests in Nuxt environment)

// vitest.config.ts
import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
  test: {
    environment: 'nuxt',
  },
})

[2]

Per-file opt-in (or opt-out)

// `@vitest-environment` nuxt

and if you set environment: 'nuxt' globally, you can opt out with:

// `@vitest-environment` node

[1][2]

Where vitest-environment-nuxt fits

vitest-environment-nuxt is associated with the older nuxt-vitest setup (its docs show defineVitestConfig coming from nuxt-vitest/config). If you’re on @nuxt/test-utils v4, prefer the Nuxt docs configuration above. [3]

Sources: Nuxt testing docs and npm package pages. [1][2][3]


Remove vitest-environment-nuxt from package.jsonβ€”it's a transitive dependency of @nuxt/test-utils v4 and already flagged as ignored.

vitest-environment-nuxt is included as a dependency of @nuxt/test-utils v4 and does not need explicit listing in package.json. The knip.json config already marks it under ignoreDependencies, confirming it's not directly used. Removing it will clean up the dependency tree without affecting functionality, as the Nuxt environment is provided through @nuxt/test-utils/config's defineVitestProject().

πŸ€– Prompt for AI Agents
In `@package.json` at line 87, Remove the explicit dependency
"vitest-environment-nuxt" from package.json (delete the line listing
"vitest-environment-nuxt": "^1.0.1") since it is transitively provided by
`@nuxt/test-utils` v4; after removal, run your package manager's install command
(npm install / yarn install / pnpm install) to update the lockfile and ensure no
direct references remain, and then run the test suite (or
`defineVitestProject()`-based setup) to confirm the Nuxt Vitest environment
still loads via `@nuxt/test-utils`.

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.

1 participant