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

toHaveStyle failing for upper cased style rules in version 4.1.2 #148

Closed
ppiyush13 opened this issue Oct 24, 2019 · 7 comments · Fixed by #154
Closed

toHaveStyle failing for upper cased style rules in version 4.1.2 #148

ppiyush13 opened this issue Oct 24, 2019 · 7 comments · Fixed by #154
Labels

Comments

@ppiyush13
Copy link

@testing-library/jest-dom library version: 4.1.2

Consider the following div element:

<div id="simple" style="align-items:center">Simple Div</div>

I am using toHaveStyle to match CSS style rules as shown below

const div = document.querySelector("#simple");

expect(div).toHaveStyle('Align-items:center;');

Expected:
It should not throw error and proceed ahead

Actual:
It fails.

But below works fine

const div = document.querySelector("#simple");

expect(div).toHaveStyle('align-items:center;');

Seems that toHaveStyle needs CSS rules to be in lower case.
But this was working as expected in version 4.1.1

@ruhaise
Copy link

ruhaise commented Oct 28, 2019

@ppiyush13 could you please try to put a codesandbox to reproduce this issue, im having some similar issue and i just wanted to confirm this

@ppiyush13
Copy link
Author

@ruhaise
here is the codesandbox link https://codesandbox.io/s/jest-dom-issue-148-9lzc6

@connormeredith
Copy link
Contributor

@ppiyush13 can you let me know if #154 fixes your issue?

@ppiyush13
Copy link
Author

@connormeredith I looked at the pull request https://github.com/testing-library/jest-dom/pull/154/files . I think it should fix this issue

@gnapse
Copy link
Member

gnapse commented Oct 31, 2019

I'll be approving the PR because I confirmed css selectors are not case sensitive (to my surprise). I just wonder why are you specifying them in your tests with capitalized names? 🤔

@gnapse
Copy link
Member

gnapse commented Oct 31, 2019

🎉 This issue has been resolved in version 4.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ppiyush13
Copy link
Author

@gnapse no specific reason for specifying CSS rules in upper case. I could have went ahead by making it lower case. I opened this issue because it was working fine till version 4.1.1

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

Successfully merging a pull request may close this issue.

4 participants