Skip to content

jesperjohansson/react-native-is-detox

Repository files navigation

react-native-is-detox

Checks whether current app instance is launched by Detox or not

Installation

yarn add react-native-is-detox

Usage (async)

import { isDetox } from 'react-native-is-detox';

// ...

const result = await isDetox();

console.log('Was app launched by Detox?', result);
import { isDetox } from 'react-native-is-detox';

function App() {
  useEffect(() => {
    isDetox().then((result) => {
      console.log('Was app launched by Detox?', result);
    });
  }, []);

  return <MyApp />;
}

Usage (sync)

import { isDetoxSync } from 'react-native-is-detox';

const result = isDetoxSync();

console.log('Was app launched by Detox?', result);
import { isDetoxSync } from 'react-native-is-detox';

function App() {
  useEffect(() => {
    const result = isDetoxSync();
    console.log('Was app launched by Detox?', result);
  }, []);

  return <MyApp />;
}

Mock module in Jest

Import react-native-is-detox/jestSetup in your Jest setup file.

import 'react-native-is-detox/jestSetup';

Credits

Original solution by Simon Buchan from this comment.

License

MIT

About

Checks whether current app instance is launched by Detox or not

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published