checks
0.4.0, released yesterday by labs.dart.dev
A framework for checking test expectations against values and building custom expectations.
What it does
Provides a literate API to express test expectations and build custom expectations. It allows checking values with descriptive failures, cascading assertions, and support for asynchronous values and streams.
AI-written summary of version 0.4.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are writing unit or widget tests in Dart and want a literate expectation API.
- You need to build custom expectations for your own types.
Skip it when
- You are writing production code (this package is strictly for testing).
- You rely on production use cases where experimental packages with frequent breaking changes are an issue.
Strengths
- Literate and readable API using cascade syntax and dot shorthands.
- Robust support for asynchronous expectations and streams.
- Clear failure reporting with detailed expectations.
Weaknesses
- Still experimental with a high expected rate of API and breaking changes.
- For production use cases, package:test and package:matcher are recommended instead.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Add a dev_dependency on checks and import package:checks/checks.dart in your test code.
void main() {
test('sample test', () {
check(actual).equals(expected);
check(someList).isNotEmpty;
check(someObject).isA<Map>();
check(someString)..startsWith('a')..endsWith('z')..contains('lmno');
});
}Alternatives
Packages that do the same job and could replace checks.
- analysis_server_plugin
Framework and support code for building plugins for the Dart analysis server.
85Compare
Works with
Packages commonly used together with checks: ones it builds on, ones built on it, and its own family.
- asyncchecks depends on itUtility classes and helpers that extend Dart's async library.
- test_apichecks depends on itThe user facing API for structuring Dart tests and checking expectations.
- spotBuilt on checksToolkit for Flutter widget tests with chainable selectors and automatic timeline reports.
- kana_kitBuilt on checksDetect and transliterate Japanese Hiragana, Katakana, and Romaji.