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
<anonymous-stub>
when running in Vitest + Vue 3 + Vue test utils { shallow: true }
#429
Comments
I'm facing the same issue here |
Can we see the |
<script setup>
</script>
<template>
<h1>Welcome to Vue.js 3</h1>
<ComplexA />
<ComplexB />
<ComplexC />
</template> |
Where the Complex[x] components are auto imported by unplugin vue components |
When Here is an example repo created with (It also fails with Vue Test Utils instead of Testing library) I'm not certain this is related to the first comment but at least there seems to be anything wrong with stubbing. |
I've opened a pr to solve this. |
Is this a similar issue in Vue 2 components? I'm seeing The PR above only applies to Vue3 - and not test utils for Vue2. |
I've resolved my issue, but it may be relevant here. For a Vue 2.7 project - running Vitest and shallow mounting caused all Vuetify components to be returned as To fix this, I had to disable This was pretty easy; In your export default defineConfig((configEnv) => ({
...,
plugins: [
vue2(),
Components({
resolvers: (configEnv.mode !== 'test') ? [VuetifyResolver()] : [],
...
] Then in your |
The thing is when stubbing a component that uses both I'm not sure if Vuetify uses |
Issue
When using single/multiple stubs option with vue test utils it renders the whole inner html of the component, like so:
When using with shallow mount the children component names become
anonymous-stub
:both cases are wrong, is there a way to make this work?
Use Case
When using tailwind you can catch style changes with snapshot tests. which I assume are much faster, than cypress component tests.
And you only want to see the styles of the current component under test, so as not to make tests fail when the child element styles update. to avoid flaky tests.
as a workaround you can import components directly, without using
unplugin-vue-components
and it works, but that obviously defeats the purpose of this plugin.Thank you
This plugin saves a ton of time and boilerplate would be awesome to get this little bit to work :)
I'd give it a show with a PR if you could just point me in the direction
The text was updated successfully, but these errors were encountered: