Skip to content
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

toHaveStyleRule should intelligently ignore spaces in strings #385

Open
danielmariz opened this issue Jul 29, 2021 · 2 comments
Open

toHaveStyleRule should intelligently ignore spaces in strings #385

danielmariz opened this issue Jul 29, 2021 · 2 comments

Comments

@danielmariz
Copy link

danielmariz commented Jul 29, 2021

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"

@danielmariz
Copy link
Author

to get around it I had to do this ugly solution
expect(Node).toHaveStyleRule('font-family', text.heading.fontFamily!.split(', ').join(','))

@Termtime
Copy link

Termtime commented May 9, 2022

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, '');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants