react-native-is-detox
v1.2.3
Published
Checks whether current app instance is launched by Detox or not
Downloads
6,676
Maintainers
Readme
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