-
Notifications
You must be signed in to change notification settings - Fork 112
Migrating from nuxt-vitest #644
Description
If you previously used nuxt-vitest, we have now merged it into @nuxt/test-utils, as well as implementing a range of fixes. Here are the required steps:
-
Uninstall
nuxt-vitest, update yourvitestversions to v1, and update@nuxt/test-utilsandvitest-environment-nuxtto the alpha versions:"devDependencies": { - "@nuxt/test-utils": "^3.8.1", + "@nuxt/test-utils": "^3.9.0-alpha.1", - "@vitest/coverage-v8": "0.33.0", + "@vitest/coverage-v8": "^1.0.4", "@vue/test-utils": "^2.4.3", - "nuxt-vitest": "^0.11.5", - "vitest": "^0.33.0", + "vitest": "^1.0.4", + "vitest-environment-nuxt": "^1.0.0-alpha.1" }, -
Update your
nuxt.configif you have added thenuxt-vitestmodule to it:export default defineNuxtConfig({ modules: [ - 'nuxt-vitest' + '@nuxt/test-utils/module' ] }) -
Update any imports from
nuxt-vitestandvitest-environment-nuxt:- import { mountSuspended } from 'nuxt-vitest/utils' // or 'vitest-environment-nuxt/utils' + import { mountSuspended } from '@nuxt/test-utils/runtime' - import { defineVitestConfig } from 'vitest-environment-nuxt/config' // or 'nuxt-vitest/config' + import { defineVitestConfig } from '@nuxt/test-utils/config' - import { setup, $fetch } from '@nuxt/test-utils' + import { setup, $fetch } from '@nuxt/test-utils/e2e'
-
Ensure vitest is running in a module context (either by checking you have
type: 'module'set in yourpackage.json, or by renaming yourvitest.configfile tovitest.config.mtsorvitest.config.mjs.
If you encounter any problems with this upgrade path, please let us know by raising an issue. 🙏
📖 You can read more in this draft documentation: nuxt/nuxt#24658.