Skip to content

Latest commit

 

History

History
78 lines (52 loc) · 1.37 KB

README.md

File metadata and controls

78 lines (52 loc) · 1.37 KB

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