Skip to content

Commit 8024534

Browse files
committed
Merge branch 'dev' into en
2 parents 95c618a + 6fa6e06 commit 8024534

File tree

134 files changed

+1559
-872
lines changed

Some content is hidden

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

134 files changed

+1559
-872
lines changed

build/config/rollup-options-test.js

-9
This file was deleted.

build/git-hooks/commit-msg

-14
This file was deleted.

build/git-hooks/pre-commit

-4
This file was deleted.

build/install-hooks.js

-8
This file was deleted.

dist/vue-test-utils.js

+127-108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/en/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* [components](api/components/README.md)
7171
* [TransitionStub](api/components/TransitionStub.md)
7272
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
73+
* [RouterLinkStub](api/components/RouterLinkStub.md)
7374
* [Selectors](api/selectors.md)
7475
* [createLocalVue](api/createLocalVue.md)
7576
* [config](api/config.md)

docs/en/SUMMARY.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* [text](api/wrapper/text.md)
4848
* [trigger](api/wrapper/trigger.md)
4949
* [update](api/wrapper/update.md)
50-
* [visible](api/wrapper/visible.md)
50+
* [isVisible](api/wrapper/isVisible.md)
5151
* [WrapperArray](api/wrapper-array/README.md)
5252
* [at](api/wrapper-array/at.md)
5353
* [contains](api/wrapper-array/contains.md)
@@ -62,7 +62,7 @@
6262
* [setProps](api/wrapper-array/setProps.md)
6363
* [trigger](api/wrapper-array/trigger.md)
6464
* [update](api/wrapper-array/update.md)
65-
* [visible](api/wrapper-array/visible.md)
65+
* [isVisible](api/wrapper-array/isVisible.md)
6666
* [components](api/components/README.md)
6767
* [TransitionStub](api/components/TransitionStub.md)
6868
* [TransitionGroupStub](api/components/TransitionGroupStub.md)

docs/en/api/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
* [destroy](./wrapper/destroy.md)
2424
* [find](./wrapper/find.md)
2525
* [findAll](./wrapper/findAll.md)
26-
* [hasAttribute](./wrapper/hasAttribute.md)
27-
* [hasClass](./wrapper/hasClass.md)
28-
* [hasProp](./wrapper/hasProp.md)
2926
* [html](./wrapper/html.md)
3027
* [is](./wrapper/is.md)
3128
* [isEmpty](./wrapper/isEmpty.md)
@@ -57,6 +54,7 @@
5754
* [components](./components/README.md)
5855
* [TransitionStub](./components/TransitionStub.md)
5956
* [TransitionGroupStub](./components/TransitionGroupStub.md)
57+
* [RouterLinkStub](./components/RouterLinkStub.md)
6058
* [Selectors](./selectors.md)
6159
* [createLocalVue](./createLocalVue.md)
6260
* [config](./config.md)

docs/en/api/wrapper-array/filter.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ A new `WrapperArray` instance containing `Wrapper` instances that returns true f
1414
- **Example:**
1515

1616
```js
17-
import { shallow } from 'vue-test-utils'
18-
import { expect } from 'chai'
17+
import { shallow } from '@vue/test-utils'
1918
import Foo from './Foo.vue'
2019

2120
const wrapper = shallow(Foo)

docs/en/api/wrapper-array/visible.md renamed to docs/en/api/wrapper-array/isVisible.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { expect } from 'chai'
1616
import Foo from './Foo.vue'
1717

1818
const wrapper = mount(Foo)
19-
expect(wrapper.visible()).toBe(true)
20-
expect(wrapper.findAll('.is-not-visible').visible()).toBe(false)
21-
expect(wrapper.findAll('.is-visible').visible()).toBe(true)
19+
expect(wrapper.isVisible()).toBe(true)
20+
expect(wrapper.findAll('.is-not-visible').isVisible()).toBe(false)
21+
expect(wrapper.findAll('.is-visible').isVisible()).toBe(true)
2222
```

docs/en/api/wrapper/visible.md renamed to docs/en/api/wrapper/isVisible.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# visible()
1+
# isVisible()
22

33
Assert `Wrapper` is visible.
44

@@ -16,6 +16,6 @@ import { expect } from 'chai'
1616
import Foo from './Foo.vue'
1717

