@@ -63,13 +63,16 @@ const shouldNotStub = (type: ConcreteComponent) => doNotStubComponents.has(type)
6363export const addToDoNotStubComponents = ( type : ConcreteComponent ) =>
6464 doNotStubComponents . add ( type )
6565
66- const stringifySymbols = ( props : ComponentPropsOptions ) => {
66+ const normalizeStubProps = ( props : ComponentPropsOptions ) => {
6767 // props are always normalized to object syntax
6868 const $props = props as unknown as ComponentObjectPropsOptions
6969 return Object . keys ( $props ) . reduce ( ( acc , key ) => {
7070 if ( typeof $props [ key ] === 'symbol' ) {
7171 return { ...acc , [ key ] : $props [ key ] ?. toString ( ) }
7272 }
73+ if ( typeof $props [ key ] === 'function' ) {
74+ return { ...acc , [ key ] : '[Function]' }
75+ }
7376 return { ...acc , [ key ] : $props [ key ] }
7477 } , { } )
7578}
@@ -100,13 +103,11 @@ export const createStub = ({
100103 // causes an error.
101104 // Only a problem when shallow mounting. For this reason we iterate of the
102105 // props that will be passed and stringify any that are symbols.
103- const propsWithoutSymbols = stringifySymbols ( props )
106+ // Also having function text as attribute is useless and annoying so
107+ // we replace it with "[Function]""
108+ const stubProps = normalizeStubProps ( props )
104109
105- return h (
106- tag ,
107- propsWithoutSymbols ,
108- renderStubDefaultSlot ? slots : undefined
109- )
110+ return h ( tag , stubProps , renderStubDefaultSlot ? slots : undefined )
110111 }
111112 }
112113 } )
0 commit comments