supertape

2019-06-24 admin

supertape是什么

什么是supertape,tape with superpowers

supertape使用教程帮助文档

Supertape NPM version Dependency Status Build Status Coverage Status

Tape with superpowers. Contains:

  • ability to catch exceptions and fail one test instead of all;
  • shows diff when test not equal or not deepEqual;
  • add jsonEqual that converts to json before checking isEqual

Install

npm i supertape -D

Codemod

You can convert your codebase from tape to supertape with help of a convert-tape-to-supertape codemod. Here is example of a result.

Example

const test = require('supertape');

test('lib: arguments', async (t) => {
    throw Error('hello');
    // will call t.fail with an error
    // will call t.end

    t.end();
});

test('lib: diff', async (t) => {
    t.equal({}, {hello: 'world'}, 'should equal');
    t.end();
});

// output
`
- Expected
+ Received

- Object {}
+ Object {
+   "hello": "world",
+ }
`

Related

  • try-to-tape - wrap tape async functions and show error on reject;
  • @cloudcmd/stub - simplest sinon.stub alternative with diff support;

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-68081.html

文章标题:supertape

回到顶部