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
Enzyme .text() selector fails on emotion styled components #733
Comments
Thank you for your report! export function App() {
return <div>Hello CodeSandbox</div>;
}
const wrapper = shallow(<App />);
console.log(wrapper.text()); You should access children of wrapper to get a valid text node, instead of accessing it directly. |
Sorry. That example was probably a little too simplistic. This example I think better illustrates the issue: CodeSandbox 2: https://codesandbox.io/s/qkl68mk86w |
@tennisgent If you introduce a new component like export function X({ className, children }) {
return (
<div className={className}>{children}</div>
)
}
export function Simple() {
return (
<div className="container">
Hello CodeSandbox
<X className="nested">Blue</X>
</div>
);
} You will see that both tests fail, even after changing test to |
Sorry for the confusion. I apparently didn't understand how Enzyme is handling custom components. Thanks for setting me straight. 👍 |
emotion
version: 9.2.3react
version: 16.3.2Relevant code.
What you did:
I am trying to test that a given emotion styled-component has the proper text as children using Enzyme. I have written the above test and it fails with the error message below:
What happened:
Reproduction:
Here is the error in CodeSandbox: https://codesandbox.io/s/5zkq790j74
Interestingly, if I call
wrapper.debug()
, it seems to output the proper markup:The text was updated successfully, but these errors were encountered: