tesuto
v2.1.1
Published
Tiny test reporting library
Downloads
16
Maintainers
Readme
tesuto
A really tiny test reporting library with one unique dependency.
$ yarn add --dev tesuto
$ npm install --save-dev tesuto
Usage
import assert from "assert"
import {testing, report, result} from "tesuto"
function add (x, y) {
return x + y
}
// Report a test
report("add numbers", function () {
assert.equal(add(1, 2), 3)
assert.equal(add(2, 2), 4)
})
// Define a group of tests
testing("add function", function () {
report("when first arg is a string, concatenate", function () {
assert.equal(add("hello_", "you"), "hello_you")
assert.equal(add("hello_", 2), "hello_2")
})
// Groups can be nested
testing("with numbers", function() {
report("should be associative", function () {
assert.equal(add(1, 2), 3)
assert.equal(add(2, 1), 3)
})
report("should support negative numbers", function () {
assert.equal(add(-1, -2), -3)
assert.equal(add(1, -2), -1)
})
})
})
result()
API
report
, define a test
report("add numbers", function () {
assert.equal(add(1, 2), 3)
assert.equal(add(2, 2), 4)
})
testing
, define a group of tests
Note: Groups can be nested
testing("add function", function () {
report("when first arg is a string, concatenate", function () {
assert.equal(add("hello_", "you"), "hello_you")
assert.equal(add("hello_", 2), "hello_2")
})
})
result
, print statistics
result()