Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const scenarioRoutes = scenarios.reduce((acc, scenario) => {
acc[scenario.key] = {
screen: scenario.Screen,
navigationOptions: { title: scenario.label },
};
return acc;
}, {});
const MainNavigator = createStackNavigator({
Home: { screen: HomeScreen },
...scenarioRoutes,
});
const AppContainer = createAppContainer(MainNavigator);
const store = new TestHookStore();
const navigateAndRun = (scenario) => {
console.log('in navigateAndRun')
return (spec) => {
// Override `it` so that it presses into the scene for this test first.
const origIt = spec.it;
spec.it = (label, f) => {
origIt.call(spec, label, async () => {
await spec.press(scenario.key);
await f();
});
};
scenario.spec(spec);
}
}
/* eslint-disable import/first */
process.env.NODE_ENV = 'test'
import React from 'react'
import { AppRegistry, Text, NativeModules } from 'react-native'
import Tester from 'cavy/src/Tester'
import TestHookStore from 'cavy/src/TestHookStore'
import integrationTests from './__tests__/integrationTests'
// Mysteriously fixes React Native stacktrace symbolication ¯\_(ツ)_/¯
if (typeof global.self === 'undefined') {
global.self = global
}
const testHookStore = new TestHookStore()
const sendReport = report => {
// eslint-disable-next-line
console.log(report)
NativeModules.BridgeTestReporter.testsFinished(report)
}
const TestRoot = () => (
)
AppRegistry.registerComponent('watermelonTest', () => TestRoot)
export const Screen = () => {
const [showHiddenMessage, setShowHiddenMessage] = useState(false);
const generateTestHook = useCavy();
return (
<>
setShowHiddenMessage(true)}
/>
{showHiddenMessage && (
)}
);
};
export const Screen = () => {
const generateTestHook = useCavy();
return ;
};
export const Screen = () => {
const [showHiddenMessage, setShowHiddenMessage] = useState(false);
const generateTestHook = useCavy();
return (
<>
setShowHiddenMessage(true)}
/>
{showHiddenMessage && (
)}
);
};
const HomeScreen = ({ navigation }) => {
const generateTestHook = useCavy();
return (
<>
{scenarios.map(scenario => (
<button title="{scenario.label}"> navigation.navigate(scenario.key)}
/>
))}
);
};
</button>
export const Screen = () => {
const generateTestHook = useCavy();
return (
<>
{false && (
)}
);
};
import React, { useState } from 'react';
import { Button, Text } from 'react-native';
import { useCavy, wrap } from 'cavy';
export const key = 'ButtonFunctionComponent';
const buttonId = `${key}.Button`;
const textId = `${key}.Text`;
const FunctionButton = ({ onPress, title }) => (
<button title="{title}">
);
const WrappedFunctionButton = wrap(FunctionButton);
export const Screen = () => {
const [showHiddenMessage, setShowHiddenMessage] = useState(false);
const generateTestHook = useCavy();
return (
<>
setShowHiddenMessage(true)}
/>
{showHiddenMessage && (
</button>
import React, { Component } from 'react'
import { Platform } from 'react-native'
import App from '../components/App'
import { Tester, TestHookStore } from 'cavy'
import Onboarding from './tests/Onboarding.js'
import AppLoading from './tests/AppLoading.js'
import Contact from './tests/Contact.js'
import Chat from './tests/Chat.js'
import DevTools from './tests/DevTools.js'
const testHookStore = new TestHookStore()
const redirectConsoleLogsToTerminal = () => {
if (Platform.OS !== 'web') {
let DEBUG_LEVEL = 0
let INFO_LEVEL = 1
let WARN_LEVEL = 2
let ERROR_LEVEL = 3
console.log = log => global.nativeLoggingHook(log, DEBUG_LEVEL)
console.info = log => global.nativeLoggingHook(log, INFO_LEVEL)
console.warn = log => global.nativeLoggingHook(log, WARN_LEVEL)
console.error = log => global.nativeLoggingHook(log, ERROR_LEVEL)
}
}
const getReportServerInfos = () => {
import React, { Component } from 'react'
import { Platform } from 'react-native'
import { Tester, TestHookStore } from 'cavy'
import Onboarding from './tests/Onboarding.js'
import AppLoading from './tests/AppLoading.js'
import Contact from './tests/Contact.js'
import Chat from './tests/Chat.js'
import DevTools from './tests/DevTools.js'
const testHookStore = new TestHookStore()
const redirectConsoleLogsToTerminal = () => {
if (Platform.OS !== 'web') {
let DEBUG_LEVEL = 0
let INFO_LEVEL = 1
let WARN_LEVEL = 2
let ERROR_LEVEL = 3
console.log = log => global.nativeLoggingHook(log, DEBUG_LEVEL)
console.info = log => global.nativeLoggingHook(log, INFO_LEVEL)
console.warn = log => global.nativeLoggingHook(log, WARN_LEVEL)
console.error = log => global.nativeLoggingHook(log, ERROR_LEVEL)
}
}
const getReportServerInfos = () => {