1818
const wrapper = mount(Foo)
19-
expect(wrapper.visible()).toBe(true)
20-
expect(wrapper.find('.is-not-visible').visible()).toBe(false)
19+
expect(wrapper.isVisible()).toBe(true)
20+
expect(wrapper.find('.is-not-visible').isVisible()).toBe(false)
2121
```

docs/en/guides/using-with-vue-router.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ shallow(Component, {
1818
})
1919
```
2020

21+
> **Note:** Installing Vue Router on a localVue also adds `$route` and `$router` as read-only properties to a localVue. This means you can not use the `mocks` option to overwrite `$route` and `$router` when mounting a component using a localVue with VueRouter installed.
22+
2123
## Testing components that use `router-link` or `router-view`
2224

2325
When you install Vue Router, the `router-link` and `router-view` components are registered. This means we can use them anywhere in our application without needing to import them.

docs/en/guides/using-with-vuex.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The most important thing to note in this test is that **we create a mock Vuex st
109109

110110
Great, so now we can mock actions, let’s look at mocking getters.
111111

112-
## Mocking Getters
112+
### Mocking Getters
113113

114114

115115
``` html
@@ -178,7 +178,7 @@ This test is similar to our actions test. We create a mock store before each tes
178178

179179
This is great, but what if we want to check our getters are returning the correct part of our state?
180180

181-
## Mocking with Modules
181+
### Mocking with Modules
182182

183183
[Modules](https://vuex.vuejs.org/en/modules.html) are useful for separating out our store into manageable chunks. They also export getters. We can use these in our tests.
184184

@@ -274,7 +274,6 @@ export default {
274274
state.count++
275275
}
276276
}
277-
278277
```
279278

280279
```js
@@ -286,7 +285,7 @@ export default {
286285

287286
### Testing getters, mutations, and actions separately
288287

289-
Getters, mutations, and actions are all JavaScript functions, so we can test them without using `vue-test-utils` or Vuex.
288+
Getters, mutations, and actions are all JavaScript functions, so we can test them without using `vue-test-utils` and Vuex.
290289

291290
The benefit to testing getters, mutations, and actions separately is that your unit tests are detailed. When they fail, you know exactly what is wrong with your code. The downside is that you will need to mock Vuex funtions, like `commit` and `dispatch`. This can lead to a situation where your unit tests pass, but your production code fails because your mocks are incorrect.
292291

@@ -333,7 +332,7 @@ test('evenOrOdd returns odd if state.count is even', () => {
333332

334333
### Testing a running store
335334

336-
Anopther approach to testing a Vuex store is to create a running store using the store config.
335+
Another approach to testing a Vuex store is to create a running store using the store config.
337336

338337
The benefit of testing creating a running store instance is we don't have to mock any Vuex functions.
339338

@@ -342,6 +341,8 @@ The downside is that when a test breaks, it can be difficult to find where the p
342341
Let's write a test. When we create a store, we'll use `localVue` to avoid polluting the Vue base constructor. The test creates a store using the `store-config.js` export:
343342

344343
```js
344+
// store-config.spec.js
345+
345346
import mutations from './mutations'
346347
import getters from './getters'
347348

