Skip to content

feat(playwright-html-report): Added snippet parameter to playwright config #36464

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

agamjots05
Copy link

fixes #34052
Before
image

After (Disabling Snippets through playwright config)
New Playwright Config Change:
image

HTML - Report Disabling Snippets
image

This comment has been minimized.

Copy link
Member

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

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

looking good, thanks for the PR! I left a pointer about the test.

// 3. Open the HTML report and confirm that the code snippet is NOT present for the failure.
// 4. Change snippets: true and confirm the snippet IS present.

test('should fail and allow visual check of HTML report snippet', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Take a look at reporter-html.spec.ts and add a test into that file.

@@ -48,7 +48,7 @@ const reporters = () => {
['json', { outputFile: path.join(outputDir, 'report.json') }],
['blob', { fileName: `${process.env.PWTEST_BOT_NAME}.zip` }],
] : [
['html', { open: 'on-failure', title: 'Playwright Library Tests' }]
['html', { open: 'on-failure', title: 'Playwright Library Tests', snippets: true }]
Copy link
Member

Choose a reason for hiding this comment

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

let's revert this

This comment has been minimized.

This comment has been minimized.

@agamjots05
Copy link
Author

looking good, thanks for the PR! I left a pointer about the test.

Just want to let you know that during development, I noticed that single test runs (npm run ctest -- specific-test.spec.ts) don't always pass reporter options through properly, but when running full test, everything seems to run correctly. So it looks like this doesn't affect the feature's functionality in real usage.

This comment has been minimized.

@agamjots05 agamjots05 requested a review from Skn0tt June 29, 2025 20:58
Copy link
Member

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

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

Looking good! Let's see what CI is saying.

Signed-off-by: Simon Knott <info@simonknott.de>

This comment has been minimized.

@dgozman
Copy link
Contributor

dgozman commented Jul 2, 2025

@agamjots05 Do you plan to follow up with reverting package.json and package-lock.json changes?

@agamjots05
Copy link
Author

@agamjots05 Do you plan to follow up with reverting package.json and package-lock.json changes?

done 👍

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jul 2, 2025

Test results for "tests 1"

1 failed
❌ [webkit-library] › library/browsercontext-pages.spec.ts:82:3 › should click the button with offset with page scale @webkit-ubuntu-22.04-node18

10 flaky ⚠️ [chromium-library] › library/chromium/tracing.spec.ts:49:3 › should run with custom categories if provided @chromium-ubuntu-22.04-node18
⚠️ [chromium-library] › library/chromium/tracing.spec.ts:49:3 › should run with custom categories if provided @chromium-ubuntu-22.04-node20
⚠️ [chromium-library] › library/popup.spec.ts:258:3 › should not throw when click closes popup @chromium-ubuntu-22.04-node22
⚠️ [chromium-library] › library/popup.spec.ts:258:3 › should not throw when click closes popup @chromium-ubuntu-22.04-node24
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1087:7 › cli codegen record › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [firefox-library] › library/inspector/cli-codegen-pick-locator.spec.ts:35:7 › should update locator highlight @firefox-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node18-1
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node24-1
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

47087 passed, 980 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.

[Feature]: Add a parameter in the test.step() method to hide code in report
3 participants