-
Notifications
You must be signed in to change notification settings - Fork 4.9k
feat(toHaveCss) Overload toHaveCSS matcher to accept React.CSSProperties #38617
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
base: main
Are you sure you want to change the base?
feat(toHaveCss) Overload toHaveCSS matcher to accept React.CSSProperties #38617
Conversation
| * | ||
| * @param styles CSS property names and values as an object. | ||
| */ | ||
| toHaveCSS(styles: CSSProperties, options?: { timeout?: number }): Promise<void>; |
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 wasn't 100% on how the build process works. Is this the correct place to add the extension?
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.
Yes, this is correct place for type overrides. But ideally you just update the parameter type definition in docs/src/api/class-locatorassertions.md and wouldn't need custom types here.
|
|
||
| CSS property value. | ||
|
|
||
| ### param: LocatorAssertions.toHaveCSS.styles |
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.
You need to update value parameter's type to accept React.CSSProperties rather than add a new parameter.
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.
What makes this a little awkward is that this feature requires less parameters than before. ie. one parameter for the pojo CSS Properties, as opposed to the two parameters for the name and the value.
The current PR handles multiple possible inputs for the first argument (either the name string, or the React.CSSProperties), albeit with some questionable naming.
Should I just delete the overload signatures, and use the main function definition that has union parameters?
| import type { TestStepInfoImpl } from '../worker/testInfo'; | ||
| import type { APIResponse, Locator, Frame, Page } from 'playwright-core'; | ||
| import type { FrameExpectParams } from 'playwright-core/lib/client/types'; | ||
| import type { CSSProperties } from 'react'; |
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.
We can't afford a dependency on 'react'. Can you make it work in a best effort fashion similar to what we do for Electron types today? Basically, if the user has 'react' in their project, strong typecheck would apply. Otherwise accepted type should be string only.
| * | ||
| * @param styles CSS property names and values as an object. | ||
| */ | ||
| toHaveCSS(styles: CSSProperties, options?: { timeout?: number }): Promise<void>; |
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.
Yes, this is correct place for type overrides. But ideally you just update the parameter type definition in docs/src/api/class-locatorassertions.md and wouldn't need custom types here.
Test results for "tests 1"32 failed 2 flaky34369 passed, 688 skipped Merge workflow run. |
References #35113
overrides-test.d.tsto include new signature