with one click
mobile-testing
Write and run tests for React Native apps using Jest and React Native Testing Library. Use when creating tests, debugging failures, or setting up test infrastructure.
Menu
Write and run tests for React Native apps using Jest and React Native Testing Library. Use when creating tests, debugging failures, or setting up test infrastructure.
| name | mobile-testing |
| description | Write and run tests for React Native apps using Jest and React Native Testing Library. Use when creating tests, debugging failures, or setting up test infrastructure. |
| allowed-tools | Bash, Read, Write, Edit |
Testing guide for React Native applications.
# Install testing dependencies
npm install --save-dev jest @testing-library/react-native
# Add to package.json
{
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
}
}
import { render, fireEvent } from '@testing-library/react-native';
import { MyButton } from './MyButton';
describe('MyButton', () => {
it('renders correctly', () => {
const { getByText } = render(<MyButton title="Click me" />);
expect(getByText('Click me')).toBeTruthy();
});
it('calls onPress when pressed', () => {
const onPress = jest.fn();
const { getByText } = render(
<MyButton title="Click me" onPress={onPress} />
);
fireEvent.press(getByText('Click me'));
expect(onPress).toHaveBeenCalledTimes(1);
});
});
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);
});
});
import { formatDate } from './formatDate';
describe('formatDate', () => {
it('formats date correctly', () => {
const date = new Date('2025-01-15');
expect(formatDate(date)).toBe('2025-01-15');
});
it('handles invalid input', () => {
expect(() => formatDate(null)).toThrow();
});
});
jest.mock('expo-notifications', () => ({
scheduleNotificationAsync: jest.fn(),
}));
jest.mock('@/db/client', () => ({
db: {
select: jest.fn(),
insert: jest.fn(),
},
}));
jest.mock('expo-router', () => ({
useRouter: () => ({
push: jest.fn(),
back: jest.fn(),
}),
}));
# Run all tests
npm test
# Watch mode (auto-rerun on changes)
npm run test:watch
# With coverage report
npm run test:coverage
# Run specific test file
npm test -- MyComponent.test.tsx
# Update snapshots
npm test -- -u
testID for Selection: More reliable than text matchingbeforeEach/afterEach for setup/teardownit('loads data', async () => {
const { findByText } = render(<DataComponent />);
expect(await findByText('Loaded')).toBeTruthy();
});
it('validates input', () => {
const { getByTestId, getByText } = render(<LoginForm />);
fireEvent.changeText(getByTestId('email-input'), 'invalid');
fireEvent.press(getByTestId('submit-button'));
expect(getByText('Invalid email')).toBeTruthy();
});
it('renders list items', () => {
const items = [{ id: '1', name: 'Item 1' }];
const { getAllByTestId } = render(<ItemList items={items} />);
expect(getAllByTestId('list-item')).toHaveLength(1);
});
screen.debug() to see rendered outputwaitFor or findBy queriesProfessional frontend standards for building, scaffolding, extending, or reviewing any UI or frontend project — new or existing — even when standards aren't explicitly asked for. Keeps generated code consistent, reusable, secure, and production-quality. Framework-agnostic: React, Vue, Angular, Svelte, plain JS.
发布本地生成的 HTML、Markdown、TXT、PDF、Word 或 PPTX 到 ShareOne 平台,生成公网分享短链接;或者当用户提供 ShareOne 链接并要求下载文件、修改文件、拉取/处理评论时使用此技能。当用户要求“发布”、“分享”、“生成链接”、“上线”,或者“下载这个链接的文件”、“修改这个 ShareOne 链接的内容”、“拉取这个链接的评论”时,必须使用此技能。
Generate AI chat completions using GPT-4o through the verging.ai proxy API with streaming (SSE) and non-streaming response support.
Convert text to speech audio using OpenAI TTS-1-HD through the verging.ai proxy API. Supports multiple voices, playback speed control, and various audio output formats.
Generate AI images using DALL-E 3 or gpt-image-1 through the verging.ai proxy API. Supports standard and HD quality, multiple images per request, and returns CDN-hosted image URLs.
Analyze images using GPT-4o Vision through the verging.ai proxy API, supporting both image URL (JSON) and file upload (multipart) modes.