Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

424
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda