playwright: [BUG] Test that passed on first retry - defined as flaky and triggers failure of the whole test run

Context:

  • Playwright Version: 1.14.1
  • Operating System: Windows
  • Browser: Chromium

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

import { PlaywrightTestConfig } from "@playwright/test";


const config: PlaywrightTestConfig = {
  retries: 1,
  timeout: 150000,
  globalTimeout: 3000000,
  reporter: [["./my-reporter.ts"], ["list"], ["junit", { outputFile: "reports/test-results.xml" }], ["allure-playwright"]],
  use: {
    browserName: 'chromium',
    trace: 'on',
    screenshot: 'on',
    viewport: {width: 1400, height: 900},
    video: {
      mode: "on-first-retry",
      size: {
        //UNIFY Recommended Resolution
        width: 1400,
        height: 900,
      }
    },
    contextOptions: {
      //viewport: {width: 1500, height: 1000},
    },
    // Browser options   
    launchOptions: {     
      channel: 'chrome', //Changed back to chromium due to the issue with chrome on CI
      headless: false,
      //args: ['--start-maximized']
    },
    //slowMo: 0,
  },
};

export default config;

Describe the bug

I run several tests in the test run. I defined the retry parameter to 1. A particular test failed on the first run and finished with success on the retry. But the whole test run failed due to the ‘flaky’ definition of the test. As I understand - the successful retry should be an actual status of the test. Am I wrong?

First run - failed. image

Retry - finished successfully. image

The whole run - failed. image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (10 by maintainers)

Most upvoted comments

Hi,

Same for us, as soon as there are “flaky” the exit code is 1

8 flaky
    foo.test.js:71:13 › xxx/ (xxx) › 'xxx' › xxx
    foo.test.js:55:11 › xxx/ (xxx) › 'xxx' › xxx
    foo.test.js:107:13 › xxx/ (xxx) › 'xxx' › xxx
    foo.test.js:71:13 › xxx/ (xxx) › 'xxx' › xxx
    foo.test.js:71:13 › xxx/ (xxx) › 'xxx' › xxx
    foo.test.js:71:13 › xxx/ (xxx) › 'xxx' › xxx 
    foo.test.js:64:9 › xxx/ (xxx) › 'xxx' › xxx 
    foo.test.js:28:7 › xxx/ (xxx) › 'xxx' › xxx
  272 passed (38m)
Makefile:378: recipe for target 'run-e2e-tests' failed
make: *** [run-e2e-tests] Error 1

I just want to mention I’m having the same issue in GitLab CI. I didn’t investigate it further yet.

$ yarn test:playwright:ci
yarn workspace v1.22.11
yarn run v1.22.11
$ yarn run test:playwright:native --config playwright.ci.config.ts
$ playwright install && playwright test --output reports/playwright --config playwright.ci.config.ts
···°°°°·····°°··················°°·······························°°·····°°······
·····°·°·····°°············°·°·°····°·°×
tracing.stopChunk: Tracing is already stopping
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:329:48
    at Object._baseTest.extend._setupContextOptionsAndArtifacts.auto [as fn] (/builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:328:40)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:98:7)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:91:40)
    at FixtureRunner.teardownScope (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:269:11)
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/workerRunner.js:91:7
×××
tracing.stopChunk: Tracing is already stopping
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:329:48
    at Object._baseTest.extend._setupContextOptionsAndArtifacts.auto [as fn] (/builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:328:40)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:98:7)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:91:40)
    at FixtureRunner.teardownScope (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:269:11)
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/workerRunner.js:91:7
×
tracing.stopChunk: Tracing is already stopping
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:329:48
    at Object._baseTest.extend._setupContextOptionsAndArtifacts.auto [as fn] (/builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:328:40)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:98:7)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:91:40)
    at FixtureRunner.teardownScope (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:269:11)
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/workerRunner.js:91:7
×
tracing.stopChunk: Tracing is already stopping
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:329:48
    at Object._baseTest.extend._setupContextOptionsAndArtifacts.auto [as fn] (/builds/xx/xxx/node_modules/@playwright/test/lib/test/index.js:328:40)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:98:7)
    at Fixture.teardown (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:91:40)
    at FixtureRunner.teardownScope (/builds/xx/xxx/node_modules/@playwright/test/lib/test/fixtures.js:269:11)
    at /builds/xx/xxx/node_modules/@playwright/test/lib/test/workerRunner.js:91:7
