Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

422
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda