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 | โฐ๏ธ |