You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You need to install `vue-template-compiler` which is used to compiled components. It should be the same version as the version of Vue you are using.
19
+
You need to install `vue-template-compiler` which is used to compile components. It should be the same version as the version of Vue you are using.
20
20
21
21
```
22
22
npm install --save-dev vue-template-compiler
@@ -35,7 +35,7 @@ Refer to the [documentation](https://vue-test-utils.vuejs.org/)
35
35
36
36
## Questions
37
37
38
-
For questions and support please use the [Discord chat room](https://vue-land.js.org/), [Gitter chat room](https://gitter.im/vuejs/vue), or [the official forum](http://forum.vuejs.org). The issue list of this repo is **exclusively** for bug reports and feature requests.
38
+
For questions and support please use the [Discord chat room](https://vue-land.js.org/) or [the official forum](http://forum.vuejs.org). The issue list of this repo is **exclusively** for bug reports and feature requests.
Copy file name to clipboardExpand all lines: docs/api/options.md
+48-2
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,18 @@ Options for `mount` and `shallowMount`. The options object can contain both Vue
9
9
-[`mocks`](#mocks)
10
10
-[`localVue`](#localvue)
11
11
-[`attachToDocument`](#attachtodocument)
12
+
-[`propsData`](#propsdata)
12
13
-[`attrs`](#attrs)
13
14
-[`listeners`](#listeners)
14
-
-[`parentComponent`](#parentComponent)
15
+
-[`parentComponent`](#parentcomponent)
15
16
-[`provide`](#provide)
16
17
-[`sync`](#sync)
17
18
18
19
## context
19
20
20
21
- type: `Object`
21
22
22
-
Passes context to functional component. Can only be used with functional components.
23
+
Passes context to functional component. Can only be used with [functional components](https://vuejs.org/v2/guide/render-function.html#Functional-Components).
23
24
24
25
Example:
25
26
@@ -206,6 +207,32 @@ Component will be attached to DOM when rendered if set to `true`.
206
207
207
208
Set the component instance's `$attrs` object.
208
209
210
+
## propsData
211
+
212
+
- type: `Object`
213
+
214
+
Set the component instance's props.
215
+
216
+
Example:
217
+
218
+
```js
219
+
constComponent= {
220
+
template:'<div>{{ msg }}</div>',
221
+
props: ['msg']
222
+
}
223
+
constwrapper=mount(Component, {
224
+
propsData: {
225
+
msg:'aBC'
226
+
}
227
+
})
228
+
expect(wrapper.text()).toBe('aBC')
229
+
```
230
+
231
+
::: tip
232
+
It's worth noting that `propsData` is actually a [Vue API](https://vuejs.org/v2/api/#propsData), not a
233
+
`vue-test-utils` option. It is processed through [`extends`](#other-options).
Vue Test Utils でコンポーネントをマウントすると、コンポーネントのルート HTML 要素にアクセスすることができます。 [Jest のスナップショットテスト](https://facebook.github.io/jest/docs/en/snapshot-testing.html)で使用するためにこれを保存することができます。
0 commit comments