Skip to main content

Running tests for React Native apps

Abstract

You can run all kinds of tests for your React Native app on Bitrise: unit tests, integration tests, or component tests. You can use Jest, for example, to write all your tests and then run them during the build process with either npm or Yarn.

You can run all kinds of tests for your React Native app on Bitrise: unit tests, integration tests, or component tests. You can use Jest, for example, to write all your tests and then run them during the build process with either npm or Yarn.

E2E testing

For end-to-end testing, check out Detox: Running Detox tests on Bitrise.

Workflow Editor

bitrise.yml

  1. Write your tests and add them to your React Native project.

  2. On Bitrise, add either the Run npm command or the Run yarn command Step to your Workflow, depending on which package manager you use in your project.

  3. Configure the Step to run the test command:

    • For Yarn, find the Arguments for running yarn commands input and add test.

    • For npm, find the The npm command with arguments to run input and add test.

    npm-test.png

    In either case, the Step will run the test script in the scripts object of your package.

  1. Write your tests and add them to your React Native project.

  2. In the bitrise.yml file, add either the npm or the yarn Step to your Workflow, depending on which package manager you use in your project.

  3. Configure the Step of your choice to run the test command: for either Step, set the command input to test.

    empty:
      steps:
        - git-clone: {}
        - npm:
            inputs:
            - command: test
        - yarn@0:
            inputs:
            - command: test
        - deploy-to-bitrise-io: {}

    Either Step will run the test script in the scripts object of your package.

That's all you need to run the tests and view their results in the build logs.