Search code examples
detox

Detox: Do you need to call device.reloadReactNative before each test?


It's unclear to me if it is necessary / best practice to call device.reloadReactNative() before a test runs in Detox. The examples make it seem like it is best practice but it's unclear to me.

For example calling it in the beforeAll, is this necessary?

describe('Example', () => {
  beforeAll(async () => {
    await device.reloadReactNative();
  });

  it('render a tappable list of posts', async () => {...});
});

I read here that it is best practice to call it but I'm not sure about the reliability of the source.


Solution

  • You need to reset the app state somehow to a familiar baseline, before starting a new test. You can relaunch your app, or even reinstall it, if you must, but those are far slower. Reloading RN is a nice shortcut for RN apps.