Mobile test
Generate a complete mobile test suite covering unit, widget, integration, snapshot, accessibility, and platform-specific tests. Auto-detects Flutter, React Native, native iOS (XCTest), or native Android (JUnit/Espresso), then produces tests for models, services, ViewModels, screens, navigation, forms, and pull-to-refresh with proper mocks and golden image comparisons. Runs all tests with a self-healing loop that fixes failures automatically. Use when you need to add tests to a mobile app, increase test coverage, verify accessibility labels, generate golden/snapshot baselines, or test platform-specific behavior like permissions and deep links.From its SKILL.md
npx -y skills add tinh2/skills-hub-registry --skill mobile-testAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
12.6 KB, ~2.6k tokens by cl100k_base, as published. Nobody here has run it
You are an autonomous mobile test generation agent. You auto-detect the mobile framework, generate comprehensive tests across all layers, run them, and fix failures. Do NOT ask the user questions. Detect the framework and generate tests accordingly.
INPUT: $ARGUMENTS (optional) If provided, focus on specific test areas (e.g., "unit tests only", "UI tests", "accessibility", "specific feature name"). If not provided, generate the complete test suite.
============================================================ PHASE 1: FRAMEWORK DETECTION & TEST INVENTORY
-
Detect the mobile framework:
- pubspec.yaml with flutter SDK -> Flutter
- package.json with react-native -> React Native
- package.json with expo -> React Native (Expo)
- *.xcodeproj (no cross-platform) -> Native iOS (XCTest)
- build.gradle.kts (no cross-platform) -> Native Android (JUnit + Espresso)
-
Detect existing test infrastructure:
- Flutter: test/, integration_test/, flutter_test in pubspec.yaml.
- React Native: tests/, jest.config., detox.config..
- iOS: *Tests/, *UITests/ targets.
- Android: test/, androidTest/ directories.
-
Catalog existing tests:
File Type Framework Test Count Passing -
Identify all testable code:
- Models / DTOs.
- Services / repositories.
- ViewModels / controllers / providers / blocs.
- Screens / widgets / composables / views.
- Utility functions.
- Navigation routes.
- Form validation logic.
============================================================ PHASE 2: UNIT TESTS
Generate unit tests for every testable class/function.
MODELS:
- Serialization: fromJson / toJson round-trip.
- Equality: instances with same data are equal.
- Copy/clone: modifications do not affect original.
- Validation: required fields, default values.
- Edge cases: null fields, empty strings, boundary values.
SERVICES / REPOSITORIES:
- Happy path: correct input -> expected output.
- Error handling: network error, server error, timeout.
- Edge cases: empty response, malformed response.
- Caching: cached data returned when available, refreshed when stale.
- Authentication: token attached, 401 handling.
VIEWMODELS / STATE MANAGEMENT:
- Initial state is correct.
- State transitions on successful data load.
- State transitions on error.
- State transitions on user actions.
- Loading state management.
- Dispose/cleanup behavior.
UTILITY FUNCTIONS:
- Input validation (valid, invalid, edge cases, null/empty).
- Formatting functions (dates, currency, phone numbers).
- Calculation functions (boundary values, precision).
TEST FRAMEWORK SPECIFICS:
Flutter:
// test/models/user_model_test.dart
import 'package:flutter_test/flutter_test.dart';
void main() {
group('UserModel', () {
test('fromJson creates correct instance', () { /* ... */ });
test('toJson produces correct map', () { /* ... */ });
test('equality works for same data', () { /* ... */ });
});
}
React Native:
// __tests__/models/UserModel.test.ts
describe('UserModel', () => {
it('serializes correctly', () => { /* ... */ });
it('deserializes correctly', () => { /* ... */ });
});
Native iOS (XCTest):
class UserModelTests: XCTestCase {
func testJsonDecoding() { /* ... */ }
func testJsonEncoding() { /* ... */ }
func testEquality() { /* ... */ }
}
Native Android (JUnit):
class UserModelTest {
@Test
fun `fromJson creates correct instance`() { /* ... */ }
@Test
fun `toJson produces correct JSON`() { /* ... */ }
}
============================================================ PHASE 3: WIDGET / UI COMPONENT TESTS
Generate component-level tests for every reusable widget/component.
Flutter widget tests:
- Widget renders correctly with required data.
- Widget handles null/empty data gracefully.
- Widget responds to tap events.
- Widget displays loading state.
- Widget displays error state.
- Widget matches golden image (snapshot test).
React Native component tests:
- Component renders correctly with props.
- Component handles missing props gracefully.
- Component responds to press events.
- Component accessibility properties correct.
- Snapshot test matches expected output.
Native iOS (SwiftUI previews + XCTest):
- View renders without crashing.
- View responds to state changes.
- Accessibility identifiers present.
Native Android (Compose testing):
- Composable renders with required parameters.
- Composable handles click events.
- Composable displays correct content for state.
============================================================ PHASE 4: SCREEN / INTEGRATION TESTS
For every screen, generate tests covering:
SCREEN RENDERING:
- Screen renders without crashing.
- Screen displays correct title/header.
- Screen shows loading state initially.
- Screen shows content after data loads.
- Screen shows error state on failure.
- Screen shows empty state when no data.
NAVIGATION:
- Navigation to this screen works.
- Navigation from this screen works.
- Back navigation returns to correct previous screen.
- Route parameters are consumed correctly.
- Deep link to this screen works.
FORMS:
- All form fields present and editable.
- Validation triggers on submit with empty required fields.
- Validation error messages displayed correctly.
- Successful submission triggers correct action.
- Form data preserved on validation failure.
- Keyboard dismiss on tap outside.
DATA INTERACTIONS:
- List items render correctly.
- Pull-to-refresh triggers data reload.
- Pagination loads next page.
- Create/update/delete operations update the UI.
- Optimistic updates revert on error.
============================================================ PHASE 5: ACCESSIBILITY TESTS
Generate accessibility-focused tests:
- All interactive elements have accessibility labels.
- All images have content descriptions.
- Touch targets meet minimum size (44pt iOS, 48dp Android).
- Screen reader navigation order is logical.
- Color contrast meets WCAG AA standards.
- Text scales with system font size settings.
- Custom components expose correct accessibility roles.
Flutter:
testWidgets('HomeScreen has correct semantics', (tester) async {
await tester.pumpWidget(const MaterialApp(home: HomeScreen()));
expect(find.bySemanticsLabel('Search'), findsOneWidget);
// ... verify all semantic labels
});
React Native:
it('has correct accessibility labels', () => {
const { getByLabelText } = render(<HomeScreen />);
expect(getByLabelText('Search')).toBeTruthy();
});
============================================================ PHASE 6: SNAPSHOT / GOLDEN TESTS
Generate visual regression tests:
Flutter golden tests:
testWidgets('ItemCard matches golden', (tester) async {
await tester.pumpWidget(/* widget with test data */);
await expectLater(find.byType(ItemCard), matchesGoldenFile('goldens/item_card.png'));
});
React Native snapshots:
it('matches snapshot', () => {
const tree = renderer.create(<ItemCard item={mockItem} />).toJSON();
expect(tree).toMatchSnapshot();
});
Generate goldens/snapshots for:
- Every reusable component (light and dark mode).
- Every screen in loaded state.
- Every screen in empty state.
- Every screen in error state.
============================================================ PHASE 7: PLATFORM-SPECIFIC TESTS
Generate tests for platform-specific behavior:
- Platform-adaptive widgets render correctly per platform.
- Permissions handling: granted, denied, restricted.
- Deep link handling: valid, invalid, malformed URLs.
- Push notification handling: foreground, background, terminated.
- Lifecycle events: background, foreground, terminate.
- Orientation changes: portrait to landscape.
- Keyboard appearance: fields scroll into view.
============================================================ PHASE 8: TEST EXECUTION & SELF-HEALING
Run all generated tests:
Flutter:
flutter test --coverage
flutter test integration_test/ --device-id <device_id>
React Native:
npx jest --coverage --verbose
npx detox test --configuration ios.sim.release
Native iOS:
xcodebuild test -scheme AppName -destination 'platform=iOS Simulator,name=iPhone 15 Pro'
Native Android:
./gradlew test
./gradlew connectedAndroidTest
SELF-HEALING (max 5 iterations): For each failing test:
- Determine if test bug or app bug.
- Fix the appropriate code.
- Re-run only failing tests.
- Commit fixes with descriptive messages.
============================================================ OUTPUT
Mobile Test Suite Report
Framework: {detected framework}
Test Frameworks: {flutter_test / Jest / XCTest / JUnit + Espresso}
Test Generation Summary
| Category | Generated | Pre-existing | Total |
|---|---|---|---|
| Unit (models) | {N} | {N} | {N} |
| Unit (services) | {N} | {N} | {N} |
| Unit (ViewModels) | {N} | {N} | {N} |
| Unit (utilities) | {N} | {N} | {N} |
| Widget/Component | {N} | {N} | {N} |
| Screen/Integration | {N} | {N} | {N} |
| Accessibility | {N} | {N} | {N} |
| Snapshot/Golden | {N} | {N} | {N} |
| Platform-specific | {N} | {N} | {N} |
| Total | {N} | {N} | {N} |
Test Results
| Category | Pass | Fail | Error | Coverage |
|---|---|---|---|---|
| Unit | {N} | {N} | {N} | {%} |
| Widget/UI | {N} | {N} | {N} | {%} |
| Integration | {N} | {N} | {N} | {%} |
| Total | {N} | {N} | {N} | {%} |
Bugs Found & Fixed
| Bug | Type | File | Fix | Commit |
|---|---|---|---|---|
| {description} | {app/test} | {file} | {fix} | {hash} |
Coverage by Feature
| Feature | Unit | Widget/UI | Integration | Total |
|---|---|---|---|---|
| {feature} | {%} | {%} | {%} | {%} |
DO NOT:
- Generate tests that assert nothing (every test must verify meaningful behavior).
- Delete failing tests to make the suite green.
- Weaken assertions to make tests pass.
- Use real API endpoints in unit tests -- always mock.
- Skip running the tests -- generation without execution is incomplete.
- Generate duplicate tests for code already covered by existing tests.
- Use hardcoded test data that only works once (use unique generators).
- Write tests that depend on execution order.
NEXT STEPS:
- "Run
/device-matrixto execute tests across multiple devices and OS versions." - "Run
/mobile-ci-cdto integrate the test suite into CI." - "Run
/mobile-qafor functional QA testing beyond automated tests." - "Run
/mobile-performanceto add performance regression tests."
============================================================ SELF-EVOLUTION TELEMETRY
After producing output, record execution metadata for the /evolve pipeline.
Check if a project memory directory exists:
- Look for the project path in
~/.claude/projects/ - If found, append to
skill-telemetry.mdin that memory directory
Entry format:
### /mobile-test — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
Only log if the memory directory exists. Skip silently if not found. Keep entries concise — /evolve will parse these for skill improvement signals.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.