From abc48e8ff4ba2ba1fcd5d1d23c0ad7ae509c6d03 Mon Sep 17 00:00:00 2001 From: eddyerburgh Date: Sat, 8 Sep 2018 08:42:25 +0100 Subject: [PATCH 1/2] docs: add section on stubbing components to common tips --- docs/guides/common-tips.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/guides/common-tips.md b/docs/guides/common-tips.md index 64a5412bd..0da13cd16 100644 --- a/docs/guides/common-tips.md +++ b/docs/guides/common-tips.md @@ -132,6 +132,24 @@ mount(Component, { }) ``` +### Stubbing components + +You can override components that are registered globally or locally by using the `stubs` option: + +```js +import { mount } from '@vue/test-utils' + +const Stub = { + render () {} +} + +mount(Component, { + // Will resolve globally-registered-component with + // empty stub + stubs: ['globally-registered-component'] +}) +``` + ### Dealing with Routing Since routing by definition has to do with the overall structure of the application and involves multiple components, it is best tested via integration or end-to-end tests. For individual components that rely on `vue-router` features, you can mock them using the techniques mentioned above. From c320831d906b970dbec518cae0ec2ef00284c681 Mon Sep 17 00:00:00 2001 From: eddyerburgh Date: Sat, 8 Sep 2018 09:08:47 +0100 Subject: [PATCH 2/2] docs: remove Stub from example --- docs/guides/common-tips.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/guides/common-tips.md b/docs/guides/common-tips.md index 0da13cd16..a70234ecd 100644 --- a/docs/guides/common-tips.md +++ b/docs/guides/common-tips.md @@ -139,10 +139,6 @@ You can override components that are registered globally or locally by using the ```js import { mount } from '@vue/test-utils' -const Stub = { - render () {} -} - mount(Component, { // Will resolve globally-registered-component with // empty stub