@@ -355,8 +356,6 @@ export default {
355356
```
356357

357358
```js
358-
// store-config.spec.js
359-
360359
import { createLocalVue } from '@vue/test-utils'
361360
import Vuex from 'vuex'
362361
import storeConfig from './store-config'
@@ -383,7 +382,7 @@ test('updates evenOrOdd getter when increment is commited', () => {
383382

384383
Notice that we use `cloneDeep` to clone the store config before creating a store with it. This is because Vuex mutates the options object used to create the store. To make sure we have a clean store in each test, we need to clone the `storeConfig` object.
385384

386-
### Resources
385+
## Resources
387386

388387
- [Example project for testing the components](https://github.com/eddyerburgh/vue-test-utils-vuex-example)
389388
- [Example project for testing the store](https://github.com/eddyerburgh/testing-vuex-store-example)

docs/ja/README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [テストランナを選ぶ](guides/choosing-a-test-runner.md)
1010
* [Jest による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-jest.md)
1111
* [Mocha + webpack による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-mocha-webpack.md)
12+
* [Karma による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-karma.md)
1213
* [非同期動作のテスト](guides/testing-async-components.md)
1314
* [Vue Router と一緒に使う](guides/using-with-vue-router.md)
1415
* [Vuex と一緒に使う](guides/using-with-vuex.md)
@@ -36,35 +37,33 @@
3637
* [destroy](api/wrapper/destroy.md)
3738
* [find](api/wrapper/find.md)
3839
* [findAll](api/wrapper/findAll.md)
39-
* [hasStyle](api/wrapper/hasStyle.md)
4040
* [html](api/wrapper/html.md)
4141
* [is](api/wrapper/is.md)
4242
* [isEmpty](api/wrapper/isEmpty.md)
4343
* [isVueInstance](api/wrapper/isVueInstance.md)
4444
* [name](api/wrapper/name.md)
4545
* [props](api/wrapper/props.md)
46-
* [setComputed](api/wrapper/setComputed.md)
4746
* [setData](api/wrapper/setData.md)
4847
* [setMethods](api/wrapper/setMethods.md)
4948
* [setProps](api/wrapper/setProps.md)
5049
* [text](api/wrapper/text.md)
5150
* [trigger](api/wrapper/trigger.md)
5251
* [update](api/wrapper/update.md)
52+
* [visible](api/wrapper/visible.md)
5353
* [WrapperArray](api/wrapper-array/README.md)
5454
* [at](api/wrapper-array/at.md)
5555
* [contains](api/wrapper-array/contains.md)
5656
* [exists](api/wrapper/exists.md)
5757
* [destroy](api/wrapper-array/destroy.md)
58-
* [hasStyle](api/wrapper-array/hasStyle.md)
5958
* [is](api/wrapper-array/is.md)
6059
* [isEmpty](api/wrapper-array/isEmpty.md)
6160
* [isVueInstance](api/wrapper-array/isVueInstance.md)
62-
* [setComputed](api/wrapper-array/setComputed.md)
6361
* [setData](api/wrapper-array/setData.md)
6462
* [setMethods](api/wrapper-array/setMethods.md)
6563
* [setProps](api/wrapper-array/setProps.md)
6664
* [trigger](api/wrapper-array/trigger.md)
6765
* [update](api/wrapper-array/update.md)
66+
* [visible](api/wrapper-array/visible.md)
6867
* [コンポーネント](api/components/README.md)
6968
* [TransitionStub](api/components/TransitionStub.md)
7069
* [TransitionGroupStub](api/components/TransitionGroupStub.md)

docs/ja/SUMMARY.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [テストランナを選ぶ](guides/choosing-a-test-runner.md)
88
* [Jest による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-jest.md)
99
* [Mocha + webpack による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-mocha-webpack.md)
10+
* [Karma による単一ファイルコンポーネントのテスト](guides/testing-SFCs-with-karma.md)
1011
* [非同期動作のテスト](guides/testing-async-components.md)
1112
* [Vue Router と一緒に使う](guides/using-with-vue-router.md)
1213
* [Vuex と一緒に使う](guides/using-with-vuex.md)
@@ -34,7 +35,6 @@
3435
* [destroy](api/wrapper/destroy.md)
3536
* [find](api/wrapper/find.md)
3637
* [findAll](api/wrapper/findAll.md)
37-
* [hasStyle](api/wrapper/hasStyle.md)
3838
* [html](api/wrapper/html.md)
3939
* [is](api/wrapper/is.md)
4040
* [isEmpty](api/wrapper/isEmpty.md)
@@ -47,21 +47,21 @@
4747
* [text](api/wrapper/text.md)
4848
* [trigger](api/wrapper/trigger.md)
4949
* [update](api/wrapper/update.md)
50+
* [isVisible](api/wrapper/isVisible.md)
5051
* [WrapperArray](api/wrapper-array/README.md)
5152
* [at](api/wrapper-array/at.md)
5253
* [contains](api/wrapper-array/contains.md)
5354
* [exists](api/wrapper/exists.md)
5455
* [destroy](api/wrapper-array/destroy.md)
55-
* [hasStyle](api/wrapper-array/hasStyle.md)
5656
* [is](api/wrapper-array/is.md)
5757
* [isEmpty](api/wrapper-array/isEmpty.md)
5858
* [isVueInstance](api/wrapper-array/isVueInstance.md)
59-
* [setComputed](api/wrapper-array/setComputed.md)
6059
* [setData](api/wrapper-array/setData.md)
6160
* [setMethods](api/wrapper-array/setMethods.md)
6261
* [setProps](api/wrapper-array/setProps.md)
6362
* [trigger](api/wrapper-array/trigger.md)
6463
* [update](api/wrapper-array/update.md)
64+
* [isVisible](api/wrapper-array/isVisible.md)
6565
* [コンポーネント](api/components/README.md)
6666
* [TransitionStub](api/components/TransitionStub.md)
6767
* [TransitionGroupStub](api/components/TransitionGroupStub.md)

docs/ja/api/README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,33 @@
2323
* [destroy](./wrapper/destroy.md)
2424
* [find](./wrapper/find.md)
2525
* [findAll](./wrapper/findAll.md)
26-
* [hasAttribute](./wrapper/hasAttribute.md)
27-
* [hasClass](./wrapper/hasClass.md)
28-
* [hasProp](./wrapper/hasProp.md)
29-
* [hasStyle](./wrapper/hasStyle.md)
3026
* [html](./wrapper/html.md)
3127
* [is](./wrapper/is.md)
3228
* [isEmpty](./wrapper/isEmpty.md)
3329
* [isVueInstance](./wrapper/isVueInstance.md)
3430
* [name](./wrapper/name.md)
3531
* [props](./wrapper/props.md)
36-
* [setComputed](./wrapper/setComputed.md)
3732
* [setData](./wrapper/setData.md)
3833
* [setMethods](./wrapper/setMethods.md)
3934
* [setProps](./wrapper/setProps.md)
4035
* [text](./wrapper/text.md)
4136
* [trigger](./wrapper/trigger.md)
4237
* [update](./wrapper/update.md)
38+
* [visible](./wrapper/visible.md)
4339
* [WrapperArray](./wrapper-array/README.md)
4440
* [at](./wrapper-array/at.md)
4541
* [contains](./wrapper-array/contains.md)
4642
* [exists](./wrapper/exists.md)
4743
* [destroy](./wrapper-array/destroy.md)
48-
* [hasStyle](./wrapper-array/hasStyle.md)
4944
* [is](./wrapper-array/is.md)
5045
* [isEmpty](./wrapper-array/isEmpty.md)
5146
* [isVueInstance](./wrapper-array/isVueInstance.md)
52-
* [setComputed](./wrapper-array/setComputed.md)
5347
* [setData](./wrapper-array/setData.md)
5448
* [setMethods](./wrapper-array/setMethods.md)
5549
* [setProps](./wrapper-array/setProps.md)
5650
* [trigger](./wrapper-array/trigger.md)
5751
* [update](./wrapper-array/update.md)
52+
* [visible](./wrapper-array/visible.md)
5853
* [コンポーネント](./components/README.md)
5954
* [TransitionStub](./components/TransitionStub.md)
6055
* [TransitionGroupStub](./components/TransitionGroupStub.md)

docs/ja/api/components/TransitionStub.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
デフォルトではすべての `transition` コンポーネントは `TransitionStub` でスタブされます。これは `vue-test-utils``config` で設定されています。スタブせずに既存の `transition` コンポーネントを使用したい場合は、 `config.stubs['transition']``false` をセットします。:
66

77
```js
8-
import VueTestUtils from '@vue/test-utils'
8+
import { config } from '@vue/test-utils'
99

10-
VueTestUtils.config.stubs.transition = false
10+
config.stubs.transition = false
1111
```
1212

1313
`transition` コンポーネントをスタブするために再びセットするには以下のようにします。
1414

1515
```js
16-
import VueTestUtils, { TransitionStub } from '@vue/test-utils'
16+
import { config, TransitionStub } from '@vue/test-utils'
1717

18-
VueTestUtils.config.stubs.transition = TransitionStub
18+
config.stubs.transition = TransitionStub
1919
```
2020

2121
マウンティングオプションでスタブとしてセットするには以下のようにします。

docs/ja/api/wrapper-array/hasStyle.md

-24
This file was deleted.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# isVisible()
2+
3+
`WrapperArray` 内のすべての `Wrapper` が表示されているかアサートします。
4+
5+
style が `display: none``visibility: hidden` の親要素を持つ `Wrapper` が少なくとも1つある場合、 false を返します。
6+
7+
コンポーネントが `v-show` によって非表示になっているかアサートすることに使用することができます。
8+
9+
- **戻り値:** `{boolean}`
10+
11+
- **例:**
12+
13+
```js
14+
import { mount } from 'vue-test-utils'
15+
import { expect } from 'chai'
16+
import Foo from './Foo.vue'
17+
18+
const wrapper = mount(Foo)
19+
expect(wrapper.isVisible()).toBe(true)
20+
expect(wrapper.findAll('.is-not-visible').isVisible()).toBe(false)
21+
expect(wrapper.findAll('.is-visible').isVisible()).toBe(true)
22+
```

0 commit comments

Comments
 (0)