Skip to main content
skill CX Codex

patrol-e2e-testing — Claude Code skill: what it does, how to install

patrol-e2e-testing is a skill for building and running Patrol 4.x end-to-end tests for Flutter apps, covering user flows, OS permission dialogs and cross-platform checks.

MIT ★ 674 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules
Open on GitHub

What patrol-e2e-testing does

The skill breaks a feature down into a user journey — taps, input and navigation on one side, visible outcomes like screen changes or dialogs on the other — then wraps it into a patrolTest() block using the $ tester, which locates widgets by Key, text, type or icon. A separate pattern covers native dialogs, such as granting camera access with $.native.grantPermission() or opening the notification shade.

Stability rules call for explicit wait conditions instead of fixed pauses: swap Future.delayed for waitUntilVisible, and tune settleTimeout in PatrolTesterConfig for slower CI runners. Tests live under patrol_test/, named with a _test.dart suffix, and run via patrol test, with options for browser runs, headless CI and tag filtering.

Credentials in the examples come from String.fromEnvironment rather than being hardcoded. A Flutter project needs Patrol already set up before this skill applies; it doesn't install the patrol package itself.

What it helps with

  • write an E2E test for a login flow
  • test a camera permission dialog
  • turn a UI bug into a regression test
  • check behavior across Android, iOS and Web
  • replace flaky fixed delays with proper wait conditions

Example prompts for the agent

  • Write a Patrol test for a successful login that checks homeScreenTitle
  • Add a test that grants camera permission via $.native.grantPermission()
  • Swap the hardcoded delay in this test for a waitUntilVisible check

How to install patrol-e2e-testing

1Plugin marketplace

/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules

This installs the whole flutter-ai-skills plugin with all its skills

2Skills CLI (Vercel)

npx skills add evanca/flutter-ai-rules --skill patrol-e2e-testing -a claude-code

3Manually: put the files in place

~/.claude/skills/patrol-e2e-testing/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/patrol-e2e-testing/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about patrol-e2e-testing

How do I install patrol-e2e-testing in Claude Code?

Run /plugin marketplace add evanca/flutter-ai-rules, then /plugin install flutter-ai-skills@flutter-ai-rules.

What does patrol-e2e-testing do?

It helps structure and write Patrol 4.x end-to-end tests for Flutter: user flows, native permission dialogs, and cross-platform checks. It sets conventions for test layout via patrolTest() and for avoiding flaky fixed delays.

What does this skill require?

Patrol needs to be set up as a dev dependency in the Flutter project, with tests kept under patrol_test/ and file names ending in _test.dart.

Source text

SKILL.md · MIT
---
name: patrol-e2e-testing
description: "Use when writing E2E/integration tests, testing native interactions like permissions or system dialogs, capturing UI regressions, or validating cross-platform behavior (Patrol 4.x)."
license: MIT
---

# Patrol E2E Testing Skill

Design, implement, and run end-to-end (E2E) tests using Patrol 4.x in Flutter projects.

## When to Use

Use this skill when:

* A new screen or user flow needs E2E test coverage.
* A feature interacts with native components (permissions, notifications, system dialogs, deep links).
* A UI bug should be captured as a regression test.
* Cross-platform behavior (Android / iOS / Web) must be validated.
* Setting up Patrol in a new or existing Flutter project.

## Setup

