diff --git a/docs/API.md b/docs/API.md index 98e69a91..915834ec 100644 --- a/docs/API.md +++ b/docs/API.md @@ -5,7 +5,9 @@ title: API This page gathers public API of `react-native-testing-library` along with usage examples. -## `render` +## `render` + +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/render.test.js) Defined as: @@ -135,6 +137,8 @@ Get the rendered component JSON representation, e.g. for snapshot testing. ## `shallow` +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/shallow.test.js) + Shallowly renders given React component. Since it doesn't return helpers to query the output, it's mostly advised to used for snapshot testing (short snapshots are best for code reviewers). ```jsx @@ -148,6 +152,8 @@ test('Component has a structure', () => { ## `fireEvent` +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/fireEvent.test.js) + Invokes a given event handler (whether native or custom) on the element, bubbling to the root of the rendered tree. The three most common events (`press`, `changeText`, and `scroll`) have been aliased for convenience. ### `fireEvent: (element: ReactTestInstance, eventName: string, data?: *) => void` @@ -252,6 +258,8 @@ fireEvent.scroll(getByTestId('scroll-view'), eventData); ## `waitForElement` +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/waitForElement.test.js) + Defined as: ```jsx @@ -278,6 +286,8 @@ If you're using Jest's [Timer Mocks](https://jestjs.io/docs/en/timer-mocks#docsN ## `debug` +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/debug.test.js) + Log prettified shallowly rendered component or test instance (just like snapshot) to stdout. ```jsx