Skip to content

Conversation

@iumehara
Copy link

References #35113

  • Overload toHaveCSS to take styles property (React.CSSProperties) type.
  • Extend Matchers interface in overrides-test.d.ts to include new signature

*
* @param styles CSS property names and values as an object.
*/
toHaveCSS(styles: CSSProperties, options?: { timeout?: number }): Promise<void>;
Copy link
Author

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?

Copy link
Member

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
Copy link
Member

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.

Copy link
Author

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';
Copy link
Member

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>;
Copy link
Member

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.

@github-actions
Copy link
Contributor

Test results for "tests 1"

32 failed
❌ [installation tests] › playwright-test-plugin.spec.ts:34 › npm: @playwright/test plugin should work @package-installations-ubuntu-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:48 › pnpm: @playwright/test plugin should work @package-installations-ubuntu-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:62 › yarn: @playwright/test plugin should work @package-installations-ubuntu-latest
❌ [installation tests] › typescript-types.spec.ts:18 › typescript types should work @package-installations-ubuntu-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:34 › npm: @playwright/test plugin should work @package-installations-windows-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:48 › pnpm: @playwright/test plugin should work @package-installations-windows-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:62 › yarn: @playwright/test plugin should work @package-installations-windows-latest
❌ [installation tests] › typescript-types.spec.ts:18 › typescript types should work @package-installations-windows-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:34 › npm: @playwright/test plugin should work @package-installations-macos-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:48 › pnpm: @playwright/test plugin should work @package-installations-macos-latest
❌ [installation tests] › playwright-test-plugin.spec.ts:62 › yarn: @playwright/test plugin should work @package-installations-macos-latest
❌ [installation tests] › typescript-types.spec.ts:18 › typescript types should work @package-installations-macos-latest
❌ [chromium-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @chromium-ubuntu-22.04-node24
❌ [chromium-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @chromium-ubuntu-22.04-node24
❌ [chromium-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @chromium-ubuntu-22.04-node24
❌ [chromium-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @chromium-ubuntu-22.04-node20
❌ [chromium-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @chromium-ubuntu-22.04-node20
❌ [chromium-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @chromium-ubuntu-22.04-node20
❌ [chromium-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @chromium-ubuntu-22.04-node22
❌ [chromium-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @chromium-ubuntu-22.04-node22
❌ [chromium-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @chromium-ubuntu-22.04-node22
❌ [firefox-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @firefox-ubuntu-22.04-node20
❌ [firefox-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @firefox-ubuntu-22.04-node20
❌ [firefox-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @firefox-ubuntu-22.04-node20
❌ [webkit-page] › page/expect-misc.spec.ts:522 › toHaveCSS › pass with React.CSSPProperties @webkit-ubuntu-22.04-node20
❌ [webkit-page] › page/expect-misc.spec.ts:528 › toHaveCSS › pass with React.CSSPProperties that are camelCase @webkit-ubuntu-22.04-node20
❌ [webkit-page] › page/expect-misc.spec.ts:534 › toHaveCSS › vendor React.CSSPProperties that are vendor-prefixed properties @webkit-ubuntu-22.04-node20
❌ [playwright-test] › playwright.spec.ts:877 › page.pause() should disable test timeout @macos-latest-node20-1
❌ [playwright-test] › runner.spec.ts:124 › should ignore subprocess creation error because of SIGINT @macos-latest-node20-2

2 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1082 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:426 › should work behind reverse proxy `@macos-latest-node20-2`

34369 passed, 688 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants