Back to Skills

react-native-testing

verified

Master testing - Jest, Testing Library, Detox E2E, and CI/CD integration

View on GitHub

Marketplace

pluginagentmarketplace-react-native

pluginagentmarketplace/custom-plugin-react-native

Plugin

react-native-assistant

Repository

pluginagentmarketplace/custom-plugin-react-native
3stars

skills/react-native-testing/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
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-testing

Installation paths:

Claude
.claude/skills/react-native-testing/
Powered by add-skill CLI

Instructions

# 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', 

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3370 chars