Skip to content

Migrate from @nuxt/test-utils

Clean break, not a drop-in. Keep Vitest/Playwright; change how apps are prepared and shared. Why shared prepare matters: Why.

Cheat sheet

@nuxt/test-utilsuntestutils
setup({ rootDir, browser })await useHarness('id') with nuxt({ root, run: 'server' })
createPage / $fetchFixtures page / goto / $fetch on harness
Playwright test.use({ nuxt })test.use({ harness: 'id' }) + shared recipes.ts
Per-file rebuildShared prepare → .untestutils/builds

Keep e2e (untestutils/vitest/plugin) and Nuxt unit (environment: 'untestutils') in separate Vitest projects.

After (e2e)

ts
// recipes.ts
import { defineRecipes } from 'untestutils'
import { nuxt } from 'untestutils/nuxt'
import { resolve } from 'node:path'

export const recipes = defineRecipes({
  basic: nuxt({ id: 'basic', root: resolve('./fixtures/basic'), run: 'server' }),
}, import.meta.url)
ts
import { describe, test, expect, useHarness } from 'untestutils/vitest'

describe('home', () => {
  test('html', async () => {
    const app = await useHarness('basic')
    expect(await app.$fetch('/')).toContain('Hello')
  })
})

Next

Released under the MIT License.