-
-
Notifications
You must be signed in to change notification settings - Fork 71
Cannot convert a Symbol value to a string #215
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
Conversation
src/ReactTestWrapper.js
Outdated
| inspect () { | ||
| const root = this.root() | ||
| const name = root.name() || '???' | ||
| const name = (root.name() || '???').toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String(x) is always better than x.toString()
src/ShallowTestWrapper.js
Outdated
| const rootInstance = root.instance() | ||
| const rootType = rootInstance && rootInstance.constructor | ||
| const name = rootType ? getDisplayName(rootType) : (root.name() || '???') | ||
| const name = (rootType ? getDisplayName(rootType) : (root.name() || '???')).toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here
test/inspect.test.js
Outdated
| expect(String(inspect(shallow(<DisplayNameSyntax />).find('div')))).to.equal('the node in <DisplayNameSyntax />') | ||
| expect(String(inspect(shallow(<DisplayNameSyntax />).find('span')))).to.equal('the node in <DisplayNameSyntax />') | ||
| expect(String(inspect(shallow(<div />)))).to.equal('<div />') | ||
| expect(String(inspect(shallow(<SymbolComponent />)))).to.equal(`<${SymbolComponent.displayName.toString()} />`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
|
Oh, thanks for fixing! I wish there would be a new release with this fix included... |
Always convert the name to string when in
ShallowTestWrapper#inspectandReactTestWrapper#inspectso it still works for components that have aSymbolas adisplayName.Since
nameis always gonna be defined I think it is fine to just call.toString, although some logic could be added to look for justSymbolinstances.#214