-
Notifications
You must be signed in to change notification settings - Fork 668
add createStub
function
#678
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
Conversation
}) | ||
``` | ||
|
||
Where `Child` is a component with `name: 'Child'`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the component needs to have the name child. It should use the constructor. Can you check if the example works for a component without a name?
@@ -0,0 +1,7 @@ | |||
export default function createStub (name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is better to add flow type as below.
export default function createStub (name: string): Component {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and add // @flow
to the top of the file
Got caught up, hopefully by tomorrow can get this done. For TODO:
|
Yes the slot default is a good idea. If you'd like you could also add this feature to the default stub rendered in the add-stubs file, so that all default stubs render $slots. |
Would you please tell me difference between this feature and a string value in |
@38elements You can use these stubs for unnamed components without importing the component: const SomeStub = createStub()
const wrapper = mount(TestComponent, {
SomeComponent: SomeStub
})
wrapper.find(SomeStub) Although this will become irrelevant with #651 🤔 |
Should we just close this since it is more or less super-seeded by #651 ? |
Regarding #651
This PR adds a
createStub
method, which creates a component as such:Useful for making it clear what is going on when you call
find
andfindAll
.