Skip to content

Commit b1c68fc

Browse files
committed
chore: merge
2 parents fe7452a + 44c4520 commit b1c68fc

File tree

130 files changed

+14290
-13472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+14290
-13472
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"presets": ["env", "stage-2", "flow-vue"],
3-
"plugins": ["transform-decorators-legacy"],
3+
"plugins": ["transform-decorators-legacy", "transform-vue-jsx"],
44
"comments": false
55
}

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- attach_workspace:
104104
at: ~/repo
105105
- *restore_node_modules
106-
- run: yarn test:compat "2.5.13"
106+
- run: yarn test:compat "2.5.16"
107107
workflows:
108108
version: 2
109109
install-tests:

.github/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The default test script will do the following: lint with ESLint -> type check wi
8282

8383
- **`create-instance`**: private package that creates an instance and applies mounting options.
8484

85-
- **`shared`**: private package that contains utilities used by the other packzges.
85+
- **`shared`**: private package that contains utilities used by the other packages.
8686

8787
- **`scripts`**: contains build-related scripts and configuration files. In most cases you don't need to touch them.
8888

CHANGELOG.md

+72
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,78 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
<a name="1.0.0-beta.23"></a>
7+
# [1.0.0-beta.23](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2018-07-31)
8+
9+
10+
### Bug Fixes
11+
12+
* add stubs/mocks to extended components ([#881](https://github.com/vuejs/vue-test-utils/issues/881)) ([862ce5c](https://github.com/vuejs/vue-test-utils/commit/862ce5c))
13+
14+
15+
16+
17+
<a name="1.0.0-beta.22"></a>
18+
# [1.0.0-beta.22](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2018-07-29)
19+
20+
21+
### Bug Fixes
22+
23+
* remove incorrect test ([#847](https://github.com/vuejs/vue-test-utils/issues/847)) ([e9374b8](https://github.com/vuejs/vue-test-utils/commit/e9374b8))
24+
* add unused propsData as component attributes ([#865](https://github.com/vuejs/vue-test-utils/issues/865)) ([c747cd6](https://github.com/vuejs/vue-test-utils/commit/c747cd6))
25+
* clear static tree for slots render ([#862](https://github.com/vuejs/vue-test-utils/issues/862)) ([c7ac0d9](https://github.com/vuejs/vue-test-utils/commit/c7ac0d9))
26+
* handle dynamic imports ([#864](https://github.com/vuejs/vue-test-utils/issues/864)) ([4e739bd](https://github.com/vuejs/vue-test-utils/commit/4e739bd))
27+
* keep the overrides prototype information of component ([#856](https://github.com/vuejs/vue-test-utils/issues/856)) ([0371793](https://github.com/vuejs/vue-test-utils/commit/0371793))
28+
* render children for functional component stubs ([#860](https://github.com/vuejs/vue-test-utils/issues/860)) ([e2e48dc](https://github.com/vuejs/vue-test-utils/commit/e2e48dc))
29+
* stub globally registered components ([#859](https://github.com/vuejs/vue-test-utils/issues/859)) ([5af3677](https://github.com/vuejs/vue-test-utils/commit/5af3677))
30+
* support multiple default slot nodes ([#861](https://github.com/vuejs/vue-test-utils/issues/861)) ([85dd3ec](https://github.com/vuejs/vue-test-utils/commit/85dd3ec))
31+
32+
33+
### Features
34+
35+
* add support for JSX scopedSlots value ([#871](https://github.com/vuejs/vue-test-utils/issues/871)) ([13bcaeb](https://github.com/vuejs/vue-test-utils/commit/13bcaeb))
36+
* export createWrapper method to create wrapper from instance ([#868](https://github.com/vuejs/vue-test-utils/issues/868)) ([ebca3b3](https://github.com/vuejs/vue-test-utils/commit/ebca3b3))
37+
* export wrapper class ([#866](https://github.com/vuejs/vue-test-utils/issues/866)) ([c212ebf](https://github.com/vuejs/vue-test-utils/commit/c212ebf))
38+
* render props on auto stubs ([#834](https://github.com/vuejs/vue-test-utils/issues/834)) ([8db502d](https://github.com/vuejs/vue-test-utils/commit/8db502d))
39+
40+
41+
42+
43+
<a name="1.0.0-beta.21"></a>
44+
# [1.0.0-beta.21](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2018-07-22)
45+
46+
47+
### Bug Fixes
48+
49+
* broken links for deprecated methods ([#786](https://github.com/vuejs/vue-test-utils/issues/786)) ([5bb6a0b](https://github.com/vuejs/vue-test-utils/commit/5bb6a0b))
50+
* **types:** remove unnecessary method ([#755](https://github.com/vuejs/vue-test-utils/issues/755)) ([2068208](https://github.com/vuejs/vue-test-utils/commit/2068208))
51+
* allow extended components as stubs ([#825](https://github.com/vuejs/vue-test-utils/issues/825)) ([65449b3](https://github.com/vuejs/vue-test-utils/commit/65449b3))
52+
* extend extended child components ([#757](https://github.com/vuejs/vue-test-utils/issues/757)) ([bc5aba3](https://github.com/vuejs/vue-test-utils/commit/bc5aba3))
53+
* fix type of wrapper.vm ([#759](https://github.com/vuejs/vue-test-utils/issues/759)) ([ff5220d](https://github.com/vuejs/vue-test-utils/commit/ff5220d))
54+
* handle cloneDeep errors in createLocalVue ([#844](https://github.com/vuejs/vue-test-utils/issues/844)) ([17dfdc8](https://github.com/vuejs/vue-test-utils/commit/17dfdc8))
55+
* handle textarea correctly in setValue() and setChecked() ([#771](https://github.com/vuejs/vue-test-utils/issues/771)) ([4c9fe3c](https://github.com/vuejs/vue-test-utils/commit/4c9fe3c))
56+
* handle unnamed parent and child components ([#768](https://github.com/vuejs/vue-test-utils/issues/768)) ([71a2ac4](https://github.com/vuejs/vue-test-utils/commit/71a2ac4))
57+
* improve scopedSlots option ([#808](https://github.com/vuejs/vue-test-utils/issues/808)) ([b946997](https://github.com/vuejs/vue-test-utils/commit/b946997))
58+
* improve slots option ([#813](https://github.com/vuejs/vue-test-utils/issues/813)) ([5fecbd2](https://github.com/vuejs/vue-test-utils/commit/5fecbd2))
59+
* recursively call Vue.set in setData ([#843](https://github.com/vuejs/vue-test-utils/issues/843)) ([ef01abf](https://github.com/vuejs/vue-test-utils/commit/ef01abf))
60+
* setProps() throws an error if the property is the same reference ([#791](https://github.com/vuejs/vue-test-utils/issues/791)) ([bf655f3](https://github.com/vuejs/vue-test-utils/commit/bf655f3))
61+
* stubs extended component correctly ([#767](https://github.com/vuejs/vue-test-utils/issues/767)) ([24ab4c5](https://github.com/vuejs/vue-test-utils/commit/24ab4c5))
62+
* support setValue on textarea ([#764](https://github.com/vuejs/vue-test-utils/issues/764)) ([e83cda2](https://github.com/vuejs/vue-test-utils/commit/e83cda2))
63+
* update props when watcher depends on value ([#842](https://github.com/vuejs/vue-test-utils/issues/842)) ([2aeaee3](https://github.com/vuejs/vue-test-utils/commit/2aeaee3))
64+
* use boolean for VueWrapper ([#763](https://github.com/vuejs/vue-test-utils/issues/763)) ([6fa6ecd](https://github.com/vuejs/vue-test-utils/commit/6fa6ecd))
65+
* use for in to stub components on prototype ([#845](https://github.com/vuejs/vue-test-utils/issues/845)) ([b6a3659](https://github.com/vuejs/vue-test-utils/commit/b6a3659))
66+
67+
68+
### Features
69+
70+
* add parentComponent option ([#846](https://github.com/vuejs/vue-test-utils/issues/846)) ([1951409](https://github.com/vuejs/vue-test-utils/commit/1951409))
71+
* enabled slots option to take class components ([#826](https://github.com/vuejs/vue-test-utils/issues/826)) ([4916fed](https://github.com/vuejs/vue-test-utils/commit/4916fed))
72+
* render slots by default ([#782](https://github.com/vuejs/vue-test-utils/issues/782)) ([1ad731e](https://github.com/vuejs/vue-test-utils/commit/1ad731e))
73+
* use setValue() on select element ([#837](https://github.com/vuejs/vue-test-utils/issues/837)) ([2e6de7b](https://github.com/vuejs/vue-test-utils/commit/2e6de7b))
74+
75+
76+
77+
678
<a name="1.0.0-beta.20"></a>
779
# [1.0.0-beta.20](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2018-06-24)
880

docs/.vuepress/config.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module.exports = {
2626
themeConfig: {
2727
repo: 'vuejs/vue-test-utils',
2828
docsDir: 'docs',
29+
editLinks: true,
30+
docsBranch: 'dev',
2931
locales: {
3032
'/': {
3133
label: 'English',

docs/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
77
* [Common Tips](guides/common-tips.md)
88
* [Mouse, Key and other DOM Events](guides/dom-events.md)
99
* [Choosing a test runner](guides/choosing-a-test-runner.md)
10-
* [Testing SFCs with Jest](guides/testing-SFCs-with-jest.md)
11-
* [Testing SFCs with Mocha + webpack](guides/testing-SFCs-with-mocha-webpack.md)
12-
* [Testing SFCs with Karma](guides/testing-SFCs-with-karma.md)
10+
* [Testing SFCs with Jest](guides/testing-single-file-components-with-jest.md)
11+
* [Testing SFCs with Mocha + webpack](guides/testing-single-file-components-with-mocha-webpack.md)
12+
* [Testing SFCs with Karma](guides/testing-single-file-components-with-karma.md)
1313
* [Testing Asynchronous Behavior](guides/testing-async-components.md)
14+
* [Using with TypeScript](guides/using-with-typescript.md)
1415
* [Using with Vue Router](guides/using-with-vue-router.md)
1516
* [Using with Vuex](guides/using-with-vuex.md)
1617
* [API](api/)
@@ -28,6 +29,7 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
2829
- [attachToDocument](api/options.md#attachtodocument)
2930
- [attrs](api/options.md#attrs)
3031
- [listeners](api/options.md#listeners)
32+
- [parentComponent](api/options.md#parentComponent)
3133
- [provide](api/options.md#provide)
3234
- [sync](api/options.md#sync)
3335
- [other options](api/options.md#other-options)
@@ -77,5 +79,6 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
7779
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
7880
* [RouterLinkStub](api/components/RouterLinkStub.md)
7981
* [Selectors](api/selectors.md)
82+
* [createWrapper](api/createWrapper.md)
8083
* [createLocalVue](api/createLocalVue.md)
8184
* [config](api/config.md)

docs/api/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
!!!include(docs/api/renderToString.md)!!!
77
!!!include(docs/api/selectors.md)!!!
88
!!!include(docs/api/createLocalVue.md)!!!
9+
!!!include(docs/api/createWrapper.md)!!!
910
!!!include(docs/api/config.md)!!!

docs/api/config.md

+12-14
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ When passing `stubs` as an array in the mounting options, `config.stubs` are con
2020
Example:
2121

2222
```js
23-
import VueTestUtils from '@vue/test-utils'
23+
import { config } from '@vue/test-utils'
2424

25-
VueTestUtils.config.stubs['my-component'] = '<div />'
25+
config.stubs['my-component'] = '<div />'
2626
```
2727

2828
### `mocks`
@@ -35,9 +35,9 @@ Like `stubs`, the values passed to `config.mocks` are used by default. Any value
3535
Example:
3636

3737
```js
38-
import VueTestUtils from '@vue/test-utils'
38+
import { config } from '@vue/test-utils'
3939

40-
VueTestUtils.config.mocks['$store'] = {
40+
config.mocks['$store'] = {
4141
state: {
4242
id: 1
4343
}
@@ -54,11 +54,9 @@ You can configure default methods using the `config` object. This can be useful
5454
Example:
5555

5656
```js
57-
import VueTestUtils from '@vue/test-utils'
57+
import { config } from '@vue/test-utils'
5858

59-
VueTestUtils.config.methods['errors'] = () => {
60-
any: () => false
61-
}
59+
config.methods['getData'] = () => {}
6260
```
6361

6462
### `provide`
@@ -71,9 +69,9 @@ Like `stubs` or `mocks`, the values passed to `config.provide` are used by defau
7169
Example:
7270

7371
```js
74-
import VueTestUtils from '@vue/test-utils'
72+
import { config } from '@vue/test-utils'
7573

76-
VueTestUtils.config.provide['$logger'] = {
74+
config.provide['$logger'] = {
7775
log: (...args) => {
7876
console.log(...args)
7977
}
@@ -90,9 +88,9 @@ Logs warning when extended child components are automatically stubbed. Hides war
9088
Example:
9189

9290
```js
93-
import VueTestUtils from '@vue/test-utils'
91+
import { config } from '@vue/test-utils'
9492

95-
VueTestUtils.config.logModifiedComponents = false
93+
config.logModifiedComponents = false
9694
```
9795

9896
### `silent`
@@ -105,7 +103,7 @@ It suppresses warnings triggered by Vue while mutating component's observables (
105103
Example:
106104

107105
```js
108-
import VueTestUtils from '@vue/test-utils'
106+
import { config } from '@vue/test-utils'
109107

110-
VueTestUtils.config.silent = false
108+
config.silent = false
111109
```

docs/api/createWrapper.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## createWrapper(node [, options])
2+
3+
- **Arguments:**
4+
5+
- `{vm|HTMLElement} node`
6+
- `{Object} options`
7+
- `{Boolean} sync`
8+
- `{Boolean} attachedToDocument`
9+
10+
- **Returns:**
11+
- `{Wrapper}`
12+
13+
- **Usage:**
14+
15+
`createWrapper` creates a `Wrapper` for a mounted Vue instance, or an HTML element.
16+
17+
```js
18+
import { createWrapper } from '@vue/test-utils'
19+
import Foo from './Foo.vue'
20+
21+
const Constructor = Vue.extend(Foo)
22+
const vm = new Constructor().$mount()
23+
const wrapper = createWrapper(vm)
24+
expect(wrapper.vm.foo).toBe(true)
25+
```
26+

docs/api/options.md

+63-16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Options for `mount` and `shallowMount`. The options object can contain both Vue
1111
- [`attachToDocument`](#attachtodocument)
1212
- [`attrs`](#attrs)
1313
- [`listeners`](#listeners)
14+
- [`parentComponent`](#parentComponent)
1415
- [`provide`](#provide)
1516
- [`sync`](#sync)
1617

@@ -46,45 +47,74 @@ Example:
4647

4748
```js
4849
import Foo from './Foo.vue'
49-
import Bar from './Bar.vue'
50+
51+
const bazComponent = {
52+
name: 'baz-component',
53+
template: '<p>baz</p>'
54+
}
5055

5156
const wrapper = shallowMount(Component, {
5257
slots: {
53-
default: [Foo, Bar],
58+
default: [Foo, '<my-component />', 'text'],
5459
fooBar: Foo, // Will match `<slot name="FooBar" />`.
5560
foo: '<div />',
56-
bar: 'bar'
61+
bar: 'bar',
62+
baz: bazComponent,
63+
qux: '<my-component />'
5764
}
5865
})
66+
5967
expect(wrapper.find('div')).toBe(true)
6068
```
6169

6270
## scopedSlots
6371

64-
- type: `{ [name: string]: string }`
72+
- type: `{ [name: string]: string|Function }`
6573

66-
Provide an object of scoped slots contents to the component. The key corresponds to the slot name. The value can be a template string.
74+
Provide an object of scoped slots to the component. The key corresponds to the slot name.
6775

68-
There are three limitations.
76+
You can set the name of the props using the slot-scope attribute:
6977

70-
* This option is only supported in [email protected]+.
78+
```js
79+
shallowMount(Component, {
80+
scopedSlots: {
81+
foo: '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>'
82+
}
83+
})
84+
```
7185

72-
* You can not use `<template>` tag as the root element in the `scopedSlots` option.
86+
Otherwise props are available as a `props` object when the slot is evaluated:
7387

74-
* This does not support PhantomJS.
75-
You can use [Puppeteer](https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer) as an alternative.
88+
```js
89+
shallowMount(Component, {
90+
scopedSlots: {
91+
default: '<p>{{props.index}},{{props.text}}</p>'
92+
}
93+
})
94+
```
7695

77-
Example:
96+
You can also pass a function that takes the props as an argument:
7897

7998
```js
80-
const wrapper = shallowMount(Component, {
99+
shallowMount(Component, {
100+
scopedSlots: {
101+
foo: function (props) {
102+
return this.$createElement('div', props.index)
103+
}
104+
}
105+
})
106+
```
107+
108+
Or you can use JSX. If you write JSX in a method, `this.$createElement` is auto-injected by babel-plugin-transform-vue-jsx:
109+
110+
```js
111+
shallowMount(Component, {
81112
scopedSlots: {
82-
foo: '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
113+
foo (props) {
114+
return <div>{ props.text }</div>
115+
}
83116
}
84117
})
85-
expect(wrapper.find('#fooWrapper').html()).toBe(
86-
`<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>`
87-
)
88118
```
89119

90120
## stubs
@@ -182,6 +212,23 @@ Set the component instance's `$attrs` object.
182212

183213
Set the component instance's `$listeners` object.
184214

215+
## parentComponent
216+
217+
- type: `Object`
218+
219+
Component to use as parent for mounted component.
220+
221+
Example:
222+
223+
```js
224+
import Foo from './Foo.vue'
225+
226+
const wrapper = shallowMount(Component, {
227+
parentComponent: Foo
228+
})
229+
expect(wrapper.vm.$parent.name).toBe('foo')
230+
```
231+
185232
## provide
186233

187234
- type: `Object`

docs/api/wrapper/setChecked.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { mount } from '@vue/test-utils'
1212
import Foo from './Foo.vue'
1313

1414
const wrapper = mount(Foo)
15-
const option = wrapper.find('input[type="radio"]')
16-
option.setChecked()
15+
const radioInput = wrapper.find('input[type="radio"]')
16+
radioInput.setChecked()
1717
```
1818

1919
- **Note:**

docs/api/wrapper/setData.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Sets `Wrapper` `vm` data.
44

5-
setData works by merging existing properties, except for arrays which are overwritten.
5+
setData works by recursively calling Vue.set.
66

77
**Note the Wrapper must contain a Vue instance.**
88

0 commit comments

Comments
 (0)