These commands make testing your app easier and are available with cavy-cli.
cavy init [<specFolderName>]
Set up testing with Cavy within your React Native project. Creates a
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
cavy run-ios [options] [rn-options]
Run tests on iOS.
|Option (long)||Option (short)||Description|
|Set how long to wait for the app to boot (is ignored if used with |
|Start the test server and keep it running until manually killed. For use with hot-reloading.|
|Specify the app entry point. By default, Cavy looks for an |
|Start the test server and listen for results without first building the app. Assumes your app is already running.|
|Write the test results to |
- Any react-native-cli options that are valid for
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
cavy run-android [options] [rn-options]
Run tests on Android.
Options are the same as for
cavy-cli will exit with one the following codes:
|0||Your app built successfully and all your tests passed|
|1||Your app failed to build and no tests were run|
|42||Your app built successfully but one or more of your tests failed|
|other||If react-native-cli exits with any other code during the app build phase, cavy-cli will exit with the same code|