File tree 15 files changed +84
-34
lines changed
15 files changed +84
-34
lines changed Original file line number Diff line number Diff line change 1
1
# Vue Test Utils [ ![ Build Status] ( https://circleci.com/gh/vuejs/vue-test-utils/tree/dev.png?style=shield )] ( https://circleci.com/gh/vuejs/vue-test-utils )
2
2
3
+ Vue Test Utils is the official testing library for Vue.js.
4
+
3
5
## Packages
4
6
5
- This repository provides the following two packages.
6
- They are currently in beta.
7
+ This repository provides the following two packages:
7
8
8
9
- [ Vue Test Utils] ( ./packages/test-utils )
9
10
- [ Vue Server Test Utils] ( ./packages/server-test-utils )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -302,8 +302,7 @@ remove the rendered elements from the document and destroy the component instanc
302
302
303
303
``` js
304
304
const Component = {
305
- template: ' <div>ABC</div>' ,
306
- props: [' msg' ]
305
+ template: ' <div>ABC</div>'
307
306
}
308
307
let wrapper = mount (Component, {
309
308
attachTo: ' #root'
@@ -323,7 +322,11 @@ wrapper.destroy()
323
322
- type: ` boolean `
324
323
- default: ` false `
325
324
326
- Like [ ` attachTo ` ] ( #attachto ) , but automatically creates a new ` div ` element for you and inserts it into the body. This is deprecated in favor of [ ` attachTo ` ] ( #attachto ) .
325
+ ::: warning
326
+ ` attachToDocument ` is deprecated and will be removed in future releases. Use [ ` attachTo ` ] ( #attachto ) instead.
327
+ :::
328
+
329
+ Like [ ` attachTo ` ] ( #attachto ) , but automatically creates a new ` div ` element for you and inserts it into the body.
327
330
328
331
When attaching to the DOM, you should call ` wrapper.destroy() ` at the end of your test to
329
332
remove the rendered elements from the document and destroy the component instance.
@@ -432,26 +435,22 @@ When the options for `mount` and `shallowMount` contain the options other than t
432
435
433
436
``` js
434
437
const Component = {
435
- template: ' <div>{{ foo() }}{{ bar() }}{{ baz() }}</div>' ,
436
- methods: {
437
- foo () {
438
- return ' a'
439
- },
440
- bar () {
441
- return ' b'
438
+ template: ' <div>{{ foo }}</div>' ,
439
+ data () {
440
+ return {
441
+ foo: ' fromComponent'
442
442
}
443
443
}
444
444
}
445
445
const options = {
446
- methods: {
447
- bar () {
448
- return ' B'
449
- },
450
- baz () {
451
- return ' C'
446
+ data () {
447
+ return {
448
+ foo: ' fromOptions'
452
449
}
453
450
}
454
451
}
452
+
455
453
const wrapper = mount (Component, options)
456
- expect (wrapper .text ()).toBe (' aBC' )
454
+
455
+ expect (wrapper .text ()).toBe (' fromOptions' )
457
456
```
Original file line number Diff line number Diff line change 1
1
## isEmpty
2
2
3
+ ::: warning
4
+ ` isEmpty ` is deprecated and will be removed in future releases.
5
+
6
+ Consider a custom matcher such as those provided in [ jest-dom] ( https://github.com/testing-library/jest-dom#tobeempty ) .
7
+
8
+ When using with findComponent, access the DOM element with findComponent(Comp).element
9
+ :::
10
+
3
11
Assert every ` Wrapper ` in ` WrapperArray ` does not contain child node.
4
12
5
13
- ** Returns:** ` {boolean} `
Original file line number Diff line number Diff line change 1
1
## isVueInstance
2
2
3
+ ::: warning
4
+ ` isVueInstance ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Assert every ` Wrapper ` in ` WrapperArray ` is Vue instance.
4
8
5
9
- ** Returns:** ` {boolean} `
Original file line number Diff line number Diff line change 1
1
## setMethods
2
2
3
+ ::: warning
4
+ ` setMethods ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Sets ` Wrapper ` ` vm ` methods and forces update on each ` Wrapper ` in ` WrapperArray ` .
4
8
5
9
** Note every ` Wrapper ` must contain a Vue instance.**
Original file line number Diff line number Diff line change 1
1
## emittedByOrder
2
2
3
+ ::: warning
4
+ ` emittedByOrder ` is deprecated and will be removed in future releases.
5
+
6
+ Use ` wrapper.emitted ` instead.
7
+ :::
8
+
3
9
Return an Array containing custom events emitted by the ` Wrapper ` ` vm ` .
4
10
5
11
- ** Returns:** ` Array<{ name: string, args: Array<any> }> `
Original file line number Diff line number Diff line change 1
1
## find
2
2
3
+ ::: warning
4
+ Using ` find ` to search for a Component is deprecated and will be removed. Use ` findComponent ` instead.
5
+ :::
6
+
3
7
Returns ` Wrapper ` of first DOM node or Vue component matching selector.
4
8
5
9
Use any valid DOM selector (uses ` querySelector ` syntax).
Original file line number Diff line number Diff line change 1
1
## findAll
2
2
3
+ ::: warning
4
+ Using ` findAll ` to search for Components is deprecated and will be removed. Use ` findAllComponents ` instead.
5
+ :::
6
+
3
7
Returns a [ ` WrapperArray ` ] ( ../wrapper-array/ ) .
4
8
5
9
Use any valid [ selector] ( ../selectors.md ) .
@@ -18,8 +22,10 @@ import Foo from './Foo.vue'
18
22
import Bar from ' ./Bar.vue'
19
23
20
24
const wrapper = mount (Foo)
25
+
21
26
const div = wrapper .findAll (' div' ).at (0 )
22
27
expect (div .is (' div' )).toBe (true )
23
- const bar = wrapper .findAll (Bar).at (0 )
28
+
29
+ const bar = wrapper .findAll (Bar).at (0 ) // Deprecated usage
24
30
expect (bar .is (Bar)).toBe (true )
25
31
```
Original file line number Diff line number Diff line change 1
1
## isEmpty
2
2
3
+ ::: warning
4
+ ` isEmpty ` is deprecated and will be removed in future releases.
5
+
6
+ Consider a custom matcher such as those provided in [ jest-dom] ( https://github.com/testing-library/jest-dom#tobeempty ) .
7
+
8
+ When using with findComponent, access the DOM element with ` findComponent(Comp).element `
9
+ :::
10
+
3
11
Assert ` Wrapper ` does not contain child node.
4
12
5
13
- ** Returns:** ` {boolean} `
Original file line number Diff line number Diff line change 1
1
## isVisible
2
2
3
+ ::: warning
4
+ ` isVisible ` is deprecated and will be removed in future releases.
5
+
6
+ Consider a custom matcher such as those provided in [ jest-dom] ( https://github.com/testing-library/jest-dom#tobevisible ) .
7
+
8
+ When using with findComponent, access the DOM element with ` findComponent(Comp).element `
9
+ :::
10
+
3
11
Assert ` Wrapper ` is visible.
4
12
5
13
Returns ` false ` if an ancestor element has ` display: none ` or ` visibility: hidden ` style.
Original file line number Diff line number Diff line change 1
1
## isVueInstance
2
2
3
+ ::: warning
4
+ ` isVueInstance ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Assert ` Wrapper ` is Vue instance.
4
8
5
9
- ** Returns:** ` {boolean} `
Original file line number Diff line number Diff line change 1
1
## name
2
2
3
+ ::: warning
4
+ ` name ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Returns component name if ` Wrapper ` contains a Vue instance, or the tag name of ` Wrapper ` DOM node if ` Wrapper ` does not contain a Vue instance.
4
8
5
9
- ** Returns:** ` {string} `
Original file line number Diff line number Diff line change 1
1
## overview
2
2
3
+ ::: warning
4
+ ` overview ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Prints a simple overview of the ` Wrapper ` .
4
8
5
9
- ** Example:**
Original file line number Diff line number Diff line change 1
1
## setMethods
2
2
3
+ ::: warning
4
+ ` setMethods ` is deprecated and will be removed in future releases.
5
+ :::
6
+
3
7
Sets ` Wrapper ` ` vm ` methods and forces update.
4
8
5
9
** Note the Wrapper must contain a Vue instance.**
You can’t perform that action at this time.
0 commit comments