tape-await

Yet another async-await helper for tape.

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.

Repository

https://github.com/mbostock/tape-await.git


上一篇:custom-guider
下一篇:vega-label

相关推荐

公众号

欢迎 JavaScript 爱好者