jest-dom
jest-dom copied to clipboard
fix: toHaveStyle assertion with invalid style (#564)
What:
Given an invalid declaration such as fontSize: 8
, due to the missing unit, the toHaveStyle
matcher should not pass the following test:
render(<div data-testid="element" style={{ fontSize: 8 }} />)
expect(screen.getByTestId('element')).toHaveStyle({ fontSize: 1 })
Why:
Refer to the original issue for more info: #564
How:
This PR fixes #564 by adding a more restrictive guard in the matcher's logic.
Checklist:
- [ ] Documentation N/A
- [x] Tests
- [ ] Updated Type Definitions N/A
- [x] Ready to be merged