You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently updated styled-components of my project to the latest version ("jest-styled-components": "^7.0.2" & "styled-components": "^5.1.1").
Although the great majority of my tests pass, some of them have the following error message: No style rules found on passed Component.
After investigation, I noticed the only failing tests were the one where the styled components is exported directly, which are styled-components created with the babel macro. I tried to create those components without the babel macro and the tests are passing.
importReactfrom'react'import{shallow}from'enzyme'import{Tag,TagMacro}from'./Tag'describe('Tag',()=>{it('no macro - has the right color',()=>{// test passes, no babel macroexpect(shallow(<Tag/>)).toHaveStyleRule('background-color','orange')})it('macro - has the right color',()=>{// fail, with the babel macroexpect(shallow(<TagMacro/>)).toHaveStyleRule('background-color','orange')})it('macro - has the right color',()=>{// test passes, with a work aroundfunctionWrapperTag(){return<TagMacro/>}expect(shallow(<WrapperTag/>).find(TagMacro)).toHaveStyleRule('background-color','orange')})})
I'm using Enzyme, React and Styled-components macro. All with the latest version.
The text was updated successfully, but these errors were encountered:
dorianamouroux
changed the title
No style rules when testing directly a styled components
No style rules when testing directly a styled components from babel macro
Jun 4, 2020
I'm currently updated
styled-components
of my project to the latest version ("jest-styled-components": "^7.0.2"
&"styled-components": "^5.1.1"
).Although the great majority of my tests pass, some of them have the following error message:
No style rules found on passed Component
.After investigation, I noticed the only failing tests were the one where the styled components is exported directly, which are styled-components created with the babel macro. I tried to create those components without the babel macro and the tests are passing.
I created a repository to reproduce the bug:
https://github.com/dorianamouroux/styled-components-test-issue
The component:
The spec:
I'm using Enzyme, React and Styled-components macro. All with the latest version.
The text was updated successfully, but these errors were encountered: