Rayrun

What could be the reasons for not getting all the traces when using the --tracing=retain-on-failure flag in @playwright/test?

Answer

Troubleshooting Tracing in @playwright/test

If you're not seeing all traces when using --tracing=retain-on-failure, there could be a few reasons why.

Check Your Test Configuration

First, remember that --tracing=retain-on-failure only retains traces for failed tests. If all your tests pass, you won't see any traces.

Also, your playwright.config.ts might be misconfigured. For instance, if traces are set to run on the first retry of a failed test using trace: 'on-first-retry', but no retries are happening, no traces will be generated.

// playwright.config.ts
module.exports = {
  retries: 1,
  use: {
    trace: 'on-first-retry',
  },
};

Verify Your Playwright Version

Ensure you're using Playwright version 1.25 or higher. The --trace flag was introduced in v1.25.

// package.json
{
  "dependencies": {
    "playwright": "^1.25.0"
  }
}

Run Your Tests

Make sure your tests actually fail so that retries occur. Also, ensure your test command includes the --trace flag followed by 'retain-on-failure'.

npx playwright test --trace=retain-on-failure

If you're still not seeing all the traces, consult the official Playwright documentation or the Playwright community for further guidance. For more tips on handling flaky tests in Playwright, check out this blog post.

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 [email protected].