Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

421
Views
Playwright on Github screenshots on failure not working

My playwright.config.ts includes:

use: {
  ...
  screenshot: 'only-on-failure',
}

and test failures result in screenshots being saved in /test-results when they fail locally. But when the tests fail when run in Github Actions, no screenshots are taken. So it's impossible for me to tell what's going wrong in my tests, which pass fine locally.

The only CI-specific parts of my config are:

/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? 'github' : 'list',

ETA: my action.yml attempts to upload the /test-results folder but it's always completely empty, as no screenshots were taken:

- uses: actions/upload-artifact@v2
  if: always()
  with:
    name: playwright-test-results
    path: test-results/
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';

const config: PlaywrightTestConfig = {
    forbidOnly: !!process.env.CI,
    retries: process.env.CI ? 2 : 1,
    use: {
        trace: 'on',
        screenshot: 'only-on-failure', // Capture screenshot after each test failure.
        video: 'retain-on-failure', //Record video only when retrying a test for the first time.
        headless: true,
        viewport: { width: 1280, height: 720 },
        baseURL: "https:xxxxx",
        launchOptions: {
            slowMo: 50,
            logger: {
                isEnabled: (name, severity) => name === 'browser',
                log: (name, severity, message, args) => console.log(`${name} ${message}`)
            }
        },
        actionTimeout: 10 * 1000,
        navigationTimeout: 30 * 1000
    },
    expect: {
        timeout: 10 * 1000
    },
    timeout: 90000,
    outputDir: `${__dirname}/build`,
    projects: [
        {
            name: 'chromium',
            use: { ...devices['Desktop Chrome'] }
        }
    ],
    reporter: [
        ['junit', { outputFile: 'build/results.xml' }],
        ['html', { outputFolder: 'build/html-report', open: 'never' }],
        ['list']
    ]
};
export default config;

// .gitlab-ci.yml

.e2e:
  stage: postdeploy
  image: xxxxx
  script:
    - pnpm xxx
    - pnpm nx test e2e // "test": "playwright test --output build --workers 2",
  after_script:
    - ls -l tests/e2e
    - cp -r tests/e2e/build ./results

  artifacts:
    when: always
    expire_in: never
    name: 'test-artifacts'
    paths:
      - results/html-report
    exclude:
      - results/results.xml
    reports:
      junit: results/results.xml

about 4 years ago · Juan Pablo Isaza Report

0

We can upload the test-results folder as a run artifact using GitHub's "upload-artifact" action post suite execution.

Alternatively, a step can be added in the workflow after the test run to upload the images to the desired location.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!