-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: include component and wrapper in return type for vue mount adapter #24479
feat: include component and wrapper in return type for vue mount adapter #24479
Conversation
Thanks for taking the time to open a PR!
|
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.
Couple small comments but looks and works great, will approve but would like to see comments addressed before merge
…ue-24342-update-vue-wrapper-return-type
Webkit system tests 🤷♂️ Everything else looks 💯 |
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.
Works great, chaining off the mount to get the wrapper works nice, putting the component instance in an alias and grabbing it there works nicely too. Probably no need for users to rely on Cypress.vueWrapper
any more which will be sweet.
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.
This PR already got merged while I was in the middle of reviewing, but will drop these comments here for future consideration.
// by returning undefined we keep the previous subject | ||
// which is the mounted 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.
Comment no longer applicable
): Cypress.Chainable<{ | ||
wrapper: VueWrapper<ComponentPublicInstance<V>> | ||
component: VueWrapper<ComponentPublicInstance<V>>['vm'] | ||
}> |
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.
Still working on my Typescript, but would it make sense to introduce a generic return type like:
type MountReturn<C> = {
wrapper: VueWrapper<C>
component: C
}
to use for the return of all the mount overloads?
Result
export function mount<V extends {}>(
originalComponent: {
new (...args: any[]): V
__vccOpts: any
},
options?: MountingOptions<any> & Record<string, any>
): Cypress.Chainable<MountReturn<V>>
Would that work for all the overload cases?
User facing changelog
Vue Mount adapter now returns an object with both the
VueWrapper
(wrapper
) and component instance (component
).Additional details
Part of CT GA.
Steps to test
You could do
const foo = cy.mount(SomeVueComponent)
then observe bothwrapper
andcomponent
properties are available on the returned value.wrapper
contains all of these methods from Vue Test Utils. Component contains various Vue related things.How has the user experience changed?
You can access the component instance, which is more in line with what other mount adapters do.
PR Tasks
cypress-documentation
? NOT YETtype definitions
?