The Wayback Machine - https://web.archive.org/web/20200420210414/https://github.com/vuejs/vue-test-utils-next
Skip to content
The next iteration of Vue Test Utils, targeting Vue 3
TypeScript Vue JavaScript
Branch: master
Clone or download

Latest commit

dobromir-hristov and lmiller1990 feat: Add global configuration settings (#53)
* feat: add globalProperties to mountingOptions

* refactor: move globalProperties to global property

* feat: add global config

* refactor: update types and fix broken tests

* refactor: update rollup build

* tests: add mocks tests

* fix: fix missing type

* chore: remove globalProperties

* chore: remove left over stubs

* chore: merge conflicts

Co-authored-by: Lachlan Miller <[email protected]>
Latest commit 66d4d44 Apr 20, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows chore: add tsd tests for typings Apr 17, 2020
docs fix: findComponent in docs Apr 19, 2020
examples chore: do not run example test by default Apr 8, 2020
src feat: Add global configuration settings (#53) Apr 20, 2020
test-dts feat: properly type mount Apr 19, 2020
tests feat: Add global configuration settings (#53) Apr 20, 2020
.gitignore Ignore coverage folder Mar 31, 2020
.prettierrc build: add add prettier and linting on commit Mar 26, 2020
README.md Merge branch 'master' into feat/unmount Apr 18, 2020
babel.config.js init commit with WIP from vue-testing-framework repo Feb 20, 2020
jest.config.js chore: bump deps and use vue-jest Mar 28, 2020
package.json chore: beta 2 Apr 18, 2020
rollup.config.js feat: Add global configuration settings (#53) Apr 20, 2020
setup.js init commit with WIP from vue-testing-framework repo Feb 20, 2020
tsconfig.json wip: work on build with rollup Feb 23, 2020
yarn.lock Merge branch 'master' into feat/find-by-component Apr 18, 2020

README.md

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

Coming from Vue 2 + Vue Test Utils beta?

We are working on some documentation to help people migrate. At this point it will 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.

Docs

Docs are located in this repo. Read them here. They are in a separate repository because running Vuepress alongside a repo with Vue 3 causes conflicts - Vuepress expects to be running against Vue 2. This seems like the most simple solution for now.

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 a lot of work to do. See issues for some basic TODOs, or the table at the bottom of this page.

What works?

See the docs. Most basic DOM interactions work. Advanced features like shallowMount and stubs are a work in progress.

Contributing

This is still very much alpha - 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.

Comparsion with Vue Test Utils beta (targeting Vue 2)

This is table for those coming from VTU beta, comparing the two APIs. A lot of 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)

  • Q: Where is shallowMount?

  • A: Coming soon. There is an issue and a PR open.

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 will rename to attachTo. See here
attrs
scopedSlots ⚰️ scopedSlots are merged with slots in Vue 3
context ⚰️ different from Vue 2, may 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 has PR
destroy renamed to unmount to match Vue 3 lifecycle hook name.
props
contains ⚰️ use find
emittedByOrder ⚰️ use emitted
setSelected ⚰️ now part of setValue
setChecked ⚰️ now part of setValue
is ⚰️
isEmpty ⚰️ use matchers such as this
isVisible ⚰️ use matchers such as this
isVueInstance ⚰️
name ⚰️
setMethods ⚰️
You can’t perform that action at this time.