From 73e7e4542dd18bfdbceab9537836af50734c93e0 Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Wed, 14 Dec 2016 21:28:09 +0000 Subject: [PATCH] Updated docs for next --- releases/next/docs/modal.html | 2 +- releases/next/docs/testing.html | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/releases/next/docs/modal.html b/releases/next/docs/modal.html index 9cf97948db6..ecdf19f9db1 100644 --- a/releases/next/docs/modal.html +++ b/releases/next/docs/modal.html @@ -44,7 +44,7 @@ class ModalExample extends /View> ); } -}

Props #

animated bool #

Deprecated

Use the animationType prop instead.

animationType enum('none', 'slide', 'fade') #

The animationType prop controls how the modal animates.

  • slide slides in from the bottom
  • fade fades into view
  • none appears without an animation

onShow function #

The onShow prop allows passing a function that will be called once the modal has been shown.

transparent bool #

The transparent prop determines whether your modal will fill the entire view. Setting this to true will render the modal over a transparent background.

visible bool #

The visible prop determines whether your modal is visible.

androidonRequestClose Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func #

The onRequestClose callback is called when the user taps the hardware back button.

iosonOrientationChange function #

The onOrientationChange callback is called when the orientation changes while the modal is being displayed. +}

Props #

animated bool #

Deprecated

Use the animationType prop instead.

animationType enum('none', 'slide', 'fade') #

The animationType prop controls how the modal animates.

  • slide slides in from the bottom
  • fade fades into view
  • none appears without an animation

onShow function #

The onShow prop allows passing a function that will be called once the modal has been shown.

transparent bool #

The transparent prop determines whether your modal will fill the entire view. Setting this to true will render the modal over a transparent background.

visible bool #

The visible prop determines whether your modal is visible.

androidhardwareAccelerated bool #

The hardwareAccelerated prop controls whether to force hardware acceleration for the underlying window.

androidonRequestClose Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func #

The onRequestClose callback is called when the user taps the hardware back button.

iosonOrientationChange function #

The onOrientationChange callback is called when the orientation changes while the modal is being displayed. The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.

iossupportedOrientations [enum('portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right')] #

The supportedOrientations prop allows the modal to be rotated to any of the specified orientations. On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.

You can edit the content above on GitHub and send us a pull request!

Examples #

Edit on GitHub
'use strict'; diff --git a/releases/next/docs/testing.html b/releases/next/docs/testing.html index c8cbf64d5fc..040ff1c3b37 100644 --- a/releases/next/docs/testing.html +++ b/releases/next/docs/testing.html @@ -1,7 +1,8 @@ -Testing

Testing #

Running Tests and Contributing #

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis and CircleCI continuous integration systems, and will automatically post the results to your PR.

We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!

Jest Tests #

Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with

npm test

from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

To use Jest for your react-native projects we recommend following the React-Native Tutorial on the Jest website.

Unit tests (Android) #

React Native uses the Buck build tool to run tests. Unit tests run locally on your machine, no emulator is needed. To run the tests:

$ cd react-native -$ ./scripts/run-android-local-unit-tests.sh

Integration tests (Android) #

React Native uses the Buck build tool to run tests. Integration tests run on an emulator / device and verify that modules and components, as well as the core parts of React Native (such as the bridge) work well end-to-end.

Make sure you have the path to the Android NDK set up, see Prerequisites.

To run the tests:

$ cd react-native -$ npm install -$ ./scripts/run-android-local-integration-tests.sh

Integration Tests (iOS) #

React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS as NativeModules.TestModule. The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria. See IntegrationTestHarnessTest.js, UIExplorerIntegrationTests.m, and IntegrationTestsApp.js for example usage and integration points.

You can run integration tests locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode.

Screenshot/Snapshot Tests (iOS) #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image. To do this, simply change to _runner.recordMode = YES; in UIExplorer/UIExplorerSnapshotTests.m, re-run the failing tests, then flip record back to NO and submit/update your PR and wait to see if the Travis build passes.

You can edit the content above on GitHub and send us a pull request!

Testing #

Running Tests and Contributing #

This document is about running tests on React Native itself. If you're interested in testing a React Native app, check out the React Native Tutorial on the Jest website.

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis and CircleCI continuous integration systems, which will automatically annotate pull requests with the test results.

Whenever you are fixing a bug or adding new functionality to React Native, you should add a test that covers it. Depending on the change you're making, there are different types of tests that may be appropriate.

Jest Tests #

Jest tests are JavaScript-only tests run on the command line with node. You can run the existing React Native jest tests with:

$ cd react-native +$ npm test

It's a good idea to add a Jest test when you are working on a change that only modifies JavaScript code.

The tests themselves live in the __tests__ directories of the files they test. See TouchableHighlight-test.js for a basic example.

Android Unit Tests #

The Android unit tests do not run in an emulator. They just use a normal Java installation. You do need to install Java 8. In particular, the default OS X Java install is insufficient.

You also need to install the Buck build tool.

To run the Android unit tests:

$ cd react-native +$ ./scripts/run-android-local-unit-tests.sh

It's a good idea to add an Android unit test whenever you are working on code that can be tested by Java code alone. The Android unit tests live under ReactAndroid/src/tests, so you can browse through that directory for good examples of tests.

Android Integration Tests #

To run the integration tests, you need to install the Android NDK. See Prerequisites.

You also need to install the Buck build tool.

We recommend running the Android integration tests in an emulator, although you can also use a real Android device. It's a good idea to keep the emulator running with a visible window. That way if your tests stall, you can look at the emulator to debug.

Some devices and some emulator configurations may not work with the tests. We do maintain an emulator configuration that works, as the standard for testing. To run this emulator config:

$ cd react-native +$ ./scripts/run-android-emulator.sh

Once you have an emulator running, to run the integration tests:

$ cd react-native +$ ./scripts/run-android-local-integration-tests.sh

The integration tests should only take a few minutes to run on a modern developer machine.

It's a good idea to add an Android integration test whenever you are working on code that needs both JavaScript and Java to be tested in conjunction. The Android integration tests live under ReactAndroid/src/androidTest, so you can browse through that directory for good examples of tests.

iOS Integration Tests #

React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS as NativeModules.TestModule. The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria. See IntegrationTestHarnessTest.js, UIExplorerIntegrationTests.m, and IntegrationTestsApp.js for example usage and integration points.

You can run integration tests locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode.

iOS Screenshot/Snapshot Tests #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image. To do this, simply change to _runner.recordMode = YES; in UIExplorer/UIExplorerSnapshotTests.m, re-run the failing tests, then flip record back to NO and submit/update your PR and wait to see if the Travis build passes.

You can edit the content above on GitHub and send us a pull request!