Coder Social home page Coder Social logo

isabella232 / vue-test-utils-next Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vuejs/test-utils

0.0 0.0 0.0 3.13 MB

The next iteration of Vue Test Utils, targeting Vue 3

Home Page: https://next.vue-test-utils.vuejs.org

License: MIT License

JavaScript 1.44% TypeScript 95.39% Vue 3.17%

vue-test-utils-next's Introduction

vue-test-utils-next

The next iteration of Vue Test Utils. It targets Vue 3.

Installation and Usage

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

Get started with the documentation.

Coming from Vue 2 + Vue Test Utils?

We plan on work on some documentation to help people migrate.

At this point you will have better luck trying this out with a brand new Vue 3 app, as opposed to upgrading an existing Vue 2 app. Feedback and bug reports are welcome!

Working with .vue files

There is vue-jest for loading .vue files into Jest. The next branch contains support for Vue 3. Install it with yarn add vue-jest@next. It lacks support for some things, namely JSX.

If you don't want to configure things, you can download a repository with Vue 3, @vue/test-utils@next, vue-jest@next and TypeScript configured here.

Documentation

See the docs.

Development

It's a pretty small codebase at the moment. Get started by running yarn install. You can run the tests with yarn test. That's it!

There is still some work left to do. See issues for some basic TODOs, or the table at the bottom of this page.

Contributing

We plan on moving to RC sooner than later. If you want to add a feature, have a hack or ping someone in Discord to chat, or check out the issues and project board.

There's also some work left to do in docs.

Comparison with Vue Test Utils beta (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 has not been tested vigorously. Please try it out.
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 ⚰️ may not make sense anymore since we do not mutate the global Vue instance in Vue 3.
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 ⚰️

vue-test-utils-next's People

Contributors

aethr avatar afontcu avatar angelogulina avatar bencodezen avatar cexbrayat avatar colinscz avatar cuixiaorui avatar dependabot-preview[bot] avatar dependabot[bot] avatar dobromir-hristov avatar doz13189 avatar elevatebart avatar geekqiaqia avatar herringtondarkholme avatar jessicasachs avatar jokcy avatar jw-foss avatar linusborg avatar lmiller1990 avatar lzurbriggen avatar motao314 avatar nandi95 avatar pikax avatar posva avatar rrittwag avatar seevee avatar shixin-guo avatar sodatea avatar underfin avatar ursmetz 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.