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
Copy file name to clipboardExpand all lines: src/v3/stubbing-components.md
+8-6
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ export default {
83
83
84
84
## Write a test using `mount`
85
85
86
-
Let's start off by writing a test to verify that `<ComponentWithAsyncCall>` is rendered:
86
+
Let's start off by writing a test to verify that `<ComponentWithAsyncCall>` is rendered. Note that `findComponent` is used. `find` is used for querying DOM elements, and uses the `querySelector` syntax. `findComponent` is used when looking for a specific component, a takes a component as the argument.
87
87
88
88
```js
89
89
import { shallowMount, mount } from'@vue/test-utils'
The test is passing - great! However, we can do better. Notice the `console.log` in the test output - this comes from the `makeApiCall` method. Ideally we don't want to make calls to external services in our unit tests, especially when it's from a component that is not the main focus of the current test. We can use the `stubs` mounting option, described in the `vue-test-utils` docs [here](https://vue-test-utils.vuejs.org/api/options.html#stubs).
111
+
The test is passing - great! However, we can do better. Notice the `console.log` in the test output - this comes from the `makeApiCall` method. Ideally we don't want to make calls to external services in our unit tests, especially when it's from a component that is not the main focus of the current test. We can use the `stubs` mounting option, described in the `vue-test-utils` docs [here](https://next.vue-test-utils.vuejs.org/migration/#mocks-and-stubs-are-now-in-global).
112
112
113
113
## Using `stubs` to stub `<ComponentWithAsyncCall>`
114
114
@@ -117,9 +117,11 @@ Let's update the test, this time stubbing `<ComponentWithAsyncCall>`:
117
117
```js
118
118
it('renders with mount and does initialize API call', () => {
0 commit comments