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

chore: add pageSnapshot option #34669

Merged
merged 9 commits into from
Feb 11, 2025
Merged

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Feb 7, 2025

As discussed yesterday, this makes pageSnapshot available to configure as an option.

Also adds a 5s timeout to the snapshot taking.

Follow-up to #34573.

@Skn0tt Skn0tt requested review from yury-s and Copilot February 7, 2025 08:11
@Skn0tt Skn0tt self-assigned this Feb 7, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@@ -640,7 +640,7 @@ class ArtifactsRecorder {
await page.screenshot({ ...screenshotOptions, timeout: 5000, path, caret: 'initial' });
});

this._pageSnapshotRecorder = new SnapshotRecorder(this, pageSnapshot, 'pageSnapshot', 'text/plain', '.ariasnapshot', async (page, path) => {
this._pageSnapshotRecorder = new SnapshotRecorder(this, pageSnapshot ?? 'only-on-failure', 'pageSnapshot', 'text/plain', '.ariasnapshot', async (page, path) => {
Copy link
Preview

Copilot AI Feb 7, 2025

Choose a reason for hiding this comment

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

Consider adding a normalization function for pageSnapshot similar to normalizeScreenshotMode to ensure consistent handling of the pageSnapshot option.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno Copilot, let's add that when we need it. ScreenshotMode is a little bit more complicated of a type than pageSnapshot.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

* since: v1.10
- type: <[PageSnapshotMode]<"off"|"on"|"only-on-failure">>

Whether to automatically capture a ARIA snapshot of the page after each test. Defaults to `'only-on-failure'`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Whether to automatically capture a ARIA snapshot of the page after each test. Defaults to `'only-on-failure'`.
Whether to automatically capture a ARIA snapshot of the page after each test. Defaults to `'off'`.

I don't think we want it on by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

My recollection of when we discussed this is to enable it by default - let's discuss tonight.

@@ -128,7 +128,7 @@ test('should work with screenshot: on', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
...testFiles,
'playwright.config.ts': `
module.exports = { use: { screenshot: 'on' } };
module.exports = { use: { screenshot: 'on', pageSnapshot: 'off' } };
Copy link
Member

Choose a reason for hiding this comment

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

Why did screenshot and trace tests change, let's revert this part?

Copy link
Member Author

Choose a reason for hiding this comment

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

if pageSnapshot is on by default, it means that there's more attachments. all the changed tests assert on attachments, so they have to change. the easiest is to disable pageSnapshot, that way no assertions need to be changed.

@@ -485,7 +485,7 @@ test('should work with video: retain-on-failure', async ({ runInlineTest }) => {
test('should work with video: on-first-retry', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = { use: { video: 'on-first-retry' }, retries: 1, name: 'chromium' };
module.exports = { use: { video: 'on-first-retry', pageSnapshot: 'off' }, retries: 1, name: 'chromium' };
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@@ -59,7 +59,7 @@ test('should stop tracing with trace: on-first-retry, when not retrying', async
test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = { use: { trace: 'on' } };
module.exports = { use: { trace: 'on', pageSnapshot: 'off' } };
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Co-authored-by: Yury Semikhatsky <[email protected]>
Signed-off-by: Simon Knott <[email protected]>
Copy link
Contributor

Test results for "tests 1"

10 flaky ⚠️ [chromium-page] › tests/page/page-event-request.spec.ts:123:3 › should report navigation requests and responses handled by service worker @chromium-ubuntu-22.04-node20
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:403:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [chromium-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @ubuntu-20.04-chromium-tip-of-tree
⚠️ [webkit-library] › tests/library/browsercontext-clearcookies.spec.ts:92:3 › should remove cookies by domain @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-leaks.spec.ts:82:5 › click should not leak @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-leaks.spec.ts:107:5 › fill should not leak @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-leaks.spec.ts:161:5 › waitFor should not leak @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-screenshot.spec.ts:224:5 › page screenshot › should take fullPage screenshots and mask elements outside of it @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-set-input-files.spec.ts:245:3 › should upload large file with relative path @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › tests/ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

37840 passed, 654 skipped
✔️✔️✔️

Merge workflow run.

@yury-s yury-s merged commit 8ed2f43 into microsoft:main Feb 11, 2025
29 checks passed
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