jashkenas / tape-await

Yet another async-await helper for tape.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tape-await

A synchronous test without test.end:

tape("42 is a number", test => {
  test.equal(typeof 42, "number");
});

A synchronous test that throws an error which is treated as a failure:

tape("errors are failures", test => {
  throw new Error("fail");
});

An asynchronous test:

tape("promises are great", async test => {
  await new Promise(resolve => setTimeout(resolve, 250));
  test.ok(true);
});

This module is similar to tape-async, tape-promise, and blue-tape. One difference is that it also provides implicit test.end for synchronous tests, rather than only providing it for asynchronous tests. Another is that it correctly handles rejected promises with falsey values, such as Promise.reject(). Also, it only supports promises and not generators, and does not attempt to deal with unhandled promise rejections or uncaught exceptions.

About

Yet another async-await helper for tape.

License:ISC License


Languages

Language:JavaScript 100.0%