tesuto
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

Build Status npm version

tesuto logo

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()

Package Sidebar

Install

npm i tesuto

Weekly Downloads

6

Version

2.1.1

License

MIT

Unpacked Size

126 kB

Total Files

23

Last publish

Collaborators

  • dgellow