nuxt / test-utils

๐Ÿงช Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
287 stars 75 forks source link

`renderSuspended` does not handle `onEvent` notation #731

Open pguilbert opened 5 months ago

pguilbert commented 5 months ago

Environment


Reproduction

https://stackblitz.com/edit/github-5sxamx?file=components%2FMyComponent.nuxt.spec.ts

Describe the bug

One convenient method for verifying that a component has emitted the expected events is to pass a prop with "onX" that contain a mocked function:

const onTest = vi.fn()
render(MyComponent, {
  props: { title: 'Test title', onTest},
});
expect(onTest).toHaveBeenCalled(); โœ…

While this works fine with the testing library render helper, Nuxt's renderSuspended fails to pass the event handler to the component:

await renderSuspended(MyComponent, {
  props: { title: 'Test title', onTest },
});
expect(onTest).toHaveBeenCalled(); โŒ

Additional context

No response

Logs

No response