Closed
Description
Environment
- Operating System: Linux
- Node Version: v20.15.1
- Nuxt Version: 3.15.2
- CLI Version: 3.20.0
- Nitro Version: 2.10.4
- Package Manager: [email protected]
- Builder: -
- User Config: compatibilityDate, devtools, modules
- Runtime Modules: @nuxt/test-utils/[email protected]
- Build Modules: -
Reproduction
https://stackblitz.com/~/github.com/romhml/nuxt-test-repro
Describe the bug
Hi! There seems to be an issue when using mountSuspended
on a component with defineOptions({ inheritAttrs: false })
where attributes bound using v-bind="$attrs"
are missing.
For instance with this component:
<template>
<div>
<button v-bind="$attrs"> <slot /> </button>
</div>
</template>
<script setup lang="ts">
defineOptions({ inheritAttrs: false })
</script>
The first test below using mountSuspended
will fail because the attribute is missing, whereas the test using mount
from @vue/test-utils
works as expected.
import { test, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import ExampleComponent from '~/app/components/ExampleComponent.vue'
test('with mountSuspended', async () => {
const wrapper = await mountSuspended(ExampleComponent, { attrs: { 'aria-label': 'Aria Label' } })
expect(wrapper.find('[aria-label="Aria Label"]').exists()).toBe(true)
})
test('with mount', () => {
const wrapper = mount(ExampleComponent, { attrs: { 'aria-label': 'Aria Label' } })
expect(wrapper.find('[aria-label="Aria Label"]').exists()).toBe(true)
})
Additional context
No response
Activity