dart-migrate-to-checks-package
Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.
Security Assessment
About dart-migrate-to-checks-package
The `dart-migrate-to-checks-package` skill is designed to help Dart developers modernize their testing code by replacing assertions from the older `package:matcher` with the more expressive `package:checks` API. This migration addresses the need for clearer, more readable, and more maintainable test code. It solves common issues associated with `expect` statements, such as limited expressiveness and lack of structured property checks, by providing a consistent and literate testing style that supports both synchronous and asynchronous expectations.
This skill offers several key capabilities. It provides detailed syntax migration guidelines for common assertion patterns, including basic equality, type checks, and property extraction. It supports chaining multiple checks using Dart's cascade operator and handles asynchronous scenarios for `Future` and `Stream` values. In addition, it integrates with Dart MCP Server tooling, allowing developers to manage dependencies, run static analysis, execute tests, and apply automated fixes seamlessly. The migration workflow includes checklists and feedback loops to iteratively validate code correctness using static analysis and test execution.
The primary users of this skill are Dart and Flutter developers who maintain test suites and wish to modernize their assertions for better readability and maintainability. It is particularly useful for teams migrating legacy test code or standardizing testing practices across a codebase. By adopting this skill, users can ensure consistent test behavior, leverage improved error diagnostics from `package:checks`, and simplify ongoing maintenance and code reviews.
FAQ
How do I start migrating my test files to use `package:checks`?
Begin by adding `package:checks` as a dev dependency using `dart pub add dev:checks`. Then import `package:checks/checks.dart` in the test files you plan to migrate and replace `expect` statements with the corresponding `check` statements according to the syntax migration guidelines.
Will this work with existing `package:test` setups?
Yes. `package:checks` works alongside `package:test`. You only need to remove `package:matcher` if it's explicitly listed, but its transitively included instances via `package:test` do not require removal.
How can I handle asynchronous assertions when migrating?
For `Future` values, await the `check` call with `.completes((result) => ...)`. For `Stream` values, use a `StreamQueue` for multiple checks or `.withQueue` for single or broadcast streams, following the provided syntax examples.
Are there automated tools to assist with migration?
Yes. Use Dart MCP Server tools such as `analyze_files` for static analysis, `run_tests` for executing tests with detailed diagnostics, and `dart_fix` for automated fixes where applicable.
What are common issues to watch for during migration?
Common issues include missing imports, incorrect generic types in `isA` checks, and unawaited futures. Using the feedback loops for static analysis and test validation ensures these issues are detected and corrected.
Install dart-migrate-to-checks-package
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dart-lang/skills