question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stubbing components

See original GitHub issue

We 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jackmelliscommented, Jul 11, 2017

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.

1reaction
jackmelliscommented, Jul 11, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found