Master testing - Jest, Testing Library, Detox E2E, and CI/CD integration
View on GitHubpluginagentmarketplace/custom-plugin-react-native
react-native-assistant
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-react-native/blob/main/skills/react-native-testing/SKILL.md -a claude-code --skill react-native-testingInstallation paths:
.claude/skills/react-native-testing/# React Native Testing Skill
> Learn comprehensive testing strategies including unit tests, component tests, and E2E tests.
## Prerequisites
- React Native basics
- Understanding of async/await
- Familiarity with testing concepts
## Learning Objectives
After completing this skill, you will be able to:
- [ ] Configure Jest for React Native
- [ ] Write component tests with Testing Library
- [ ] Mock native modules and APIs
- [ ] Implement E2E tests with Detox/Maestro
- [ ] Set up CI/CD test pipelines
---
## Topics Covered
### 1. Jest Setup
```javascript
// jest.config.js
module.exports = {
preset: 'react-native',
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
transformIgnorePatterns: [
'node_modules/(?!(react-native|@react-native)/)',
],
};
```
### 2. Component Testing
```tsx
import { render, screen, fireEvent } from '@testing-library/react-native';
import { Button } from './Button';
describe('Button', () => {
it('calls onPress when pressed', () => {
const onPress = jest.fn();
render(<Button title="Click" onPress={onPress} />);
fireEvent.press(screen.getByText('Click'));
expect(onPress).toHaveBeenCalled();
});
});
```
### 3. Hook Testing
```tsx
import { renderHook, act } from '@testing-library/react-native';
import { useCounter } from './useCounter';
describe('useCounter', () => {
it('increments count', () => {
const { result } = renderHook(() => useCounter());
act(() => result.current.increment());
expect(result.current.count).toBe(1);
});
});
```
### 4. Mocking
```typescript
// Mock native module
jest.mock('@react-native-async-storage/async-storage', () => ({
setItem: jest.fn(),
getItem: jest.fn(),
}));
// Mock API
jest.mock('./api', () => ({
fetchUser: jest.fn().mockResolvedValue({ id: '1', name: 'Test' }),
}));
```
### 5. E2E with Detox
```typescript
describe('Login', () => {
beforeAll(async () => {
await device.launchApp();
});
it('should login successfully',