jest-styled-components
jest-styled-components copied to clipboard
toHaveStyleRule should intelligently ignore spaces in strings
trafficstars
I am having the same issue as described in Issue#89
the value is correct but somehow the styled-components remove all spaces in the value and does not get strictly compared to the same value passed
` "Value mismatch for property 'font-family'"
Expected
"font-family: europa, -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif"
Received:
"font-family: europa,-apple-system,system-ui,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif"
> 72 | expect(Node).toHaveStyleRule('font-family', text.heading.fontFamily)
`
Versions: "styled-components": "^5.2.3" "jest-styled-components": "^7.0.3"
to get around it I had to do this ugly solution
expect(Node).toHaveStyleRule('font-family', text.heading.fontFamily!.split(', ').join(','))
Similar issue, in my case I was getting:
Expected (This is actually what I was sending, it was pretty confusing)
"background-color: rgb(24, 107, 237)"
Received: (This is what was actually expected)
"background-color: rgb(24,107,237)"
For me to get it working I had to do something different
value.toString().replace(/\s/g, '');