Skip to content

shallowMount stub behavior is inconsistent between options object component and constructor one #1186

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

Closed
ktsn opened this issue Mar 14, 2019 · 2 comments

Comments

@ktsn
Copy link
Member

ktsn commented Mar 14, 2019

Version

1.0.0-beta.29

Reproduction link

https://github.com/ktsn/vue-test-utils-shallow-stub-issue

Steps to reproduce

  1. yarn install
  2. yarn test
  3. You will see the inconsistency of stub behavior between options object component and constructor component.

What is expected?

Both shallowMounted component renders the same html.

What is actually happening?

The child of stubbed component (GrandChild) is stubbed if Child is passed as options object while not stubbed if Child is constructor.


I'm not sure which behavior is intended but I think the behavior with options object stub is more useful. Because sometimes I want to control which child components should be stubs or not by passing the component itself to stubs option. And in that case, I will not expect the child component be rendered entirely (grandchildren components should be replaced with stubs).

@eddyerburgh
Copy link
Member

This is actually undefined behavior that I should have considered.

I think the behavior of the constructor is more intuitive, but it might require changing the current shallow rendering logic.

@ebisbe
Copy link
Collaborator

ebisbe commented Feb 15, 2023

#1564 (comment)

@ebisbe ebisbe closed this as completed Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants