Stubbing components
See original GitHub issueWe have discussed adding an option to stub components to mount (shallow does this by default).
Do people agree with this API:
mount(Component, stub: {
ComponentName: '<div />',
AnotherComponentName: Component
})
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Stubs and Shallow Mount | Vue Test Utils
Vue Test Utils provides some advanced features for stubbing components and directives. A stub is where you replace an existing implementation of a...
Read more >Stubbing components - Vue Testing Handbook
Why stub? When writing unit tests, often we want to stub parts of the code we are not interested in. A stub is...
Read more >What are "stubbed child components" in Vue Test Utils?
A stubbed child component is a replacement for a child component rendered by the component under test. Imagine you have a ParentComponent ...
Read more >[Testing Vue 3 apps] 1.12 - Stubbing Components with global ...
My courses and advanced screencasts: https://vuejs-course.com/My website (sign-up for my book on Vue testing!) https://lachlan-miller.me/
Read more >Stubbing components in jest tests - No Fluff Web
Stubbing components in Jest tests ... import MyComponent from "@/components/MyComponent.vue"; const localVue ... The component will look something like
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think if you are testing a component that is rendering globally-registered components, it should stub them locally. But I don’t think it’s wise to alter the original components, as like you said, you could end up with leaks between tests.
I’ve come across the same issue myself, it’s very hard to stub global components. The safest solution (aside from not stubbing them at all) is to go through all global components and register a local component with the same name on the test component.