Cavy

Cavy

  • Documentation
  • API
  • GitHub
  • Roadmap
  • FAQ

›Guides

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)

Writing your own custom reporter

If you don't want to use cavy-cli to handle your tests results, you can pass in your own custom reporter.

By default, Cavy will send a test report to cavy-cli if it detects it is running. However, passing your own custom reporter function as a prop into the Tester component overrides this functionality - Cavy will call your function with the test report as an argument instead of sending the results to cavy-cli.

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import App from './app';
import { Tester, TestHookStore } from 'cavy';
import IntegrationSpecs from './specs/IntegrationSpecs';

// Extra import for your-custom-reporter:
import YourCustomReporter from 'your-custom-reporter';

const testHookStore = new TestHookStore();

class TestableApp extends Component {
  render() {
    return (
      <Tester specs={IntegrationSpecs}
        store={testHookStore}
        // Pass your reporter into the Tester component
        // with the `reporter` prop:
        reporter={YourCustomReporter.reporter}>
        <App/>
      </Tester>
    );
  }
}

AppRegistry.registerComponent('App', () => TestableApp);

For a real example of a custom test reporter, check out Cavy Native Reporter, which reports test results to native Android or iOS test runners:

  • Installing & using Cavy Native Reporter
  • Cavy Native Reporter on GitHub
← Writing your own spec helpersUsing Cavy Native Reporter →
Pixie Labs
Docs
Getting StartedGuidesAPI Reference
Community
HelpContributorsFurther reading
More
GitHub
StarFollow @pixielabsTweet
Cavy
Copyright © 2021 Pixie Labs