Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.15 KB

README.md

File metadata and controls

40 lines (29 loc) · 1.15 KB

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);
});

To install:

yarn add --dev tape@4 tape-await

To use, require tape-await instead of tape:

const tape = require("tape-await");

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.