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
CobaltAsyncFactorybuilt from a function. -
AsyncFnParamFactory<
T extends Object, P extends Object> -
An
CobaltAsyncParamFactorybuilt 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
CobaltDecoratorbuilt from a function. -
FnFactory<
T extends Object> -
An
CobaltFactorybuilt from a function. -
FnHook<
T extends Object> -
A
CobaltHookbuilt from functions. -
FnParamFactory<
T extends Object, P extends Object> -
An
CobaltParamFactorybuilt from a function. -
ValueFactory<
T extends Object> -
An
CobaltFactorythat 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
scopecan see, and reports what happened. -
cobaltTestRoot(
{String name = 'root', List< CobaltObserver> observers = const [], List<CobaltOverride< overrides = const []}) → CobaltScopeObject> > - 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< overrides = const []}) → Future<Object> >CobaltScope> - Starts a graph and disposes it when the test ends.
-
describeGraph(
CobaltScope scope) → String -
What
scopeand the scopes below it register, as text. -
describeGraphMermaid(
CobaltScope scope) → String -
What
scopeand 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
scopecan see resolves. -
expectGraphSnapshot(
CobaltScope scope, String path, {bool? update}) → void -
Fails unless describeGraph of
scopematches the snapshot stored atpath, 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.