@@ -1100,17 +1100,15 @@ To test the logic of Apollo cache updates, we might want to mock an Apollo Clien
...
@@ -1100,17 +1100,15 @@ To test the logic of Apollo cache updates, we might want to mock an Apollo Clien
To separate tests with mocked client from 'usual' unit tests, create an additional factory and pass the created `mockApollo` as an option to the `createComponent`-factory. This way we only create Apollo Client instance when it's necessary.
To separate tests with mocked client from 'usual' unit tests, create an additional factory and pass the created `mockApollo` as an option to the `createComponent`-factory. This way we only create Apollo Client instance when it's necessary.
We need to inject `VueApollo`to the Vue local instance and, likewise, it is recommended to call `localVue.use()` in `createMockApolloProvider()` to only load it when it is necessary.
We need to inject `VueApollo`into the Vue instance by calling `Vue.use(VueApollo)`. This will install `VueApollo` globally for all the tests in the file. It is recommended to call `Vue.use(VueApollo)` just after the imports.
```javascript
```javascript
importVueApollofrom'vue-apollo';
importVueApollofrom'vue-apollo';
import{createLocalVue}from'@vue/test-utils';
importVuefrom'vue';
constlocalVue=createLocalVue();
Vue.use(VueApollo);
functioncreateMockApolloProvider(){
functioncreateMockApolloProvider(){
localVue.use(VueApollo);
returncreateMockApollo(requestHandlers);
returncreateMockApollo(requestHandlers);
}
}
...
@@ -1118,7 +1116,6 @@ function createComponent(options = {}) {
...
@@ -1118,7 +1116,6 @@ function createComponent(options = {}) {