一键导入
dart-migrate-to-checks-package
// Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.
// Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.
Collect coverage using the coverage packge and create an LCOV report
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.
Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
| name | dart-migrate-to-checks-package |
| description | Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents. |
| metadata | {"model":"models/gemini-3.1-pro-preview","last_modified":"Fri, 24 Apr 2026 15:15:22 GMT"} |
Manage dependencies using the Dart Tooling MCP Server pub tool or standard CLI commands.
package:checks as a dev_dependency using dart pub add dev:checks.package:matcher if it is explicitly listed in the pubspec.yaml (note: it is often transitively included by package:test, which is fine).package:checks/checks.dart in all test files undergoing migration.Transition test assertions from the package:matcher syntax to the literate API provided by package:checks.
expect(actual, equals(expected)) or expect(actual, expected) with check(actual).equals(expected).expect(actual, isA<Type>()) with check(actual).isA<Type>().expect(actual.property, expected) with check(actual).has((a) => a.property, 'property name').equals(expected)...) to chain multiple expectations on a single subject.Future, await the check call: await check(someFuture).completes((r) => r.equals(expected));.Stream, wrap it in a StreamQueue for multiple checks, or use .withQueue for single/broadcast checks.Copy and use the following checklist to track progress when migrating a test suite:
package:checks as a dev dependency.package:matcher (expect calls).package:checks/checks.dart in target test files.expect(...) statements to check(...) statements.analyze_files).run_tests).analyze_files tool on the modified test directories.isA, unawaited futures).run_tests tool.package:checks provides detailed context (e.g., Which: has length of <2>).check() expectations or the underlying code to resolve the failure.Input (matcher):
expect(someList.length, 1);
expect(someString, startsWith('a'));
expect(someObject, isA<Map>());
Output (checks):
check(someList).length.equals(1);
check(someString).startsWith('a');
check(someObject).isA<Map>();
Input (matcher):
expect('foo,bar,baz', allOf([
contains('foo'),
isNot(startsWith('bar')),
endsWith('baz')
]));
Output (checks):
check('foo,bar,baz')
..contains('foo')
..not((s) => s.startsWith('bar'))
..endsWith('baz');
Input (matcher):
expect(Future.value(10), completion(equals(10)));
expect(Future.error('oh no'), throwsA(equals('oh no')));
Output (checks):
await check(Future.value(10)).completes((it) => it.equals(10));
await check(Future.error('oh no')).throws<String>().equals('oh no');
Input (matcher):
var stdout = StreamQueue(Stream.fromIterable(['Ready', 'Go']));
await expectLater(stdout, emitsThrough('Ready'));
Output (checks):
var stdout = StreamQueue(Stream.fromIterable(['Ready', 'Go']));
await check(stdout).emitsThrough((it) => it.equals('Ready'));