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

Support stubs and make sure working with Vue 2.7 #2048

Open
lmiller1990 opened this issue Jan 17, 2023 · 3 comments
Open

Support stubs and make sure working with Vue 2.7 #2048

lmiller1990 opened this issue Jan 17, 2023 · 3 comments
Labels

Comments

@lmiller1990
Copy link
Member

Now Vue 2.7 has script setup, we need some test cases around this. I think stubs doesn't work: cypress-io/cypress#25450

@johndegey
Copy link

johndegey commented Feb 28, 2023

Hello,

I have a simple base project with vite - vue2.7 - vitest - testing-library
I use unplugin-vue-component (essentially in another project with vuetify 2)
It uses composition api, all imports have been removed from script setup.
Vite as a config for test (remove the use of unplugin-vue-component).

I manage to get it work only if I stub all child component in the test file.
If you don't, vue warn about all the unknown child components.
If you add the import in the script setup, stubbing does not work.

https://github.com/johndegey/vite-vitest-vue2

The branch 'stubbing' does not have unplugin-vue-component
The branch 'stubbing_work' have it.

Hope this could help you...

Best

John

Edit: part of my workaround came from here
unplugin/unplugin-vue-components#429 (comment)

@lmiller1990
Copy link
Member Author

Hi!

What should I do? I checked out stubbing and ran the tests but they all work - no warning/error. What am I missing?

@johndegey
Copy link

Hi,

Sorry, i'm terrible at explaining myself ;)

Try the main branch

  1. edit TheWelcome.spec.js, add stub for WelcomeItem, run test and stubbing does not work.
  2. edit TheWelcome.vue, comment the import for WelcomeItem, run the test, stubbing works

In the branch stubbing_work :

  1. you have to use stubbing for all child component, without that, it won't work without warning,
    => there is no import in .vue sfc component
  2. if you add the import in TheWelcome.vue, stubbing does not work anymore

Seems that the import in the script setup automaticaly failes the stubbing.

Best
John

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

No branches or pull requests

3 participants