Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vnodeTransformers/stubComponentsTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const normalizeStubProps = (props: ComponentPropsOptions) => {
const $props = props as unknown as ComponentObjectPropsOptions
return Object.keys($props).reduce((acc, key) => {
if (typeof $props[key] === 'symbol') {
return { ...acc, [key]: $props[key]?.toString() }
return { ...acc, [key]: [$props[key]?.toString()] }
}
if (typeof $props[key] === 'function') {
return { ...acc, [key]: '[Function]' }
return { ...acc, [key]: ['[Function]'] }
}
return { ...acc, [key]: $props[key] }
}, {})
Expand Down
16 changes: 15 additions & 1 deletion tests/props.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
import { mount, shallowMount, VueWrapper } from '../src'
import WithProps from './components/WithProps.vue'
import PropWithSymbol from './components/PropWithSymbol.vue'
Expand Down Expand Up @@ -318,6 +318,20 @@ describe('props', () => {
expect(wrapper.html()).toBe('<comp-stub fn="[Function]"></comp-stub>')
})

// https://github.com/vuejs/test-utils/issues/2411
it('should not warn on stringify props in stubs', () => {
const spy = vi.spyOn(console, 'warn').mockReturnValue()
const Comp = defineComponent({
name: 'Comp',
template: `<transition @enter="() => {}"></transition>`
})

const wrapper = mount(Comp)

expect(wrapper.html()).toContain('<transition-stub')
expect(spy).not.toHaveBeenCalled()
})

describe('edge case with symbol props and stubs', () => {
it('works with Symbol as default', () => {
const Comp = defineComponent({
Expand Down