How to use Jest globalSetup with Detox

I want to use globalSetup, and globalTeardownby Jest with the Detox, to install detox occurs only once, but the Detox, apparently failed when init was not beforeAll.

Any suggestions?

Jest Version: 22.0.4 Detox Version: 6.0.4

configurations:

"globalSetup": "./setUpDetox.js",
"globalTeardown": "./tearDownDetox.js",
+4
source share
1 answer

Instead of using globalSetup and globalTeardown, configure and deploy your test environment from within your init. Just use the joke before and after.

e2e / init.js

const detox = require('detox');
const config = require('../package.json').detox;

jest.setTimeout(120000);

beforeAll(async () => {
  // custom setup
  console.log('Initializing Detox');
  await detox.init(config, { launchApp: false });
});

afterAll(async () => {
  // custom teardown
  await detox.cleanup();
});

e2e / config.json

{
  "setupTestFrameworkScriptFile" : "./init.js"
}
+1
source

Source: https://habr.com/ru/post/1691744/


All Articles