±°°±±°°··
  1) [Safari iPhone 12] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
    Timeout of 30000ms exceeded.
    Pending operations:
      - page.waitForSelector at tests/playwright/pages/home-page/home-page.page.ts:99:48
    attachment #1: trace (application/zip) ---------------------------------------------------------
    reports/playwright/pages-home-page-home-page-Home-page-mobile-menu-should-look-as-expected-Safari-iPhone-12/trace.zip
    Usage:
        npx playwright show-trace reports/playwright/pages-home-page-home-page-Home-page-mobile-menu-should-look-as-expected-Safari-iPhone-12/trace.zip
    ------------------------------------------------------------------------------------------------
    Retry #1 ---------------------------------------------------------------------------------------
    Timeout of 30000ms exceeded.
  2) [Safari iPhone SE] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
    Timeout of 30000ms exceeded.
    Pending operations:
      - page.waitForSelector at tests/playwright/pages/home-page/home-page.page.ts:99:48
    attachment #1: trace (application/zip) ---------------------------------------------------------
    reports/playwright/pages-home-page-home-page-Home-page-mobile-menu-should-look-as-expected-Safari-iPhone-SE/trace.zip
    Usage:
        npx playwright show-trace reports/playwright/pages-home-page-home-page-Home-page-mobile-menu-should-look-as-expected-Safari-iPhone-SE/trace.zip
    ------------------------------------------------------------------------------------------------
    Retry #1 ---------------------------------------------------------------------------------------
    Timeout of 30000ms exceeded.
  3) [Safari iPad 7] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
    Timeout of 30000ms exceeded.
    Retry #1 ---------------------------------------------------------------------------------------
    Timeout of 30000ms exceeded.
  Slow test: [Safari iPhone SE] › pages/home-page/home-page.test.ts (2m)
  Slow test: [Safari iPhone 12] › pages/home-page/home-page.test.ts (2m)
  Slow test: [Safari iPad 7] › pages/home-page/home-page.test.ts (2m)
  Slow test: [Safari 1080p] › pages/todos/todos.test.ts (55s)
  Slow test: [Safari 1080p] › pages/home-page/home-page.test.ts (51s)
  3 flaky
    [Safari iPhone 12] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
    [Safari iPhone SE] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
    [Safari iPad 7] › pages/home-page/home-page.test.ts:51:5 › Home page mobile menu should look as expected 
  25 skipped
  100 passed (3m)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is still on Playwright 1.15.0, I’ll also try with the latest version.

I also do have tracing enabled in my config:

import { devices, PlaywrightTestConfig } from '@playwright/test'

export const DESKTOP_1080P_VIEWPORT = { width: 1920, height: 1080 }

const config: PlaywrightTestConfig = {
    use: {
        baseURL: process.env.BASE_URL ? process.env.BASE_URL : 'http://localhost:3000',
    },
    testDir: './tests/playwright/',
    testMatch: '*.test.ts',
    timeout: 30000,
    preserveOutput: 'failures-only',
    retries: 3,
    projects: [
        {
            name: 'Chrome 1080p',
            use: {
                browserName: 'chromium',
                launchOptions: { args: ['--disable-dev-shm-usage'] },
                viewport: DESKTOP_1080P_VIEWPORT,
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        {
            name: 'Safari 1080p',
            use: {
                browserName: 'webkit',
                viewport: DESKTOP_1080P_VIEWPORT,
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        {
            name: 'Firefox 1080p',
            use: {
                browserName: 'firefox',
                viewport: DESKTOP_1080P_VIEWPORT,
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        // Test against mobile viewports.
        {
            name: 'Chrome Pixel 5',
            use: {
                ...devices['Pixel 5'],
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        {
            name: 'Safari iPhone 12',
            use: {
                ...devices['iPhone 12'],
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        {
            name: 'Safari iPhone SE',
            use: {
                ...devices['iPhone SE'],
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        // Test against tablet viewports.
        {
            name: 'Safari iPad 7',
            use: {
                ...devices['iPad (gen 7)'],
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
        {
            name: 'Chrome Galaxy Tab S4',
            use: {
                ...devices['Galaxy Tab S4'],
                trace: 'retain-on-failure',
                ignoreHTTPSErrors: true,
            },
        },
    ],
}
export default config

@dgozman Aside from the console out that comes from the list reporter, the only other thing that was unusual was the Internal error log I pasted in my previous comment.

Here is the rest of the output from our CI run where this issue occurred. You can see, no failed tests (just a couple flaky). But still exit code 1.

  Slow test: [Desktop - Safari] › xxx/pages/yyy/test.ui.ts (2m)                                                                                                                                                      
  Slow test: [Desktop - Chromium] › xxx/pages/yyy/test.ui.ts (2m)                                                                                                                                                    
  Slow test: [Desktop - Chromium] › xxx/pages/yyy/test.ui.ts (2m)                                                                                                                                                   
  Slow test: [Desktop - Safari] › xxx/pages/yyy/xxx.test.ui.ts (2m)                                                                                                                                                
  Slow test: [Desktop - Safari] › xxx/pages/yyy/test.ui.ts (2m)                                                                                                                                                     
                                                                                                                                                                                                                                 
  2 flaky                                                                                                                                                                                                                        
    [Desktop - Chromium] › xxx/pages/xxx/test.ui.ts:64:3 › xxx -  zzzzzzzz                                                                                                             
    [Desktop - Chromium] › xxx/pages/xxx/test.ui.ts:79:3 › xxx -  zzzzzz                                                      
  272 skipped                                                                                                                                                                                                                    
  644 passed (8m)                                                                                                                                                                                                                
error Command failed with exit code 1.                                                                                                                                                                                           
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.