How to use cavy - 10 common examples

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixielabs / cavy / test / CavyTester / src / App.js View on Github external
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);
  }
}
github Nozbe / WatermelonDB / src / index.integrationTests.native.js View on Github external
/* 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)
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 (
    <>
       setShowHiddenMessage(true)}
      />
      {showHiddenMessage && (
        
      )}
    
  );
};
github pixielabs / cavy / test / CavyTester / src / scenarios / exists.js View on Github external
export const Screen = () => {
  const generateTestHook = useCavy();
  return ;
};
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 (
    <>
       setShowHiddenMessage(true)}
      />
      {showHiddenMessage && (
        
      )}
    
  );
};
github pixielabs / cavy / test / CavyTester / src / App.js View on Github external
const HomeScreen = ({ navigation }) => {
  const generateTestHook = useCavy();
  return (
    <>
      {scenarios.map(scenario => (
        <button title="{scenario.label}"> navigation.navigate(scenario.key)}
        /&gt;
      ))}
    
  );
};
</button>
github pixielabs / cavy / test / CavyTester / src / scenarios / notExists.js View on Github external
export const Screen = () =&gt; {
  const generateTestHook = useCavy();

  return (
    &lt;&gt;
      
      {false &amp;&amp; (
        
      )}
    
  );
};
github pixielabs / cavy / test / CavyTester / src / scenarios / buttonFunctionComponent.js View on Github external
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 }) =&gt; (
  <button title="{title}">
);

const WrappedFunctionButton = wrap(FunctionButton);

export const Screen = () =&gt; {
  const [showHiddenMessage, setShowHiddenMessage] = useState(false);
  const generateTestHook = useCavy();

  return (
    &lt;&gt;
       setShowHiddenMessage(true)}
      /&gt;
      {showHiddenMessage &amp;&amp; (
        </button>
github berty / berty / client / react-native / common / integration / AppWrapper.js View on Github external
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 = () => {
github berty / berty / client / react-native / app / main / integration / AppWrapper.js View on Github external
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 = () => {

cavy

An integration test framework for React Native.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis