Jest-dom: `toHaveStyle` support passing an object

Created on 7 Jan 2020  路  5Comments  路  Source: testing-library/jest-dom

Describe the feature you'd like:

Pass an object to the toHaveStyle matcher. The object shape would be the same as the style object in React.

This would allow the tests to match the code conventions of a project using object-based CSS-in-JS and offer type checking/code completion.

Teachability, Documentation, Adoption, Migration Strategy:

Offered as an alternative for the string function signature.

expect(element).toHaveStyle({
  padding: '10px',
  marginTop: 5
});
enhancement good first issue released

Most helpful comment

Please do crack on! I'm not going to have time for a couple of weeks, I can loop back around then and start if you haven't opened a PR.

All 5 comments

I'm in favor. I personally really like objects as styles. 馃憤

I'm in favor too. And sorry for having left this issue forgotten. Should've replied earlier.

@tom-sherman are you interested and able to contribute with this enhancement? Otherwise I'd say we're open to have anyone else contribute. I may be able to take it eventually if no one jumps in.

I can handle this if @tom-sherman doesn't want to.

Please do crack on! I'm not going to have time for a couple of weeks, I can loop back around then and start if you haven't opened a PR.

:tada: This issue has been resolved in version 5.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benmonro picture benmonro  路  3Comments

BurntCaramel picture BurntCaramel  路  5Comments

gnapse picture gnapse  路  3Comments

srittau picture srittau  路  5Comments

thomaslombart picture thomaslombart  路  6Comments