22 Star 218 Fork 230

记得要让着本宝宝/ckjcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
_includes
_layouts
_posts
css
fonts
img
js
less
node_modules
.bin
abbrev
align-text
amdefine
ansi-regex
ansi-styles
argparse
asn1
assert-plus
async
aws-sign2
boom
browserify-zlib
buffer-from
camelcase
center-align
chalk
clean-css
cliui
coffee-script
colors
combined-stream
commander
concat-stream
core-util-is
cryptiles
ctype
dateformat
debug
decamelize
deep-equal
defined
delayed-stream
escape-string-regexp
esprima
eventemitter2
exit
faye-websocket
figures
findup-sync
forever-agent
form-data
gaze
getobject
glob
globule
graceful-fs
grunt-contrib-less/node_modules
grunt-contrib-uglify/node_modules
grunt-contrib-watch/node_modules
grunt-legacy-log-utils
grunt-legacy-log
grunt-legacy-util
gzip-size
has-ansi
has-color
hawk
hoek
hooker
http-signature
iconv-lite
inherits
ip-regex
is-buffer
isarray
js-yaml
json-stringify-safe
jsonify
kind-of
lazy-cache
less
lodash
longest
lru-cache
maxmin
mime-types
mime
minimatch
minimist
mkdirp
natives
node-uuid
nopt
noptify
oauth-sign
object-assign
pako
pretty-bytes
process-nextick-args
psl
punycode
qs
readable-stream
repeat-string
request
right-align
rimraf
safe-buffer
sigmund
sntp
source-map
string_decoder
stringstream
strip-ansi
supports-color
tape
example
lib
test
.npmignore
.travis.yml
LICENSE
index.js
package.json
readme.markdown
tiny-lr-fork
tough-cookie
tunnel-agent
typedarray
uglify-js
uglify-to-browserify
underscore.string
underscore
util-deprecate
which
window-size
wordwrap
yargs
zlib-browserify
pwa
.gitignore
404.html
ChengKeJ.github.io.iml
Graph Bed.md
Gruntfile.js
LICENSE
README.md
_config.yml
about.html
chengkej.io.iml
codecov.yml
feed.xml
index.html
offline.html
package-lock.json
package.json
sw.js
tags.html
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

tape

tap-producing test harness for node and browsers

build status

tape

browser compatibility

chrome, firefox, opera, safari, IE6, IE7, IE8, IE9

using browserify@1.16.5

example

var test = require('tape');

test('timing test', function (t) {
    t.plan(2);
    
    t.equal(typeof Date.now, 'function');
    var start = Date.now();
    
    setTimeout(function () {
        t.equal(Date.now() - start, 100);
    }, 100);
});
$ node example/timing.js
TAP version 13
# timing test
ok 1 should be equal
not ok 2 should be equal
  ---
    operator: equal
    expected: 100
    actual:   107
  ...

1..2
# tests 2
# pass  1
# fail  1

methods

The assertion methods in tape are heavily influenced or copied from the methods in node-tap.

var test = require('tape')

test(name, cb)

Create a new test with an optional name string. cb(t) fires with the new test object t once all preceeding tests have finished. Tests execute serially.

If you forget to t.plan() out how many assertions you are going to run and you don't call t.end() explicitly, your test will hang.

t.plan(n)

Declare that n assertions should be run. t.end() will be called automatically after the nth assertion. If there are any more assertions after the nth, or after t.end() is called, they will generate errors.

t.end()

Declare the end of a test explicitly.

t.fail(msg)

Generate a failing assertion with a message msg.

t.pass(msg)

Generate a passing assertion with a message msg.

t.skip(msg)

Generate an assertion that will be skipped over.

t.ok(value, msg)

Assert that value is truthy with an optional description message msg.

Aliases: t.true(), t.assert()

t.notOk(value, msg)

Assert that value is falsy with an optional description message msg.

Aliases: t.false(), t.notok()

t.error(err, msg)

Assert that err is falsy. If err is non-falsy, use its err.message as the description message.

Aliases: t.ifError(), t.ifErr(), t.iferror()

t.equal(a, b, msg)

Assert that a === b with an optional description msg.

Aliases: t.equals(), t.isEqual(), t.is(), t.strictEqual(), t.strictEquals()

t.notEqual(a, b, msg)

Assert that a !== b with an optional description msg.

Aliases: t.notEquals(), t.notStrictEqual(), t.notStrictEquals(), t.isNotEqual(), t.isNot(), t.not(), t.doesNotEqual(), t.isInequal()

t.deepEqual(a, b, msg)

Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with an optional description msg.

Aliases: t.deepEquals(), t.isEquivalent(), t.looseEqual(), t.looseEquals(), t.same()

t.notDeepEqual(a, b, msg)

Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with an optional description msg.

Aliases: t.notEquivalent(), t.notDeeply(), t.notSame(), t.isNotDeepEqual(), t.isNotDeeply(), t.isNotEquivalent(), t.isInequivalent()

t.throws(fn, expected, msg)

Assert that the function call fn() throws an exception.

t.doesNotThrow(fn, expected, msg)

Assert that the function call fn() does not throw an exception.

t.test(name, cb)

Create a subtest with a new test handle st from cb(st) inside the current test t. cb(st) will only fire when t finishes. Additional tests queued up after t will not be run until all subtests finish.

var htest = test.createHarness()

Create a new test harness instance, which is a function like test(), but with a new pending stack and test state.

By default the TAP output goes to process.stdout or console.log() if the environment doesn't have process.stdout. You can pipe the output to someplace else if you test.stream.pipe() to a destination stream on the first tick.

test.only(name, cb)

Like test(name, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored

install

With npm do:

npm install tape

license

MIT

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ckjcode/ckjcode.git
git@gitee.com:ckjcode/ckjcode.git
ckjcode
ckjcode
ckjcode
master

搜索帮助