Vue test utils skilld

From skilld-dev/vue-ecosystem-skills · View interactive version

Vue test utils skilld is an AI agent skill from the GitHub repository skilld-dev/vue-ecosystem-skills. ALWAYS use when writing, debugging, or reviewing code that imports "@vue/test-utils" or mentions vue test-utils, VTU, mount, shallowMount, findComponent, wrapper queries, or migrating from Vue Test Utils v1. Provides the current API surface, mounting options, wrapper methods, and testing recipes for

How to use this skill

Skill file

@vue/test-utils 2.5.1 (Vue 3)

Prepared source: input/source, version 2.5.1 (package.json:3).

Requires Vue 3.x and @vue/compiler-dom 3.x as peers; @vue/server-renderer 3.x is an optional peer needed only for renderToString (package.json:73-81).

Test-runner agnostic (Vitest, Jest, others). Needs a browser-like DOM environment (jsdom or happy-dom).

Install: npm install @vue/test-utils --save-dev

Quick start

import { mount } from '@vue/test-utils'
import Counter from './Counter.vue'

test('increments', async () => {
  const wrapper = mount(Counter, { props: { start: 1 } })
  await wrapper.find('button').trigger('click')
  expect(wrapper.text()).toContain('2')
})

Public API surface

Exports from dist/src/index.d.ts:13:

| Export | Kind | Use |

|---|---|---|

| mount | function | Mount a component, returns VueWrapper (dist/src/mount.d.ts:17) |

| shallowMount | function | Same as mount with all child components stubbed (dist/src/mount.d.ts:22) |

| renderToString | function | SSR-render a component to a string, Promise<string> (dist/src/renderToString.d.ts:4) |

| flushPromises | function | Await pending non-Vue promises (mocked API calls, timers) (dist/src/utils/flushPromises.d.ts:1) |

| enableAutoUnmount(hook) | function | Unmount all wrappers via a test hook (dist/src/utils/autoUnmount.d.ts:4) |

| disableAutoUnmount | function | Stop auto unmounting (dist/src/utils/autoUnmount.d.ts:3) |

| VueWrapper | class | Wrapper around a mounted component instance (dist/src/vueWrapper.d.ts:5) |

| DOMWrapper | class | Wrapper around a DOM element; new DOMWrapper(document.body) (dist/src/domWrapper.d.ts:4) |

| RouterLinkStub | component | Stub for <router-link> (dist/src/components/RouterLinkStub.d.ts:1) |

| config | object | Shared default mount options and wrapper plugins (dist/src/config.d.ts:32) |

| createWrapperError | function | Internal; produces the error wrapper returned by find misses |

Core rules

import { enableAutoUnmount } from '@vue/test-utils'
import { afterEach } from 'vitest'

enableAutoUnmount(afterEach)

Version notes: 2.4.10 -> 2.5.1

Earlier v2 milestones still relevant

Migrating from v1 (Vue 2)

Full table: migration reference, official guide https://test-utils.vuejs.org/migration/

Best practices

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.