Skip to content

Add testMode config to debug tests via the DAP --test flag#97

Open
FrantisekGazo wants to merge 1 commit into
zed-extensions:mainfrom
FrantisekGazo:feat/test-mode-debugging
Open

Add testMode config to debug tests via the DAP --test flag#97
FrantisekGazo wants to merge 1 commit into
zed-extensions:mainfrom
FrantisekGazo:feat/test-mode-debugging

Conversation

@FrantisekGazo

Copy link
Copy Markdown
Contributor

What

Adds an optional boolean testMode to the debug configuration. When true, the extension spawns the debug adapter with the --test flag ([fvm] flutter|dart debug_adapter --test), so program runs via flutter test / dart test instead of flutter run / dart run. Works for both "type": "flutter" and "type": "dart". Default false — existing configs are unaffected.

{
  "label": "Debug current test file",
  "adapter": "Dart",
  "type": "flutter",
  "request": "launch",
  "program": "$ZED_FILE",
  "cwd": "$ZED_DIRNAME",
  "testMode": true
}

Why

There was previously no way to debug a test the way it actually executes under flutter test (headless flutter_tester, AutomatedTestWidgetsFlutterBinding, goldens, …). The only workaround was flutter test --start-paused plus a manual attach with a freshly pasted vmServiceUri on every run. The Dart/Flutter SDKs ship this as a mode of the same adapter — see the Flutter DAP README (--[no-]test); the extension just never exposed it.

Changes

  • src/dart.rs — read testMode; append --test to the adapter arguments; skip the deviceId → toolArgs -d <id> injection in test mode (flutter test runs headless — device selection is a flutter run concept, and users who need -d for integration tests can still pass it via toolArgs).
  • debug_adapter_schemas/Dart.json — declare testMode (schema has additionalProperties: false); remove the dead "test" value from the flutterMode enum — the DAP treats flutterMode as a build mode (debug/profile/release), so "test" never did anything and would now be mistaken for this switch.
  • README.md — "Debugging tests" section with the config above.

In test mode toolArgs keep their existing meaning — the DAP forwards them to flutter test / dart test (e.g. --plain-name, --tags).

Tested

  • flutter + testMode: true on a widget test: headless flutter test run, breakpoints/stepping/variables work; toolArgs: ["--plain-name", …] narrows to a single test.
  • Regression: existing flutter run launch and attach configs behave unchanged with testMode unset.

@cla-bot cla-bot Bot added the cla-signed label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant