cobalt_test library

Test helpers for Cobalt.

Pure Dart on test_api and matcher rather than the full test runner, so the same helpers work under dart test and flutter test without a second package and without putting flutter_test in anything that does not need it.

Classes

AsyncFnFactory<T extends Object>
An CobaltAsyncFactory built from a function.
AsyncFnParamFactory<T extends Object, P extends Object>
An CobaltAsyncParamFactory built from a function.
CapturingObserver
Collects every event a graph emits, for tests that assert on them.
CobaltGraphEntry
One key's result.
CobaltGraphReport
The result of walking a graph and resolving everything in it.
DisposeRecorder
Records the order things were torn down in.
FnDecorator<T extends Object>
An CobaltDecorator built from a function.
FnFactory<T extends Object>
An CobaltFactory built from a function.
FnHook<T extends Object>
A CobaltHook built from functions.
FnParamFactory<T extends Object, P extends Object>
An CobaltParamFactory built from a function.
ValueFactory<T extends Object>
An CobaltFactory that always returns the same value.

Enums

CobaltGraphOutcome
What one key did when a graph was checked.

Extensions

CobaltTestScope on CobaltScope
Helpers for overriding part of a graph in a test.

Functions

checkGraph(CobaltScope scope, {Map<CobaltKey, Object> params = const {}}) → Future<CobaltGraphReport>
Resolves everything scope can see, and reports what happened.
cobaltTestRoot({String name = 'root', List<CobaltObserver> observers = const [], List<CobaltOverride<Object>> overrides = const []}) → CobaltScope
A bare root scope, disposed when the test ends.
cobaltTestScope({required CobaltScopeBuilder root, List<CobaltBootstrapStep> bootstrap = const [], String rootName = 'root', List<CobaltObserver> observers = const [], List<CobaltOverride<Object>> overrides = const []}) → Future<CobaltScope>
Starts a graph and disposes it when the test ends.
describeGraph(CobaltScope scope) → String
What scope and the scopes below it register, as text.
describeGraphMermaid(CobaltScope scope) → String
What scope and the scopes below it register, as a Mermaid flowchart.
expectGraphResolves(CobaltScope scope, {Map<CobaltKey, Object> params = const {}}) → Future<void>
Fails the test unless every registration scope can see resolves.
expectGraphSnapshot(CobaltScope scope, String path, {bool? update}) → void
Fails unless describeGraph of scope matches the snapshot stored at path, relative to the package the tests run in.
expectGraphSnapshots(FutureOr<CobaltScope> graphOf(CobaltEnvironment environment), {required Iterable<CobaltEnvironment> environments, required String directory, bool? update}) → Future<void>
expectGraphSnapshot for each of environments, one file each: <directory>/<environment name>.txt.