Skip to content

Conversation

@Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Mar 25, 2025

Closes #35099 by adding a path to the prompt contents to terminal report outputs:

Screenshot 2025-03-25 at 12 39 28

@Skn0tt Skn0tt requested review from Copilot and pavelfeldman March 25, 2025 11:41
@Skn0tt Skn0tt self-assigned this Mar 25, 2025
Copy link
Contributor

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.

Pull Request Overview

This PR adds a new feature to display an error prompt path in terminal outputs to help diagnose test failures. The changes include:

  • Adding a new test in the reporter-line specs to validate the error prompt output.
  • Enhancing the error formatting in the base reporter to append a relative path to error prompts when available.
  • Updating the prompt handling and the HTML reporter to accommodate the new prompt attachment structure.

Reviewed Changes

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

Show a summary per file
File Description
tests/playwright-test/reporter-line.spec.ts Added a test case to check that the terminal output includes the error prompt path.
packages/playwright/src/reporters/base.ts Modified error formatting functions to allow inclusion of the error prompt.
packages/playwright/src/prompt.ts Updated to use fs/promises and write prompt attachments with a file path.
packages/html-reporter/src/testErrorView.tsx Changed the prompt property type to TestAttachment and updated prompt handling accordingly.
packages/html-reporter/src/testResultView.tsx Adjusted attachment retrieval to align with the new prompt attachment structure.
packages/playwright/src/reporters/github.ts Updated reporter call to use the new error formatting signature.
packages/playwright/src/reporters/html.ts Updated the call to formatResultFailure to include new parameters.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Skn0tt Skn0tt requested a review from dgozman March 26, 2025 13:17
if (includePrompt) {
const promptPath = result.attachments.find(a => a.name === `_prompt-${index}`)?.path;
if (promptPath)
message += '\n' + screen.colors.cyan(`Error Prompt: ${relativeFilePath(screen, config, promptPath)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a layering violation. Test runner should not know about prompts.

Copy link
Member Author

@Skn0tt Skn0tt Mar 26, 2025

Choose a reason for hiding this comment

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

This isn't the test runner, but the terminal reporter. If the HTML reporter knows about prompts, why can't the terminal reporter?

);
}

const promptPath = testInfo.outputPath(`_prompt-${index}.md`);
Copy link
Contributor

Choose a reason for hiding this comment

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

The file name does not have to start with the underscore 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

good point! and even better, it doesn't need to have an index if there's only one. fixed in d1cc9e9.

@Skn0tt Skn0tt requested a review from dgozman March 26, 2025 13:45
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

if (!error.message)
return;
return false;
if (testInfo.attachments.find(a => a.name === `_prompt-${index}`))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this filter condition conflicts with checking for errors.length === 1 below.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch! fixed in cf6e070

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Test results for "tests 1"

2 flaky ⚠️ [chromium-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @chromium-ubuntu-22.04-node20
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18

38921 passed, 805 skipped
✔️✔️✔️

Merge workflow run.

@Skn0tt Skn0tt merged commit 2f3fe8f into microsoft:main Mar 28, 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.

[Feature]: Add Support to Run Playwright Tests and Get LLM "Copy Prompt" Output in CLI for LLMs

2 participants