Component testing utils for Vue 3.
π«π· French version of this README.md
- yarn:
yarn add @vue/test-utils --dev
- npm:
npm install @vue/test-utils --save-dev
Get started with the documentation.
Check the migration guide. It's still a work in progress. If you find a problem or something that doesn't work that previously did in Vue Test Utils v1, please open an issue.
See the docs.
Get started by running pnpm install
. You can run the tests with pnpm test
. That's it!
This is table for those coming from VTU 1, comparing the two APIs. Some things are still a work in progress.
- β - implemented
- β - not yet implemented
- β°οΈ - will not be implemented (if you have a compelling use case, please open an issue)
option | status | notes |
---|---|---|
data | β | |
slots | β | |
mocks | β | nested in global |
propsData | β | now called props |
provide | β | nested in global |
mixins | β | (new!) nested in global |
plugins | β | (new!) nested in global |
component | β | (new!) nested in global |
directives | β | (new!) nested in global |
stubs | β | |
attachToDocument | β | renamed attachTo . See here |
attrs | β | |
scopedSlots | β°οΈ | scopedSlots are merged with slots in Vue 3 |
context | β°οΈ | different from Vue 2, does not make sense anymore. |
localVue | β°οΈ | no longer required - Vue 3 there is no global Vue instance to mutate. |
listeners | β°οΈ | no longer exists in Vue 3 |
parentComponent | β°οΈ |
method | status | notes |
---|---|---|
attributes | β | |
classes | β | |
exists | β | |
find | β | only querySelector syntax is supported. find(Comp) under discussion here |
emitted | β | |
findAll | β | see above. .vm is different to Vue 2. We are exploring options. |
get | β | |
html | β | |
setValue | β | works for select, checkbox, radio button, input, textarea. Returns nextTick . |
text | β | |
trigger | β | returns nextTick . You can do await wrapper.find('button').trigger('click') |
setProps | β | |
props | β | |
setData | β | |
destroy | β | renamed to unmount to match Vue 3 lifecycle hook name. |
props | β | |
isVisible | β | |
contains | β°οΈ | use find |
emittedByOrder | β°οΈ | use emitted |
setSelected | β°οΈ | now part of setValue |
setChecked | β°οΈ | now part of setValue |
is | β°οΈ | |
isEmpty | β°οΈ | use matchers such as this |
isVueInstance | β°οΈ | |
name | β°οΈ | |
setMethods | β°οΈ |