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

fix: allow finding async component stubs by definition #2040

Merged
merged 1 commit into from
May 11, 2023

Conversation

xanf
Copy link
Collaborator

@xanf xanf commented Apr 30, 2023

This MR introduces an ability to find async component stubs by definition of underlying component, not just by wrapper itself

It also mimics @vue/test-utils@1.x behavior (well, kinda) - @vue/test-utils@1.x was unable to stub async components due to limitations in our patch approach, so "finding" always worked cause there were no stubs

@netlify
Copy link

netlify bot commented Apr 30, 2023

Deploy Preview for vue-test-utils-docs ready!

Name Link
🔨 Latest commit 15fb751
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-docs/deploys/644dea585510fb00088b219c
😎 Deploy Preview https://deploy-preview-2040--vue-test-utils-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -230,7 +243,8 @@ export function createStubComponentsTransformer({
return (
config.plugins.createStubs?.({
name: stubName,
component: type
component: type,
registerStub
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to provide an ability to mess with stubs (including async componentS) to the plugin system, so our plugins will be as capable as original createStub

@xanf
Copy link
Collaborator Author

xanf commented Apr 30, 2023

A bit of off-topic: happy to be back to active development here! We have a Vue.js 3 migration working group established in GitLab, so I will be happy to dedicate more time polishing things here and adding new cool features

@xanf xanf force-pushed the xanf-fix-shallow-mount-async-stubs branch 4 times, most recently from ba8bbb3 to 0546844 Compare April 30, 2023 04:08
@xanf xanf force-pushed the xanf-fix-shallow-mount-async-stubs branch from 0546844 to 15fb751 Compare April 30, 2023 04:11
const AsyncComponentWithoutName = defineAsyncComponent(async () => ({
template: '<span>AsyncComponent</span>'
}))

it('stubs async component with name', async () => {
const AsyncComponent = defineAsyncComponent(async () => ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move component definition inside test, because otherwise for second test __asyncResolved will be already defined from previous test

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Will give a bit of time for other reviewers to chime in, but tests look good.

@lmiller1990 lmiller1990 self-requested a review May 1, 2023 01:32
@cexbrayat cexbrayat merged commit 19ef115 into main May 11, 2023
@cexbrayat cexbrayat deleted the xanf-fix-shallow-mount-async-stubs branch May 11, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants