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

83
Visualizações
Cleaning up detox in cucumber run

I'm using detox with cucumber and the setup works great until the last moment of calling AfterAll hooks. In the hook I do the following:

AfterAll(async () => {
  console.log('CLEANING DETOX');
  await detox.cleanup();
});

To run cucumber I use the following script from package.json:

"bdd": "cucumber-js --require-module @babel/register",

The problem happens when I interrupt cucumber run for any reason. AfterAll hook won't run in this case and detox won't clear its stale files. Which wouldn't be a problem but detox is using ~/Library/Detox/device.registry.state.lock file to track which simulators are being used by runner. Essentially, this leads to detox constantly launching new simulator devices as this file never gets cleared. I thought, I could just create a simple wrapper script:

const { execSync } = require('child_process');
const detox = require('detox');

const stdout = execSync('cucumber-js --require-module @babel/register');
process.on('SIGINT', async function () {
  console.log('Cleanig up detox');
  await detox.cleanup();
});
console.log(stdout);

However, that didn't work either as detox.cleanup() only removes the file when it has detox.device setup. Which happens in BeforeAll hook:

BeforeAll({ timeout: 120 * 1000 }, async () => {
  const detoxConfig = { selectedConfiguration: 'ios.debug2' };
  // console.log('CONFIG::', detoxConfig);
  await detox.init(detoxConfig);
  await detox.device.launchApp();
});

My only idea left is to manually clear the file - I should be able to grab lock file path from detox internal somehow - my worry about this approach is tight dependency on detox implementation. Which is why I would rather call detox.cleanup.

EDIT: Ended up doing this workaround for now:

BeforeAll({ timeout: 120 * 1000 }, async () => {
  await startDetox();
});
async function startDetox() {
  const detoxConfig = { selectedConfiguration: 'ios.debug' };

  const lockFile = getDeviceLockFilePathIOS();
  unlink(lockFile, (err) => {
    if (err) {
      console.debug('Lock file was not deleted:::', err);
    }
  });
  await detox.init(detoxConfig);
  await detox.device.launchApp();
}

Wonder if anyone has a better idea ?

about 4 years ago · Juan Pablo Isaza
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