GithubHelp home page GithubHelp logo

isabella232 / spec-9 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from invertase/spec

0.0 0.0 0.0 2.72 MB

✅ A streamlined testing framework for Dart & Flutter.

Home Page: https://docs.page/invertase/spec

License: Apache License 2.0

Dart 99.49% Batchfile 0.14% Shell 0.37%

spec-9's Introduction

✅ Spec

A streamlined testing framework for Dart & Flutter.

Melos docs.page

What is it?

Spec builds on-top of existing Dart & Flutter testing tools to provide a streamlined & elegant testing environment. Spec provides both a CLI tool and Dart package.

CLI

The Spec CLI allows you to run the spec command from your CLI environment and run your tests:

  • Intuitive testing output interface, inspired by Jest.
  • Interactive CLI (via spec --watch); automatically re-run tests when source code changes & rerunning of only failed tests.
  • Run both Dart & Flutter tests in parallel with a single command.
  • Run tests from multiple packages at the same time using Melos.

spec

Package

The spec package provides a different take on how to write tests. Designed with type-safety and IDE autocompletion in mind, spec alters the way you write your tests to be more declarative, less error prone and force good habits.

Getting Started

Matchers

Spec CLI works alongside normal Dart test matchers, however also ships with custom matchers, see the API reference docs.

Example of testing using Spec matchers:

import 'package:spec/spec.dart';

void main() {
  test('future example', () async {
    final future = Future.value(42);
    expect(future).toEqual(future);
    await expect(future).completion.toEqual(42);
    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();
  });
}

CLI

Installation

dart pub global activate spec_cli

Usage

Run tests:

spec

Run tests in interactive mode:

spec --watch

Interactive mode supports a number of keyboard shortcuts:

Watch Usage:
 › Press f to run only failed tests.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

LICENSE

Built and maintained by Invertase.

spec-9's People

Contributors

rrousselgit avatar salakar avatar ehesp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.