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

325
Visualizações
Can we configure and select Playwright launch options based on env?

Context : I am running a bunch of Playwright e2e tests for a enterprise web application, which are run on Github actions, as a part of the CI/CD process.

To launch Chromium using Playwright we have these launch options -

const options = {
  headless: true,
  slowMo: 100,
  ..
  // all args added to help run Chromium in headless mode
  args: [
    '--start-maximized',
    '--disable-dev-shm-usage',
    '--no-sandbox'
  ],
  
  video: "true"
};

When the same tests are run on the local system during the time we add new test cases, we have to manually change the headless: true to false to have a head-ful execution.

I'm wondering if we can configure this to have change based on the run - when the execution is local, it changes the headless mode to false and true when it runs on ci. Let's say for running tests on local,

npm run test --env=local gets the headless as false, and npm run test --env=ci gets headless true in the options.

I've gone through Playwright's documentation but couldn't find anything concrete. Most of the answers on Playwright/Puppeteer are about how to change the URL's etc, based on the env.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could try one of the below options:

  1. Create two separate config files, one for ci and one for local execution. Create two scripts in package.json one for local and one ci pointing to respective config file
  2. Update your current code as below:
  headless: !!process.env.HEADLESS,
  slowMo: 100,
  ..
  // all args added to help run Chromium in headless mode
  args: [
    '--start-maximized',
    '--disable-dev-shm-usage',
    '--no-sandbox'
  ],
  
  video: "true"
};```

// create two scripts in your package.json:

"headless":"HEADLESS=true npm run test"
"local":"npm run test"
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