Skip to content

Does anybody have an idea of how can I test a component that used portal? #135

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
rzkhosroshahi opened this issue Apr 11, 2020 · 4 comments · Fixed by #136
Closed

Does anybody have an idea of how can I test a component that used portal? #135

rzkhosroshahi opened this issue Apr 11, 2020 · 4 comments · Fixed by #136
Labels

Comments

@rzkhosroshahi
Copy link

Hello.
I was trying to test a component that used portal-vue package. My issue is how can I ensure that a component inside the portal after clicking on something, it's rendered or exist.

@afontcu
Copy link
Member

afontcu commented Apr 12, 2020

Hi! Haven't used portal-vue before, fancy to open up a PR to set an example in this repo? 🤗

I guess you'll need 2 things: 1 to register portal-vue as a plugin:

import PortalVue from 'portal-vue'

test('...', () => {
  const { /* ... */ } = render(MyComp, {}, vue => vue.use(PortalVue))
})

and 2 to make sure you render the destination node in a custom container or baseElement. Again, I'm wild guessing since I haven't use it before :)

@afontcu
Copy link
Member

afontcu commented Apr 14, 2020

@rzkhosroshahi does #136 help you? 🤗

@rzkhosroshahi
Copy link
Author

@rzkhosroshahi does #136 help you? 🤗

Yes, thanks. it's really helpful ☺️. But in many real-world usages of the portal, the target portal there is not on the same component, so I think we need a component to wrap portal target and make sure this component renders the portal component.

@afontcu
Copy link
Member

afontcu commented May 20, 2020

🎉 This issue has been resolved in version 5.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants