diff --git a/.eslintrc b/.eslintrc
index dad888b1d..3bfd1f67a 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -10,11 +10,13 @@
"flowtype"
],
"extends": [
- "plugin:vue-libs/recommended",
- "plugin:flowtype/recommended"
+ "plugin:flowtype/recommended",
+ "plugin:vue-libs/recommended"
],
"rules": {
"template-curly-spacing" : "off",
+ "for-direction": "off",
+ "getter-return": "off",
"no-debugger": 2,
"no-proto": 0,
"space-before-function-paren": 0,
diff --git a/.flowconfig b/.flowconfig
index 353d5b503..fa4b44464 100644
--- a/.flowconfig
+++ b/.flowconfig
@@ -4,6 +4,3 @@
[libs]
flow
-
-[options]
-suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 072749421..5a14567ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.0.5](https://github.com/vuejs/vue-test-utils/compare/v1.0.4...v1.0.5) (2020-08-29)
+
+
+### Bug Fixes
+
+* extend Vue parent with options to support accessing root. with VCA ([#1661](https://github.com/vuejs/vue-test-utils/issues/1661)) ([f78f817](https://github.com/vuejs/vue-test-utils/commit/f78f817306e2e228319092e3d3de55fc4356aa93))
+* handle shallowMount on components with v-if and scoped slots ([#1663](https://github.com/vuejs/vue-test-utils/issues/1663)) ([41f2b2b](https://github.com/vuejs/vue-test-utils/commit/41f2b2b18cb0d557bf36a5a28cf769a02dba931f))
+
+
+
+
+
## [1.0.4](https://github.com/vuejs/vue-test-utils/compare/v1.0.3...v1.0.4) (2020-08-17)
diff --git a/babel.config.js b/babel.config.js
index e7d78a63b..5a6a6785b 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -29,8 +29,7 @@ module.exports = api => {
[
'@babel/preset-env',
{
- // currently, there are dependency resolution issues with older versions of vuepress. Once vuepress is upgraded, core-js can be moved to version 3
- corejs: 2,
+ corejs: 3,
useBuiltIns: 'entry'
}
],
diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js
index 6516b35c3..a1b99cea4 100644
--- a/docs/.vuepress/config.js
+++ b/docs/.vuepress/config.js
@@ -21,12 +21,12 @@ module.exports = {
description: 'Библиотека для тестирования Vue-компонентов'
}
},
- serviceWorker: true,
+ plugins: ['@vuepress/pwa'],
head: [
['link', { rel: 'icon', href: '/favicon.png' }],
['link', { rel: 'stylesheet', href: '/vueschool.css' }]
],
- theme: 'vue',
+ theme: '@vuepress/vue',
themeConfig: {
algolia: {
apiKey: 'ee1b8516c9e5a5be9b6c25684eafc42f',
@@ -143,10 +143,8 @@ module.exports = {
}
}
},
- markdown: {
- config: md => {
- // use more markdown-it plugins!
- md.use(require('markdown-it-include'))
- }
+ extendMarkdown: md => {
+ // use more markdown-it plugins!
+ md.use(require('markdown-it-include'))
}
}
diff --git a/docs/README.md b/docs/README.md
index b2d02340f..663952c8b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -21,11 +21,13 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
- [renderToString](api/renderToString.md)
- [Mounting Options](api/options.md)
- [context](api/options.md#context)
+ - [data](api/options.md#data)
- [slots](api/options.md#slots)
- [scopedSlots](api/options.md#scopedslots)
- [stubs](api/options.md#stubs)
- [mocks](api/options.md#mocks)
- [localVue](api/options.md#localvue)
+ - [attachTo](api/options.md#attachto)
- [attachToDocument](api/options.md#attachtodocument)
- [attrs](api/options.md#attrs)
- [propsData](api/options.md#propsdata)
@@ -37,16 +39,19 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
- [attributes](api/wrapper/attributes.md)
- [classes](api/wrapper/classes.md)
- [contains](api/wrapper/contains.md)
+ - [destroy](api/wrapper/destroy.md)
- [emitted](api/wrapper/emitted.md)
- [emittedByOrder](api/wrapper/emittedByOrder.md)
- [exists](api/wrapper/exists.md)
- - [destroy](api/wrapper/destroy.md)
- [find](api/wrapper/find.md)
- [findAll](api/wrapper/findAll.md)
+ - [findAllComponents](api/wrapper/findAllComponents.md)
+ - [findComponent](api/wrapper/findComponent.md)
- [get](api/wrapper/get.md)
- [html](api/wrapper/html.md)
- [is](api/wrapper/is.md)
- [isEmpty](api/wrapper/isEmpty.md)
+ - [isVisible](api/wrapper/isVisible.md)
- [isVueInstance](api/wrapper/isVueInstance.md)
- [name](api/wrapper/name.md)
- [props](api/wrapper/props.md)
@@ -58,15 +63,14 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
- [setValue](api/wrapper/setValue.md)
- [text](api/wrapper/text.md)
- [trigger](api/wrapper/trigger.md)
- - [isVisible](api/wrapper/isVisible.md)
- [WrapperArray](api/wrapper-array/)
- [at](api/wrapper-array/at.md)
- [contains](api/wrapper-array/contains.md)
- - [exists](api/wrapper/exists.md)
- [destroy](api/wrapper-array/destroy.md)
- [filter](api/wrapper-array/filter.md)
- [is](api/wrapper-array/is.md)
- [isEmpty](api/wrapper-array/isEmpty.md)
+ - [isVisible](api/wrapper-array/isVisible.md)
- [isVueInstance](api/wrapper-array/isVueInstance.md)
- [setChecked](api/wrapper-array/setChecked.md)
- [setData](api/wrapper-array/setData.md)
@@ -74,7 +78,6 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
- [setProps](api/wrapper-array/setProps.md)
- [setValue](api/wrapper-array/setValue.md)
- [trigger](api/wrapper-array/trigger.md)
- - [isVisible](api/wrapper-array/isVisible.md)
- [components](api/components/)
- [RouterLinkStub](api/components/RouterLinkStub.md)
- [Selectors](api/selectors.md)
diff --git a/docs/api/wrapper-array/setChecked.md b/docs/api/wrapper-array/setChecked.md
index e59784c89..b8afcdef5 100644
--- a/docs/api/wrapper-array/setChecked.md
+++ b/docs/api/wrapper-array/setChecked.md
@@ -15,25 +15,27 @@ wrapperArray.wrappers.forEach(wrapper => wrapper.setChecked(checked))
```js
import { mount } from '@vue/test-utils'
-const wrapper = mount({
- data() {
- return {
- t1: false,
- t2: ''
- }
- },
- template: `
-
-
-
-
-
`
+test('setChecked demo', async () => {
+ const wrapper = mount({
+ data() {
+ return {
+ t1: false,
+ t2: ''
+ }
+ },
+ template: `
+
+
+
+
+
`
+ })
+
+ const wrapperArray = wrapper.findAll('.foo')
+ expect(wrapper.vm.t1).toEqual(false)
+ expect(wrapper.vm.t2).toEqual('')
+ await wrapperArray.setChecked()
+ expect(wrapper.vm.t1).toEqual(true)
+ expect(wrapper.vm.t2).toEqual('foo')
})
-
-const wrapperArray = wrapper.findAll('.foo')
-expect(wrapper.vm.t1).toEqual(false)
-expect(wrapper.vm.t2).toEqual('')
-wrapperArray.setChecked()
-expect(wrapper.vm.t1).toEqual(true)
-expect(wrapper.vm.t2).toEqual('foo')
```
diff --git a/docs/api/wrapper-array/setData.md b/docs/api/wrapper-array/setData.md
index d59bb102b..49895cd12 100644
--- a/docs/api/wrapper-array/setData.md
+++ b/docs/api/wrapper-array/setData.md
@@ -15,8 +15,10 @@ import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
import Bar from './Bar.vue'
-const wrapper = mount(Foo)
-const barArray = wrapper.findAll(Bar)
-barArray.setData({ foo: 'bar' })
-expect(barArray.at(0).vm.foo).toBe('bar')
+test('setData demo', async () => {
+ const wrapper = mount(Foo)
+ const barArray = wrapper.findAll(Bar)
+ await barArray.setData({ foo: 'bar' })
+ expect(barArray.at(0).vm.foo).toBe('bar')
+})
```
diff --git a/docs/api/wrapper-array/setProps.md b/docs/api/wrapper-array/setProps.md
index eb99f4601..85c22e7db 100644
--- a/docs/api/wrapper-array/setProps.md
+++ b/docs/api/wrapper-array/setProps.md
@@ -15,8 +15,10 @@ import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
import Bar from './Bar.vue'
-const wrapper = mount(Foo)
-const barArray = wrapper.findAll(Bar)
-barArray.setProps({ foo: 'bar' })
-expect(barArray.at(0).vm.foo).toBe('bar')
+test('setProps demo', async () => {
+ const wrapper = mount(Foo)
+ const barArray = wrapper.findAll(Bar)
+ await barArray.setProps({ foo: 'bar' })
+ expect(barArray.at(0).vm.foo).toBe('bar')
+})
```
diff --git a/docs/api/wrapper-array/setValue.md b/docs/api/wrapper-array/setValue.md
index 1a50d0f38..e21cbac0e 100644
--- a/docs/api/wrapper-array/setValue.md
+++ b/docs/api/wrapper-array/setValue.md
@@ -29,10 +29,12 @@ const wrapper = mount({
`
})
-const wrapperArray = wrapper.findAll('.foo')
-expect(wrapper.vm.t1).toEqual('')
-expect(wrapper.vm.t2).toEqual('')
-wrapperArray.setValue('foo')
-expect(wrapper.vm.t1).toEqual('foo')
-expect(wrapper.vm.t2).toEqual('foo')
+test('setValue demo', async () => {
+ const wrapperArray = wrapper.findAll('.foo')
+ expect(wrapper.vm.t1).toEqual('')
+ expect(wrapper.vm.t2).toEqual('')
+ await wrapperArray.setValue('foo')
+ expect(wrapper.vm.t1).toEqual('foo')
+ expect(wrapper.vm.t2).toEqual('foo')
+})
```
diff --git a/docs/api/wrapper-array/trigger.md b/docs/api/wrapper-array/trigger.md
index 167d258eb..010997057 100644
--- a/docs/api/wrapper-array/trigger.md
+++ b/docs/api/wrapper-array/trigger.md
@@ -16,12 +16,14 @@ import { mount } from '@vue/test-utils'
import sinon from 'sinon'
import Foo from './Foo.vue'
-const clickHandler = sinon.stub()
-const wrapper = mount(Foo, {
- propsData: { clickHandler }
+test('trigger demo', async () => {
+ const clickHandler = sinon.stub()
+ const wrapper = mount(Foo, {
+ propsData: { clickHandler }
+ })
+
+ const divArray = wrapper.findAll('div')
+ await divArray.trigger('click')
+ expect(clickHandler.called).toBe(true)
})
-
-const divArray = wrapper.findAll('div')
-divArray.trigger('click')
-expect(clickHandler.called).toBe(true)
```
diff --git a/docs/api/wrapper/setChecked.md b/docs/api/wrapper/setChecked.md
index f0b49c0b7..64d0d1738 100644
--- a/docs/api/wrapper/setChecked.md
+++ b/docs/api/wrapper/setChecked.md
@@ -12,9 +12,14 @@ Sets checked value for input element of type checkbox or radio and updates `v-mo
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
-const wrapper = mount(Foo)
-const radioInput = wrapper.find('input[type="radio"]')
-radioInput.setChecked()
+test('setChecked demo', async () => {
+ const wrapper = mount(Foo)
+ const radioInput = wrapper.find('input[type="radio"]')
+
+ await radioInput.setChecked()
+
+ expect(radioInput.element.checked).toBeTruthy()
+})
```
- **Note:**
diff --git a/docs/api/wrapper/setData.md b/docs/api/wrapper/setData.md
index ca622d3d3..ef8323ca3 100644
--- a/docs/api/wrapper/setData.md
+++ b/docs/api/wrapper/setData.md
@@ -16,7 +16,11 @@ setData works by recursively calling Vue.set.
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
-const wrapper = mount(Foo)
-wrapper.setData({ foo: 'bar' })
-expect(wrapper.vm.foo).toBe('bar')
+test('setData demo', async () => {
+ const wrapper = mount(Foo)
+
+ await wrapper.setData({ foo: 'bar' })
+
+ expect(wrapper.vm.foo).toBe('bar')
+})
```
diff --git a/docs/api/wrapper/setProps.md b/docs/api/wrapper/setProps.md
index 7b6ed8fe0..9fc39cc7d 100644
--- a/docs/api/wrapper/setProps.md
+++ b/docs/api/wrapper/setProps.md
@@ -14,9 +14,13 @@ Sets `Wrapper` `vm` props and forces update.
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
-const wrapper = mount(Foo)
-wrapper.setProps({ foo: 'bar' })
-expect(wrapper.vm.foo).toBe('bar')
+test('setProps demo', async () => {
+ const wrapper = mount(Foo)
+
+ await wrapper.setProps({ foo: 'bar' })
+
+ expect(wrapper.vm.foo).toBe('bar')
+})
```
You can also pass a `propsData` object, which will initialize the Vue instance with passed values.
diff --git a/docs/api/wrapper/setSelected.md b/docs/api/wrapper/setSelected.md
index 85767740a..fa953f672 100644
--- a/docs/api/wrapper/setSelected.md
+++ b/docs/api/wrapper/setSelected.md
@@ -8,10 +8,14 @@ Selects an option element and updates `v-model` bound data.
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
-const wrapper = mount(Foo)
-const options = wrapper.find('select').findAll('option')
+test('setSelected demo', async () => {
+ const wrapper = mount(Foo)
+ const options = wrapper.find('select').findAll('option')
-options.at(1).setSelected()
+ await options.at(1).setSelected()
+
+ expect(wrapper.find('option:checked').element.value).toBe('bar')
+})
```
- **Note:**
diff --git a/docs/api/wrapper/setValue.md b/docs/api/wrapper/setValue.md
index f74e0c3dd..efe2a29f4 100644
--- a/docs/api/wrapper/setValue.md
+++ b/docs/api/wrapper/setValue.md
@@ -12,17 +12,28 @@ Sets value of a text-control input or select element and updates `v-model` bound
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
-const wrapper = mount(Foo)
+test('setValue demo', async () => {
+ const wrapper = mount(Foo)
-const textInput = wrapper.find('input[type="text"]')
-textInput.setValue('some value')
+ const textInput = wrapper.find('input[type="text"]')
+ await textInput.setValue('some value')
-const select = wrapper.find('select')
-select.setValue('option value')
+ expect(wrapper.find('input[type="text"]').element.value).toBe('some value')
-// requires