spec 0.2.3 copy "spec: ^0.2.3" to clipboard
spec: ^0.2.3 copied to clipboard

A streamlined testing framework for Dart & Flutter.

example/example.dart

import 'package:spec/spec.dart';

void main() {
  test('example', () {
    var count = 0;

    expect(count).toEqual(0);

    count++;

    expect(count).not.toEqual(0);
    expect(count).toEqual(1);
  });

  test('future example', () async {
    final future = Future.value(42);

    // await expect(future).toEqual(42); // does not compile
    expect(future).toEqual(future); // OK

    await expect(future).completion.toEqual(42);
    // expect(42).resolve.toEqual(42); // does not compile

    await expect(future).throws.isArgumentError();
  });

  test('stream example', () async {
    final stream = Stream.value(42);

    await expect(stream).emits.toEqual(42);
    await expect(stream).emits.isNull();
    await expect(stream).emits.not.isNull();

    await expect(stream).emitsError.isArgumentError();
  });

  test('function example', () {
    void throwsFn() => throw Error();

    expect(throwsFn).returnsNormally();
    expect(throwsFn).throws.isArgumentError();
  });

  test('num example', () {
    expect(42).toEqual(42);
    expect(42).lessThan(42);
  });

  test('bool example', () {
    expect(true).isTrue();
  });

  test('string example', () {
    expect('hello').equalsIgnoringCase('HELLO');
  });
}
47
likes
140
pub points
70%
popularity

Publisher

verified publisherinvertase.io

A streamlined testing framework for Dart & Flutter.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

meta, test

More

Packages that depend on spec