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

84
Vistas
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 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