substack's tape test runner with promise support
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin Standardize Jan 24, 2016
test Make shouldFail behave like throws Sep 5, 2016
.gitignore initial commit Oct 10, 2013
.npmignore initial commit Oct 10, 2013
README.md Make shouldFail behave like throws Sep 5, 2016
blue-tape.js Make shouldFail behave like throws Sep 5, 2016
package.json 1.0.0 Sep 5, 2016

README.md

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