Rayrun

What are the steps to access the HTML report generated by Playwright tests in a Docker container?

Answer

Accessing Playwright Test Reports in Docker

First, ensure Playwright is installed in your Docker container. You can include the installation commands in your Dockerfile or run them manually inside the container.

Next, run your tests inside the Docker container. Use the command npx playwright test followed by the path to your test files. Don't forget to include any necessary flags or options for running tests in headless mode or with specific browsers.

npx playwright test /path/to/your/test/files

After running the tests, Playwright generates an HTML report with detailed test results. To access this report, extract it from the Docker container and open it in a web browser.

To extract the HTML report from the Docker container, you can:

  • Navigate to the directory on your host machine where you've mounted a volume or bind mount for storing artifacts generated during testing. Locate the HTML report file there.
  • Or, if no volume or bind mount was used, copy the HTML report file from within the Docker container to your host machine using the docker cp command.
docker cp containerId:/path/to/report.html /host/path/to/report.html

Once you have the HTML report file on your host machine, serve it using a local web server. You can do this within a folder where Playwright is installed.

Change into the directory where you extracted the HTML report file and use npx playwright show-report followed by the name (or path) of the report.

cd /path/to/report
npx playwright show-report report.html

This starts a local web server that serves up the report. Now you can view your test results in detail!

References

Thank you!
Was this helpful?
Still have questions?

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

Related Discord Threads

Related Questions

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.