jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

fix: toHaveStyle assertion with invalid style (#564)

Open EduardoSimon opened this issue 1 year ago • 1 comments

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

EduardoSimon avatar Feb 16 '24 22:02 EduardoSimon