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(e2e): coverage #6611

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/vkui/src/testing/e2e/index.playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

// 1. Расширяем Playwright под свои нужды.
import * as fs from 'node:fs/promises';
import { devices, expect, test as testBase } from '@playwright/experimental-ct-react';
import type { PlaywrightTestConfig } from '@playwright/test';
import { screenshotWithClipToContent } from './screenshotWithClipToContent';
Expand Down Expand Up @@ -55,7 +56,7 @@
},
expectCallCount,
);
expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot(

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 3/10)

[vkcom (chromium) • light] › components/PanelHeader/PanelHeader.e2e.tsx:9:5 › PanelHeader

2) [vkcom (chromium) • light] › components/PanelHeader/PanelHeader.e2e.tsx:9:5 › PanelHeader ───── Error: Screenshot comparison failed: Expected an image 413px by 464px, received 391px by 456px. 7673 pixels (ratio 0.05 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/PanelHeader/__image_snapshots__/panelheader-vkcom-chromium-light-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-PanelHeader-PanelHeader.e2e.tsx-PanelHeader-vkcom-chromium-•-light/panelheader-vkcom-chromium-light-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-PanelHeader-PanelHeader.e2e.tsx-PanelHeader-vkcom-chromium-•-light/panelheader-vkcom-chromium-light-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/PanelHeader/PanelHeader.e2e.tsx:15:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 3/10)

[vkcom (chromium) • light] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea

3) [vkcom (chromium) • light] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea ────────────── Error: Screenshot comparison failed: Expected an image 1193px by 1435px, received 1077px by 978px. 512323 pixels (ratio 0.30 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/__image_snapshots__/textarea-vkcom-chromium-light-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-vkcom-chromium-•-light/textarea-vkcom-chromium-light-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-vkcom-chromium-•-light/textarea-vkcom-chromium-light-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/Textarea.e2e.tsx:8:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 6/10)

[android (chromium) • dark] › components/OnboardingTooltip/OnboardingTooltip.e2e.tsx:5:5 › OnboardingTooltip

2) [android (chromium) • dark] › components/OnboardingTooltip/OnboardingTooltip.e2e.tsx:5:5 › OnboardingTooltip Error: Screenshot comparison failed: Expected an image 320px by 1264px, received 320px by 1252px. 3834 pixels (ratio 0.01 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/OnboardingTooltip/__image_snapshots__/onboardingtooltip-android-chromium-dark-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-OnboardingTooltip-OnboardingTooltip.e2e.tsx-OnboardingTooltip-android-chromium-•-dark/onboardingtooltip-android-chromium-dark-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-OnboardingTooltip-OnboardingTooltip.e2e.tsx-OnboardingTooltip-android-chromium-•-dark/onboardingtooltip-android-chromium-dark-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/OnboardingTooltip/OnboardingTooltip.e2e.tsx:11:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 6/10)

[android (chromium) • dark] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea

3) [android (chromium) • dark] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea ───────────── Error: Screenshot comparison failed: Expected an image 320px by 1991px, received 320px by 1408px. 176259 pixels (ratio 0.28 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/__image_snapshots__/textarea-android-chromium-dark-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-android-chromium-•-dark/textarea-android-chromium-dark-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-android-chromium-•-dark/textarea-android-chromium-dark-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/Textarea.e2e.tsx:8:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 6/10)

[android (chromium) • dark] › components/Typography/Caption/Caption.e2e.tsx:5:5 › Caption

4) [android (chromium) • dark] › components/Typography/Caption/Caption.e2e.tsx:5:5 › Caption ───── Error: Screenshot comparison failed: Expected an image 320px by 1271px, received 320px by 1188px. 25375 pixels (ratio 0.07 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/Typography/Caption/__image_snapshots__/caption-android-chromium-dark-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Typography-Caption-Caption.e2e.tsx-Caption-android-chromium-•-dark/caption-android-chromium-dark-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Typography-Caption-Caption.e2e.tsx-Caption-android-chromium-•-dark/caption-android-chromium-dark-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/Typography/Caption/Caption.e2e.tsx:7:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 6/10)

[android (chromium) • dark] › components/Typography/Footnote/Footnote.e2e.tsx:5:5 › Footnote

5) [android (chromium) • dark] › components/Typography/Footnote/Footnote.e2e.tsx:5:5 › Footnote ── Error: Screenshot comparison failed: Expected an image 320px by 462px, received 320px by 452px. 3200 pixels (ratio 0.03 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/Typography/Footnote/__image_snapshots__/footnote-android-chromium-dark-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Typography-Footnote-Footnote.e2e.tsx-Footnote-android-chromium-•-dark/footnote-android-chromium-dark-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Typography-Footnote-Footnote.e2e.tsx-Footnote-android-chromium-•-dark/footnote-android-chromium-dark-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/Typography/Footnote/Footnote.e2e.tsx:7:3

Check failure on line 59 in packages/vkui/src/testing/e2e/index.playwright.ts

View workflow job for this annotation

GitHub Actions / Call reusable workflow / Run e2e tests for (shard 8/10)

[vkcom (chromium) • dark] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea

2) [vkcom (chromium) • dark] › components/Textarea/Textarea.e2e.tsx:6:5 › Textarea ─────────────── Error: Screenshot comparison failed: Expected an image 1193px by 1435px, received 1077px by 978px. 646629 pixels (ratio 0.38 of all image pixels) are different. Expected: /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/__image_snapshots__/textarea-vkcom-chromium-dark-1-snap.png Received: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-vkcom-chromium-•-dark/textarea-vkcom-chromium-dark-1-snap-actual.png Diff: /__w/VKUI/VKUI/packages/vkui/__diff_output__/components-Textarea-Textarea.e2e.tsx-Textarea-vkcom-chromium-•-dark/textarea-vkcom-chromium-dark-1-snap-diff.png at testing/e2e/index.playwright.ts:59 57 | expectCallCount, 58 | ); > 59 | expect(await screenshotWithClipToContent(page, options, browserName)).toMatchSnapshot( | ^ 60 | customScreenshotName, 61 | toMatchSnapshot, 62 | ); at result (/__w/VKUI/VKUI/packages/vkui/src/testing/e2e/index.playwright.ts:59:77) at /__w/VKUI/VKUI/packages/vkui/src/components/Textarea/Textarea.e2e.tsx:8:3
customScreenshotName,
toMatchSnapshot,
);
Expand Down Expand Up @@ -103,6 +104,40 @@
},
{ auto: true },
],
page: async ({ page, browserName }, use, testInfo) => {
if (browserName !== 'chromium') {
return use(page);
}

await page.coverage.startJSCoverage({
resetOnNavigation: false,
});
await page.coverage.startCSSCoverage({
resetOnNavigation: false,
});

await use(page);

const resultJS = await page.coverage.stopJSCoverage();
const resultCSS = await page.coverage.stopCSSCoverage();

const resultJSFile = testInfo.outputPath('v8-coverage-js.json');
const resultCSSFile = testInfo.outputPath('v8-coverage-css.json');

await fs.writeFile(resultJSFile, JSON.stringify(resultJS));
await fs.writeFile(resultCSSFile, JSON.stringify(resultCSS));

testInfo.attachments.push({
name: 'v8-coverage-js.json',
contentType: 'application/json',
path: resultJSFile,
});
testInfo.attachments.push({
name: 'v8-coverage-css.json',
contentType: 'application/json',
path: resultCSSFile,
});
},
});

// 2. Ре-экспортируем нужные модули, типы и константы.
Expand Down
Loading