Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: render component name in stub #606

Merged
merged 2 commits into from
May 15, 2018

Conversation

eddyerburgh
Copy link
Member

@eddyerburgh eddyerburgh commented May 14, 2018

This change renders stubbed components with the component name and a stub suffix:

const wrapper = shallow({
  template: `<clock-component />`,
  components: {
    ClockComponent
  }
})

wrapper.html() // '<clock-component-stub></clock-component>'

Closes #410
Closes #28

@iztsv
Copy link
Contributor

iztsv commented May 15, 2018

@eddyerburgh thanks for the feature!

If ClockComponent uses a child component in template like <child-component :some-prop="someValue"></child-component>, will stubbed html be like:

'<clock-component-stub>
  <child-component some-prop="VALUE"></child-component>
</clock-component>'

?

@eddyerburgh
Copy link
Member Author

shallow does not render slots by defualt.

You could acheive that effect by manually stubbing both components:

const wrapper = mount(TestComponent, {
  stubs: [ 'ChildComponent', 'ClockComponent']
})

@eddyerburgh eddyerburgh merged commit dbf63bb into vuejs:dev May 15, 2018
@eddyerburgh eddyerburgh deleted the stub-components-with-name branch May 15, 2018 06:05
@trollepierre
Copy link
Contributor

I don't want to have to stub any SubChildComponent in my test.

@eddyerburgh
Copy link
Member Author

If you want this feature then create an issue and we can discuss it there

@stephane
Copy link

I'm a bit lost in the various related github issues/PR about stubs and I don't understand why I need to add a stubs: { 'VueComponent': '<div />' } to my tests which use shallowMount to avoid warnings.
From v3.0.0-beta.16 to beta.18

@38elements
Copy link
Contributor

38elements commented Jun 11, 2018

If you are concerned about it, I think it is better that you create an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants