Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions

Jump to navigation Jump to search
m
Line 1,472: Line 1,472:


=== Test Retries ===
=== Test Retries ===
* workers are clean incognito browser windows
* worker is re-used after completing a passing test
* a new worker is started after a failed test
* with retries on the failed test is retried in the new worker
* with retries off the next test is started in the new worker
In file <code>playwright.config.ts</code>
<nowiki>
export default defineConfig({
  ...
  /* Retry on CI only */
  retries: process.env.CI ? 2 : 1,
  use: {
    ...
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    trace: "on-first-retry", //['on-first-retry', 'on-all-retries', 'off', 'on', 'retain-on-failure']
  },
</nowiki>
In file <code>tests\uiComponents.spec.ts</code>
<nowiki>
test.describe.only("Forms Layouts page", () => {
  test.describe.configure({ retries: 2,  })
  test.beforeEach(async ({ page }, testInfo) => {
    if(testInfo.retry){
      // can clean up from previous failed attempt
    }
    ...
  })
...
</nowiki>
Notes:
* Having trace on-first-retry is very cool
=== Parallel Execution ===
=== Parallel Execution ===
=== Screenshots and Videos ===
=== Screenshots and Videos ===

Navigation menu