testing-with-marionette
Skill7 starsChanged 8 months agoMITView on GitHub
AI-driven Flutter E2E testing with Marionette (marionette_flutter in the app, marionette_cli or marionette_mcp to drive it). Control running Flutter apps in debug mode for smoke tests, regression checks, exploratory testing, and UI automation. Trigger when the user mentions E2E testing, UI automation, smoke tests, controlling a running Flutter app, VM Service interaction, tapping or entering text in an app, screenshots, log collection, session reports, or testing native dialogs, permissions, or WebViews. Supports named instances, direct VM service URIs, and MCP. Use for troubleshooting flaky UI flows, automating repetitive manual tests, verifying behavior after merges, and AI-agent-driven QA.
In this repository41 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- skill-creatorSkill
- flutter-dbSkill
- flutter-routingSkill
- flutter-state-managementSkill
- bloc-signalsSkill
- configuring-codemagicSkill
- applying-effective-dartSkill
- deploying-with-fastlaneSkill
- integrating-firebaseSkill
- implementing-fl-chartSkill
- integrating-google-adsSkill
- animating-flutter-widgetsSkill
- routing-with-autorouteSkill
- implementing-flutter-blocSkill
- configuring-deep-linksSkill
- persisting-data-with-driftSkill
- building-flutter-production-appsSkill
- generating-flutter-uiSkill
- routing-with-gorouterSkill
- managing-hive-storageSkill
- using-flutter-hooksSkill
- running-flutter-isolatesSkill
- managing-flutter-provider-stateSkill
- implementing-responsive-layoutsSkill
- implementing-riverpodSkill
- managing-secure-storageSkill
- flutter-setupSkill
- managing-shared-preferencesSkill
- implementing-flutter-social-authSkill
- flutter-testingSkill
- generating-freezed-modelsSkill
- configuring-github-actionsSkill
- building-jaspr-web-appsSkill
- implementing-openapi-in-dartSkill
- integrating-revenuecatSkill
- integrating-sentrySkill
- developing-serverpod-backendSkill
- building-shadcn-flutter-uiSkill
- integrating-supabaseSkill
- converting-ts-to-dartSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Run the app in debug mode (flutter run) and copy the VM service URI from the console (for example ws://127.0.0.1:8181/ws).
- Very specific: line 58
Use marionette help <command> for the current options.
- Distinctive: line 106
If a command fails with a connection error, the app may have stopped.
- Very specific: line 108
Named instance: run marionette doctor, then marionette unregister <name> to remove stale entries.
- Very specific: line 109
Direct URI: check that the URI is still correct and the app is running.
- Very specific: line 114
Prefer --key or --identifier over --text and coordinates.
- Very specific: line 115
Use press-key for keyboard events and enter-text for typing.
- Very specific: line 116
Do not rely on set-device-config unless the app wraps its root in MarionetteDeviceConfig.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Marionette — AI Agent Reference
Marionette lets an agent drive a Flutter app that runs in debug mode. It has three parts:
| Part | Where | Purpose |
marionette_flutter | your app (dev_dependencies or dependencies with a debug guard) | Exposes the widget tree and actions over the VM service |
marionette_cli | your terminal | Commands such as tap, enter-text, take-screenshots |
marionette_mcp | MCP host (Claude Code, Cursor, Copilot, Gemini CLI) | The same actions as MCP tools, without shell calls |
1. Prepare the app
flutter pub add marionette_flutterimport 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:marionette_flutter/marionette_flutter.dart';
void main() {
if (kDebugMode) {
MarionetteBinding.ensureInitialized(
const MarionetteConfiguration(enableSessionReports: true), // optional
);
} else {
WidgetsFlutterBinding.ensureInitialized();
}
runApp(const MaterialApp(home: Scaffold(body: Center(child: Text('hi')))));
}- Guard the binding with
kDebugModeso release builds never use it. This snippet was analyzed withflutter analyzeagainstmarionette_flutter0.7.0. - Standard Material widgets work without configuration. A custom design system needs
MarionetteConfiguration(isInteractiveElement,shouldStopTraversalAtElement,extractText). Note:isInteractiveWidgetandshouldStopTraversalare deprecated. enableSessionReports: truelets each CLI call write a step log (see Session reports below).set-device-configrequires the root widget to be wrapped:runApp(const MarionetteDeviceConfig(child: MyApp()));.
2. Run the app and connect
- Run the app in debug mode (
flutter run) and copy the VM service URI from the console (for examplews://127.0.0.1:8181/ws). - Choose a connection style:
- Named instance (stateful):
marionette register <name> <uri>, thenmarionette -i <name> <command>, andmarionette unregister <name>when done. - Direct URI (stateless):
marionette --uri <ws-uri> <command>. Each call opens its own connection. Nothing is stored on disk.
- Named instance (stateful):
Global options (all commands): -i, --instance <name>, --uri <ws-uri> (mutually exclusive with -i), --timeout <seconds> (default 5), --session <title>, --session-dir <path>.
3. Commands
Use marionette help <command> for the current options. All commands except register, unregister, list, doctor, mcp, and help-ai need -i <instance> or --uri <ws-uri>.
Discovery
marionette list: lists registered instances with URI and registration time.marionette doctor: checks connectivity of every registered instance. Exit 0 when all are reachable, 1 when any is not.marionette get-interactive-elements [--ancestor-keys <str>] [--compaction compact|none]: prints one line per interactive element with type, key, identifier, and text. Use the key, identifier, or text as the matcher in later commands.marionette get-logs: prints the app's collected logs.marionette help-ai: prints the full CLI reference for AI agents.
Interaction
Element matchers: --key <str> (ValueKey), --identifier <str> (Semantics identifier, stable), --text <str>, --type <str> (widget type name). Pass exactly one primary matcher. --ancestor-keys <str> limits the search to the subtree of the named element.
tap: matchers, or--x <n> --y <n>for a coordinate tap.secondary-tap: right mouse button tap, with the same matchers astap. Desktop only. It triggersonSecondaryTap(for example context menus).double-tap,long-press,pinch-zoom: same matcher rules astap. Their help text is inmarionette help <command>. They are not described inhelp-ai.enter-text --input <str>: matches a text field with--key,--identifier, or--text, or uses--focusedfor the focused field.--inputis required.press-key --key <str> [--modifiers <list>]: sends a real key event to the focused element. Named keys includeenter,tab, andescape. Modifiers are comma-separated (control,shift, ...). Example:--key a --modifiers control. Use it for submit, focus moves, and shortcuts. Useenter-textto type text.press-back-button: Android back or iOS swipe-back.swipe: matchers plus--direction left|right|up|down(required in this mode),--distance <px>(default 200). Or give explicit--start-x --start-y --end-x --end-y.scroll-to: scrolls until a matcher is visible.
Evidence
marionette take-screenshots -o <file.png> [--open]: saves a PNG.marionette record-video [--width <px>] [--height <px>] [--open] [--ffmpeg-path <path>] [--transport auto|tcp|ws] [--frame-port <port>]: records video. Requiresffmpeg. Exit 1 when ffmpeg is missing or recording fails.
App control
marionette hot-reload: hot reload.marionette hot-restart: hot restart. Resets app state.marionette set-device-config [--text-scale <n>] [--bold-text true|false] [--platform-brightness light|dark] [--reset]: simulates device settings. Requires theMarionetteDeviceConfigwrapper described above. Without it the command exits 1.
MCP
marionette mcp [--log-file <path>] [--sse-port <port>]: runs the MCP server over stdio (default) or SSE. Use this when the agent host speaks MCP. The app is still driven through the same VM service.
4. Session reports
With enableSessionReports: true in the app, every command writes a step to .marionette/sessions/<title>-<timestamp>/steps.md. Use --session <title> (under about 60 characters) to name the directory and --session-dir <path> (or MARIONETTE_SESSION_DIR) to change where it is stored.
5. Exit codes and error recovery
0 Success 1 Runtime error (connection failed, command failed, app unreachable, ffmpeg missing) 64 Usage error (missing arguments, invalid options)
If a command fails with a connection error, the app may have stopped.
- Named instance: run
marionette doctor, thenmarionette unregister <name>to remove stale entries. Re-runflutter runand register the new URI. - Direct URI: check that the URI is still correct and the app is running. Re-run
flutter runif needed.
6. Constraints
- Debug mode only. Keep the
kDebugModeguard so the binding never ships. - Prefer
--keyor--identifierover--textand coordinates. Text changes with locale, and coordinates change with layout. - Use
press-keyfor keyboard events andenter-textfor typing. They behave differently. - Do not rely on
set-device-configunless the app wraps its root inMarionetteDeviceConfig. - For a custom design system, configure
MarionetteConfigurationbefore you start testing. Otherwise the agent cannot see your custom buttons.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

