rules/react-native/testing.md
This file extends common/testing.md with React Native / Expo specific content. Coverage target and TDD workflow are inherited from common/testing.md (80% minimum, RED-GREEN-REFACTOR).
| Layer | Tool |
|---|---|
| Unit / component | Jest + @testing-library/react-native (via jest-expo preset) |
| Hooks | @testing-library/react-native renderHook |
| E2E | Maestro (recommended, simple YAML flows) or Detox |
| Type safety | tsc --noEmit in CI |
testID unless necessary — this also enforces accessibility.import { render, screen, fireEvent } from '@testing-library/react-native'
test('calls onSelect with the user id when pressed', () => {
const onSelect = jest.fn()
render(<UserCard user={{ id: '1', email: 'a@b.com' }} onSelect={onSelect} />)
fireEvent.press(screen.getByText('[email protected]'))
expect(onSelect).toHaveBeenCalledWith('1')
})
QueryClientProvider with a fresh client per test.expo-router) so screens render in isolation.Use the tdd-guide agent proactively for new features: write a failing test that captures the behavior, then implement.