Code Monkey home page Code Monkey logo

blue-tape's Introduction

This project is no longer maintained.

The best option is to switch to a library that supports promises - either https://github.com/jprichardson/tape-promise or https://github.com/tapjs/node-tap - or perhaps its time to revisit tape-testing/tape#262 and add promise support to tape.


blue-tape

Tape with promise support.

Usage

Same as tape, except if you return a promise from a test, it will be checked for errors. If there are no errors, the test will end. Otherwise the test will fail. This means there is no need to use t.plan() or t.end().

Also provides t.shouldFail(promise P, optional class|regex expected, optional message) (as well as the alias shouldReject) which returns a new promise that resolves successfully if P rejects. If you provide the optional class, or regex then it additionally ensures that err is an instance of that class or that the message matches the regular expression. The behaviour is identical to tape's throws assertion.

Examples

Assuming delay() returns a promise:

const test = require('blue-tape');

test("simple delay", function(t) {
    return delay(1);
});

test("should fail", function(t) {
    return delay(1).then(function() {
        throw new Error("Failed!");
    });
});

Assuming failDelay() returns a promise that rejects with a DerpError:

test("promise fails but test succeeds", function(t) {
    return t.shouldFail(failDelay(), DerpError);
});

License

MIT

blue-tape's People

Contributors

dcposch avatar dependabot[bot] avatar nkbt avatar odogono avatar radiovisual avatar rangermauve avatar scothis avatar spion avatar tuckerconnelly avatar wavded avatar

Watchers

 avatar  avatar  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.