Rayrun

How do I set up an HTML reporter for Playwright Test with Java?

Answer

To set up an HTML reporter for Playwright Test with Java, follow these steps:

  1. Install the Playwright Test library.

  2. Create a playwright.config.ts file in your project's root directory.

  3. Define a reporter option in the configuration file:

    import { defineConfig } from '@playwright/test';
    
    export default defineConfig({
      reporter: [['html', { outputFolder: 'my-report' }]],
    });

    This sets up an HTML reporter that generates reports in the my-report folder.

  4. If you want to upload attachments from a data folder to another location, use the attachmentsBaseURL option:

    import { defineConfig } from '@playwright/test';
    
    export default defineConfig({
      reporter: [['html', { attachmentsBaseURL: 'https://ray.run/' }]],
    });
  5. To open the last test run report quickly, use this command:

    npx playwright show-report

    If there is a custom folder name specified in your configuration file (e.g., my-report), use this command instead:

    npx playwright show-report my-report

Note that the HTML reporter does not support merging reports generated across multiple shards into a single report. However, third-party solutions can help with this issue.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.