What are the steps to enable and view traces in Playwright tests run on GitHub Actions?


Enabling Traces in GitHub Actions with Playwright

First, ensure Playwright is set up in your project. Then, in your GitHub Action workflow file (.github/workflows/main.yml), define a job for running tests with Playwright. This includes setting up the environment, installing dependencies, and executing test scripts.

To enable tracing, add a step that runs the tests with the --trace on flag. Here's how:

npx playwright test --trace on

This generates a trace.zip file for each retried test (if retries are configured). These files contain information about each action performed during the test execution.

Viewing Traces

You can view these traces using either Playwright CLI or the Trace Viewer tool provided by Playwright.

For Playwright CLI:

npx playwright show-trace <path-to-trace.zip>

For Trace Viewer, visit trace.playwright.dev and upload your trace files.

Configuring Traces

To record traces on the first retry of a failed test, configure Playwright in your playwright.config.ts file:

  trace: 'on-first-retry'

You can also customize other trace recording options in your playwright.config.ts file.

Remember to refer to the official Playwright documentation for more detailed instructions and updates.


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

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.