Checks whether current app instance is launched by Detox or not
npm install react-native-is-detoxChecks whether current app instance is launched by Detox or not
``sh`
yarn add react-native-is-detox
`js
import { isDetox } from 'react-native-is-detox';
// ...
const result = await isDetox();
console.log('Was app launched by Detox?', result);
`
`js
import { isDetox } from 'react-native-is-detox';
function App() {
useEffect(() => {
isDetox().then((result) => {
console.log('Was app launched by Detox?', result);
});
}, []);
return
}
`
`js
import { isDetoxSync } from 'react-native-is-detox';
const result = isDetoxSync();
console.log('Was app launched by Detox?', result);
`
`js
import { isDetoxSync } from 'react-native-is-detox';
function App() {
useEffect(() => {
const result = isDetoxSync();
console.log('Was app launched by Detox?', result);
}, []);
return
}
`
Import react-native-is-detox/jestSetup in your Jest setup file.
`js``
import 'react-native-is-detox/jestSetup';
Original solution by Simon Buchan from this comment.
MIT