Skip to content

Commit 482875d

Browse files
refactor: make fireEvent async by default (#1844)
1 parent 6642caa commit 482875d

22 files changed

+1061
-996
lines changed

.gemini/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"context": {
3+
"contextFileName": "AGENTS.md"
4+
}
5+
}

AGENTS.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Code Assistant Context
2+
3+
This document provides context for the any code assistant to understand the `@testing-library/react-native` project.
4+
5+
## Project Overview
6+
7+
`@testing-library/react-native` (RNTL) provides a set of utilities for testing React Native components. It is designed to facilitate writing tests that resemble how users interact with the application, avoiding implementation details.
8+
9+
- **Core Principle:** "The more your tests resemble the way your software is used, the more confidence they can give you."
10+
- **Tech Stack:** TypeScript, React Native, Jest.
11+
- **Architecture:** The library simulates the React Native runtime on top of `universal-test-renderer`.
12+
13+
## Building and Running
14+
15+
The project uses `yarn` for dependency management and script execution.
16+
17+
- **Installation:** `yarn install`
18+
- **Run Tests:** `yarn test` (Runs Jest)
19+
- **Run Tests (CI):** `yarn test:ci` (Runs Jest with worker limits)
20+
- **Lint Code:** `yarn lint` (Runs ESLint on `src`)
21+
- **Type Check:** `yarn typecheck` (Runs TypeScript compiler)
22+
- **Format Check:** `yarn prettier`
23+
- **Validate All:** `yarn validate` (Runs Prettier, ESLint, Typecheck, and Tests in sequence)
24+
- **Build Project:** `yarn build` (Cleans, builds JS with Babel, builds TS types, and copies Flow types)
25+
26+
## Development Conventions
27+
28+
- **Code Style:**
29+
- **Linting:** ESLint is configured with `@callstack/eslint-config` and `typescript-eslint`. It enforces strict rules, including `no-console` and consistent type imports.
30+
- **Formatting:** Prettier is used for code formatting (single quotes, trailing commas).
31+
- **Imports:** Sorted using `eslint-plugin-simple-import-sort`.
32+
33+
- **Testing:**
34+
- **Framework:** Jest with `react-native` preset.
35+
- **Location:** Tests are located within `src`, typically co-located in `__tests__` directories.
36+
- **Setup:** `jest-setup.ts` configures the test environment. `src/index.ts` automatically configures cleanup after each test unless skipped.
37+
- **Coverage:** Collected from `src`, excluding tests.
38+
39+
- **Commits & Releases:**
40+
- **Commits:** Follow the **Conventional Commits** specification (e.g., `fix:`, `feat:`, `chore:`). This is enforced and used for changelog generation.
41+
- **Releases:** Managed via `release-it`.
42+
43+
- **File Structure:**
44+
- `src/`: Source code.
45+
- `src/pure.ts`: Core logic without side effects (no auto-cleanup).
46+
- `src/index.ts`: Main entry point, re-exports `pure` and adds side effects (auto-cleanup).
47+
- `examples/`: Example React Native applications using the library.
48+
- `website/`: Documentation website.

src/__tests__/act.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ test('rerender should trigger useEffect', () => {
3131
expect(effectCallback).toHaveBeenCalledTimes(2);
3232
});
3333

34-
test('fireEvent should trigger useState', () => {
34+
test('fireEvent should trigger useState', async () => {
3535
render(<Counter />);
3636
const counter = screen.getByText(/Total count/i);
3737

3838
expect(counter.props.children).toEqual('Total count: 0');
39-
fireEvent.press(counter);
39+
await fireEvent.press(counter);
4040
expect(counter.props.children).toEqual('Total count: 1');
4141
});
4242

0 commit comments

Comments
 (0)