How to use the cavy.useCavy function in cavy

To help you get started, we’ve selected a few cavy examples, based on popular ways it is used in public projects.

github pixielabs / cavy / test / CavyTester / src / scenarios / buttonFunctionComponent.js View on Github external
export const Screen = () => {
  const [showHiddenMessage, setShowHiddenMessage] = useState(false);
  const generateTestHook = useCavy();

  return (
    <>
      <WrappedFunctionButton
        ref={generateTestHook(buttonId)}
        title="Click to show message"
        onPress={() => setShowHiddenMessage(true)}
      />
      {showHiddenMessage && (
        <Text ref={generateTestHook(textId)}>
          I only show up when you press the button
        </Text>
      )}
    </>
  );
};
github pixielabs / cavy / test / CavyTester / src / scenarios / exists.js View on Github external
export const Screen = () => {
  const generateTestHook = useCavy();
  return <Text ref={generateTestHook(testId)}>I am text that is present</Text>;
};
github pixielabs / cavy / test / CavyTester / src / scenarios / buttonClassComponent.js View on Github external
export const Screen = () => {
  const [showHiddenMessage, setShowHiddenMessage] = useState(false);
  const generateTestHook = useCavy();

  return (
    <>
      <ClassButton
        ref={generateTestHook(buttonId)}
        title="Click to show message"
        onPress={() => setShowHiddenMessage(true)}
      />
      {showHiddenMessage && (
        <Text ref={generateTestHook(textId)}>
          I only show up when you press the button
        </Text>
      )}
    </>
  );
};
github pixielabs / cavy / test / CavyTester / src / App.js View on Github external
const HomeScreen = ({ navigation }) => {
  const generateTestHook = useCavy();
  return (
    <>
      {scenarios.map(scenario => (
        <Button
          key={scenario.key}
          ref={generateTestHook(scenario.key)}
          title={scenario.label}
          onPress={() => navigation.navigate(scenario.key)}
        />
      ))}
    </>
  );
};
github pixielabs / cavy / test / CavyTester / src / scenarios / notExists.js View on Github external
export const Screen = () => {
  const generateTestHook = useCavy();

  return (
    <>
      <Text>I am text that is present</Text>
      {false && (
        <Text ref={generateTestHook(testId)}>
          I am text that is *not* present
        </Text>
      )}
    </>
  );
};
github pixielabs / cavy / sample-app / CavyDirectory / app / EmployeeListItem.js View on Github external
export default ({ data, navigation }) => {
  const generateTestHook = useCavy();
  const WrappedText = wrap(Text);

  return (
    <TouchableHighlight
      ref={generateTestHook(`${navigation.state.routeName}.${data.firstName}${data.lastName}`)}
      onPress={ () => navigation.navigate('EmployeeDetails', {employeeId: data.id}) }
      underlayColor={'#EEEEEE'}>
      <View style={styles.container}>
        <Image source={{uri: data.picture}} style={styles.picture} />
        <View>
          <Text>{data.firstName} {data.lastName}</Text>
          <WrappedText
            ref={generateTestHook(`${navigation.state.routeName}.${data.title}`)}
            style={styles.title}
          >
            {data.title}

cavy

An integration test framework for React Native.

MIT
Latest version published 12 months ago

Package Health Score

64 / 100
Full package analysis