Follow the official Patrol documentation for installation and project initialization:
[https://patrol.leancode.co/documentation#setup](https://patrol.leancode.co/documentation#setup)

Key Patrol conventions:

* Add `patrol` as a dev dependency.
* Place tests in `patrol_test/`.
* Name test files with a `_test.dart` suffix.
* Execute tests with `patrol test`.

## Workflow

Follow these steps when implementing or updating Patrol tests.

### 1. Identify the user journey

Break the feature into:

* **Actions**: taps, scrolls, input, navigation, deep links.
* **Observable outcomes**: visible text, screen changes, enabled buttons, dialogs.

Rules:

* One test per primary (happy-path) journey.
* Separate tests for critical edge cases.
* Avoid combining unrelated flows in a single test.

### 2. Structure the Patrol test

Basic Patrol structure:

```dart
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';

void main() {
  patrolTest(
    'user can log in successfully',
    ($) async {
      await $.pumpWidgetAndSettle(const MyApp());

      const email = String.fromEnvironment('E2E_EMAIL');
      const password = String.fromEnvironment('E2E_PASSWORD');

      await $(#emailField).enterText(email);
      await $(#passwordField).enterText(password);
      await $(#loginButton).tap();

      await $.waitUntilVisible($(#homeScreenTitle));

      expect($(#homeScreenTitle).text, equals('Welcome'));
    },
  );
}
```

Key concepts:

* Use `patrolTest()` instead of `testWidgets()`.
* `$` is the Patrol tester.
* Use `$(#keyName)` to find widgets by `Key`.
* Use explicit wait conditions (e.g., `waitUntilVisible`).

### 3. Handle native dialogs

For OS-level permission dialogs:

```dart
patrolTest('grants camera permission', ($) async {
  await $.pumpWidgetAndSettle(const MyApp());

  await $(#openCameraButton).tap();

  if (await $.native.isPermissionDialogVisible()) {
    await $.native.grantPermission();
  }

  await $.waitUntilVisible($(#cameraPreview));
});
```

Use native automation only when required by the feature.

### 4. Selector & interaction quick reference

**Finding widgets:**

```dart
$('some text')        // by text
$(TextField)          // by type
$(Icons.arrow_back)   // by icon
```

**Tapping:**

```dart
// Tap a widget containing a specific text label
await $(Container).$('click').tap();

// Tap a container that contains an ElevatedButton
await $(Container).containing(ElevatedButton).tap();

// Tap only the enabled ElevatedButton
await $(ElevatedButton)
    .which<ElevatedButton>(
      (b) => b.enabled,
    )
    .tap();
```

**Entering text:**

```dart
// Enter text into the second TextField on screen
await $(TextField).at(1).enterText('your input');
```

**Scrolling:**

```dart
await $(widget_you_want_to_scroll_to).scrollTo();
```

**Native interactions:**

```dart
// Grant permission while app is in use
await $.native.grantPermissionWhenInUse();

// Open notification shade and tap a notification by text
await $.native.openNotifications();
await $.native.tapOnNotificationBySelector(
  Selector(textContains: 'text'),
);
```

### 5. Running Patrol tests

Run all tests:

```bash
patrol test
```

Run a specific file with live reload (development mode):

```bash
patrol develop -t integration_test/my_test.dart
```

Run a specific file:

```bash
patrol test --target patrol_test/login_test.dart
```

Run on web:

```bash
patrol test --device chrome
```

Headless web (CI):

```bash
patrol test --device chrome --web-headless true
```

Filter by tags:

```bash
patrol test --tags android
```

### 6. Stabilization patterns

Flaky tests undermine confidence. Apply these patterns:

```dart
// AVOID — arbitrary delay
await Future.delayed(Duration(seconds: 3));

// PREFER — explicit wait condition
await $.waitUntilVisible($(#targetWidget));

// For animations, pump until settled
await $.pumpAndSettle();
```

* Never use `Future.delayed` as a synchronization mechanism.
* Use `waitUntilVisible` or `waitUntilExists` to wait for UI state.
* Set `settleTimeout` in `PatrolTesterConfig` for slow CI environments.

### Output requirements

When applied, this skill produces:

1. Patrol test(s) covering the specified feature.
2. Any required widget `Key` additions to production code.
3. Exact `patrol test` command(s) to execute locally.
4. Notes explaining stabilization or timing decisions.

**Checkpoint:** Run `patrol test --target <file>` locally to confirm the test passes before committing.

### Quality bar

A valid Patrol test must be:

* **Deterministic** — no arbitrary delays; uses explicit wait conditions.
* **Readable** — clear test name describing the user journey.
* **Minimal but complete** — one assertion chain per journey.
* **Secret-safe** — credentials loaded from `String.fromEnvironment`, never hardcoded.
* **CI-ready** — passes headless with `--web-headless true` or on emulator.

© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules

Similar skills

All skills for Testing and QA →

From the same set39

The whole set →
flutter-use-column-row-first The flutter-use-column-row-first skill guides Flutter screen layouts with Row, Column, and flexible space. Use it when building a screen that must adapt to different constraints. CX Codex +1 ★ 674repo stars firebase-crashlytics Skill teaches the agent to set up Firebase Crashlytics in Flutter projects: catch fatal and non-fatal errors, log async exceptions, add custom keys, and upload obfuscated build symbols. CX Codex +1 ★ 674repo stars firebase-in-app-messaging Guides Firebase In-App Messaging setup in Flutter: trigger and suppress popups during sensitive flows, configure GDPR opt-in collection, and run tests via test device IDs. CX Codex +1 ★ 674repo stars firebase-analytics firebase-analytics is a Claude Code skill for configuring Firebase Analytics in Flutter apps. It activates for event logging, user properties, funnels, and screen-view tracking. CX Codex +1 ★ 674repo stars revenuecat-testing revenuecat-testing builds a structured QA plan for RevenueCat in-app subscriptions, verifies sandbox events, and debugs purchase restore flows. CX Codex +1 ★ 674repo stars firebase-app-check This skill guides Firebase App Check setup in Flutter, including provider choice, debug tokens, token refresh, and enforcement rollout. CX Codex +1 ★ 674repo stars flutter-best-practices flutter-best-practices is a Claude Code skill with rules for Flutter and Dart: layers, feature folders, widget choices, and tests. The agent reads the reference file matching the task. CX Codex +1 ★ 674repo stars flutter-app-architecture flutter-app-architecture enforces layered Flutter architecture with MVVM, repositories, services, and unidirectional data flow. CX Codex +1 ★ 674repo stars

Project sponsors

Companies that keep this analytics open