Skip to content

johnsoncodehk/test-utils

This branch is 18 commits ahead of, 399 commits behind vuejs/test-utils:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f2be9d5 Β· Apr 11, 2023
Apr 9, 2023
Jul 4, 2022
Apr 9, 2023
Mar 26, 2022
Apr 11, 2023
Apr 11, 2023
Apr 10, 2023
Apr 9, 2023
Feb 15, 2021
Apr 8, 2022
Jul 5, 2022
Mar 26, 2020
Mar 6, 2021
Mar 9, 2023
Jan 21, 2021
Apr 9, 2023
Apr 9, 2023
Feb 19, 2023
Jul 4, 2022
Jul 27, 2022
Dec 24, 2021
Oct 20, 2022

Repository files navigation

Vue Test Utils

Component testing utils for Vue 3.

Languages

πŸ‡«πŸ‡· French version of this README.md

Installation and Usage

  • yarn: yarn add @vue/test-utils --dev
  • npm: npm install @vue/test-utils --save-dev

Get started with the documentation.

Coming from Vue 2 + Test Utils v1?

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.

Documentation

See the docs.

Development

Get started by running pnpm install. You can run the tests with pnpm test. That's it!

Comparison with Vue Test Utils v1 (targeting Vue 2)

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)

Mounting Options

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 ⚰️

Wrapper API (mount)

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 ⚰️

About

Vue Test Utils for Vue 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 95.9%
  • Vue 3.7%
  • JavaScript 0.4%