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
[@testing-library/jest-dom] Add new type for toHaveStyle matcher #42022
Conversation
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
@lourenci Thank you for submitting this PR! 🔔 @gnapse @jgoz @smacpherson64 - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this @lourenci, just a couple minor suggestions from me
@@ -28,7 +28,7 @@ declare namespace jest { | |||
toHaveClass(...classNames: string[]): R; | |||
toHaveFocus(): R; | |||
toHaveFormValues(expectedValues: Record<string, unknown>): R; | |||
toHaveStyle(css: string): R; | |||
toHaveStyle(css: string | object): R; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be better expressed as string | Record<string, unknown>
similar to the one above.
@@ -22,6 +22,7 @@ expect(element).toHaveClass('cls1', 'cls2', 'cls3', 'cls4'); | |||
expect(element).toHaveFocus(); | |||
expect(element).toHaveFormValues({ foo: 'bar', baz: 1 }); | |||
expect(element).toHaveStyle('display: block'); | |||
expect(element).toHaveStyle({ display: 'block' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing, could you add another property that uses a different type, like width: 100
(just to verify that non-string values are also accepted)?
@lourenci One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. Thank you! |
🔔 @jgoz - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for doing this!
A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped! |
Update
toHaveStyle
matcher type according to testing-library/jest-dom#196.