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

mountSuspended fails to pass attributes when inheritAttrs is false #1092

Closed
romhml opened this issue Jan 22, 2025 · 0 comments · Fixed by #1108
Closed

mountSuspended fails to pass attributes when inheritAttrs is false #1092

romhml opened this issue Jan 22, 2025 · 0 comments · Fixed by #1108

Comments

@romhml
Copy link
Contributor

romhml commented Jan 22, 2025

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

Logs

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

Successfully merging a pull request may close this issue.

1 participant