Skip to content
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

test(Button): improve button tests #1756

Merged
merged 10 commits into from
Aug 23, 2024
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion playwright/core/expectScreenshotFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
const expectScreenshot: ExpectScreenshotFixture = async ({
component,
screenshotName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove screenshotName (it's not used anywhere), and instead of screenshotPostfix introduce nameSuffix option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

image

screenshotPostfix,
Copy link
Contributor Author

@itwillwork itwillwork Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For multiple screenshots per test

 test(........., () => {
      await expectScreenshot();

      //...

      await expectScreenshot({
          screenshotPostfix: 'after hover',
      });
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe screenshotNameSuffix?

...pageScreenshotOptions
} = {}) => {
const captureScreenshot = async (theme: string) => {
Expand All @@ -25,7 +26,9 @@ export const expectScreenshotFixture: PlaywrightFixture<ExpectScreenshotFixture>
});
};

const nameScreenshot = testInfo.titlePath.slice(1).join(' ');
const nameScreenshot =
testInfo.titlePath.slice(1).join(' ') +
(screenshotPostfix ? ` ${screenshotPostfix}` : '');

expect(await captureScreenshot('dark')).toMatchSnapshot({
name: `${screenshotName || nameScreenshot} dark.png`,
Expand Down
2 changes: 2 additions & 0 deletions playwright/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export const test = base.extend<Fixtures>({
mount: mountFixture,
expectScreenshot: expectScreenshotFixture,
});

export {expect} from '@playwright/experimental-ct-react';
amje marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions playwright/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface ExpectScreenshotFixture {
}

interface CaptureScreenshotParams extends PageScreenshotOptions {
screenshotPostfix?: string;
screenshotName?: string;
component?: Locator;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading