Code Monkey home page Code Monkey logo

test-utils's Introduction

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

test-utils's People

Contributors

dependabot[bot] avatar lmiller1990 avatar cexbrayat avatar renovate[bot] avatar dependabot-preview[bot] avatar dobromir-hristov avatar xanf avatar afontcu avatar pikax avatar freakzlike avatar nandi95 avatar cuixiaorui avatar jessicasachs avatar snoozbuster avatar posva avatar jokcy avatar wdpm avatar shivams906 avatar yutamakotaro avatar renatodeleao avatar marina-mosti avatar likui628 avatar jw-foss avatar herringtondarkholme avatar sodatea avatar yyx990803 avatar dominicgbauer avatar scvnc avatar thomasan1999 avatar okxiaoliang4 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.