I was writing some tests for a component that uses the React 16 <Fragment /> component and run into the Cannot convert a Symbol value to a string error when running the tests. I believe that the issue is that React.Fragment uses a Symbol as displayName and the ReactTestWrapper and ShallowTestWrapperinspect method fails to convert this Symbol into a string.
An example of a failing test could be:
const SymbolComponent = class extends React.Component {
render () {
return (<div />)
}
}
SymbolComponent.displayName = Symbol('SymbolComponent')
// The failing test
it('has a div', () => {
expect(shallow(<SymbolComponent />).find('div').to.exist;
})
I think I have a fix for the Symbol issue. I'm gonna submit a PR soon with it and with some real test cases.
I was writing some tests for a component that uses the React 16
<Fragment />
component and run into theCannot convert a Symbol value to a string
error when running the tests. I believe that the issue is thatReact.Fragment
uses a Symbol as displayName and theReactTestWrapper
andShallowTestWrapper
inspect
method fails to convert this Symbol into a string.An example of a failing test could be:
I think I have a fix for the
Symbol
issue. I'm gonna submit a PR soon with it and with some real test cases.