Cavy

Cavy

  • Documentation
  • API
  • GitHub
  • Roadmap
  • FAQ

›API reference

Getting Started

  • Installing
  • Setting up the Cavy Tester
  • Writing tests

    • Hooking up components
    • Writing test cases
  • Running tests
  • Sample app

API reference

  • Tester Component
  • Test Hooks
  • Test Helpers
  • CLI Commands
  • Filtering tests
  • Cavy Native Reporter

Guides

  • Specifing a custom app entry point
  • Writing your own spec helpers
  • Writing your own custom reporter
  • Cavy Native Reporter

    • Using Cavy Native Reporter
    • iOS XCTest example (Obj-C)
    • iOS XCTest example (Swift)
    • Android example (JUnit)

CLI Commands

These commands make testing your app easier and are available with cavy-cli.

  • See installation instructions
  • View on GitHub

Reference

cavy init

cavy init [<specFolderName>]

Set up testing with Cavy within your React Native project. Creates a specs folder with an example spec in it, and an index.test.js file, from which Cavy will boot your app and run your specs.

  • <specFolderName>: The directory in which you'd like to keep your spec files. Defaults to specs.

cavy run-ios

cavy run-ios [options] [rn-options]

Run tests on iOS.

options:

Option (long)Option (short)Description
--boot-timeout <minutes>-tSet how long to wait for the app to boot (is ignored if used with --skipbuild, defaults to 2 minutes, requires Cavy 4.0.0)
--dev-dStart the test server and keep it running until manually killed. For use with hot-reloading.
--file <file>-fSpecify the app entry point. By default, Cavy looks for an index.js.
--skipbuild-sStart the test server and listen for results without first building the app. Assumes your app is already running.
--xmlWrite the test results to cavy_results.xml, conforming to JUnit XML specification. (This option requires Cavy >=3.3.0)

rn-options:

  • Any react-native-cli options that are valid for react-native run-ios.

Examples

Set index.ios.js as the entry point:

cavy run-ios -f index.ios.js

Set a custom entry point and specify a device (see React Native: Running On Simulator):

cavy run-ios -f index.ios.js --simulator="iPhone 8"

Run Cavy tests in dev mode having built and started your app manually:

cavy run-ios -d -s

Expo and cavy-cli

By default, cavy-cli attempts to build and run your app using react-native run-ios under the hood. If you're using Expo this won't work! You'll have to manually build your app yourself and run your tests using the --skipbuild option.


cavy run-android

cavy run-android [options] [rn-options]

Run tests on Android.

Options are the same as for cavy run-ios.


Exit codes

cavy-cli will exit with one the following codes:

CodeReason
0Your app built successfully and all your tests passed
1Your app failed to build and no tests were run
42Your app built successfully but one or more of your tests failed
otherIf react-native-cli exits with any other code during the app build phase, cavy-cli will exit with the same code
← Test HelpersFiltering tests →
  • Reference
    • cavy init
    • cavy run-ios
    • cavy run-android
    • Exit codes
Pixie Labs
Docs
Getting StartedGuidesAPI Reference
Community
HelpContributorsFurther reading
More
GitHub
StarFollow @pixielabsTweet
Cavy
Copyright © 2021 Pixie Labs