Skip to content

Commit

Permalink
docs: improve api docs (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski committed Apr 25, 2024
1 parent c81c89b commit 73bef94
Show file tree
Hide file tree
Showing 17 changed files with 897 additions and 905 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,16 @@ You can find the source of `QuestionsBoard` component and this example [here](ht

## API / Usage

The [public API](https://callstack.github.io/react-native-testing-library/docs/api) of `@testing-library/react-native` is focused around these essential methods:

- [`render`](https://callstack.github.io/react-native-testing-library/docs/api#render) – deeply renders the given React element and returns helpers to query the output components.
- [`fireEvent`](https://callstack.github.io/react-native-testing-library/docs/api#fireevent) - invokes named event handler on the element.
- [`waitFor`](https://callstack.github.io/react-native-testing-library/docs/api#waitfor) - waits for non-deterministic periods of time until the queried element is added or times out.
- [`waitForElementToBeRemoved`](https://callstack.github.io/react-native-testing-library/docs/api#waitforelementtoberemoved) - waits for non-deterministic periods of time until the queried element is removed or times out.
- [`within`](https://callstack.github.io/react-native-testing-library/docs/api#within) - creates a queries object scoped for a given element.
The public API of `@testing-library/react-native` is focused around these essential APIs:

- [`render`](https://callstack.github.io/react-native-testing-library/docs/render) – renders the given React element
- [`screen`](https://callstack.github.io/react-native-testing-library/docs/screen) – queries for looking up rendered elements, as well as some useful helpers.
- [`userEvent`](https://callstack.github.io/react-native-testing-library/docs/user-event) - realistic simulation of user interaction with elements like buttons and text inputs.
- [`fireEvent`](https://callstack.github.io/react-native-testing-library/docs/fire-event) - general purpose event simulation.
- [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/jest-matchers) - validate assumptions about your components.
- [`waitFor`](https://callstack.github.io/react-native-testing-library/docs/other#waitfor) - waits for non-deterministic periods of time until the queried element is added or times out.
- [`waitForElementToBeRemoved`](https://callstack.github.io/react-native-testing-library/docs/other#waitforelementtoberemoved) - waits for non-deterministic periods of time until the queried element is removed or times out.
- [`within`](https://callstack.github.io/react-native-testing-library/docs/other#within) - creates a queries object scoped for a given element.

## Migration Guides

Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/questionsBoard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ test('form submits two answers', async () => {
render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />);

const answerInputs = screen.getAllByLabelText('answer input');

// simulates the user focusing on TextInput and typing text one char at a time
await user.type(answerInputs[0], 'a1');
await user.type(answerInputs[1], 'a2');

// simulates the user pressing on any pressable element
await user.press(screen.getByRole('button', { name: 'Submit' }));

expect(onSubmit).toHaveBeenCalledWith({
Expand Down
Loading

0 comments on commit 73bef94

Please sign in to comment.