Skip to content

Latest commit

 

History

History
112 lines (80 loc) · 3.52 KB

README.md

File metadata and controls

112 lines (80 loc) · 3.52 KB

Test Harness Ultra

Latest version Dependency status

Blazingly fast, tiny and simple JavaScript test framework for both Node.js and the browser with pluggable reporters and an optional runner.

  • Tiny size - 2.04 kB minified, 1 kB gzipped, 886 B brotlied (UMD).
  • Zero dependencies.
  • ESM, CJS and UMD support for Node.js and web browser.
  • TypeScript declarations included.

See the documentation of the packages for more information.

Synopsis

CJS:

const test = require('tehanu')('sum'),
      { equal } = require('assert'),
      sum = require('./sum')

test('one number', () => equal(sum(1), 1))
test('two numbers', () => equal(sum(1, 2), 3))

ESM in Node.js:

import tehanu from 'tehanu'
import { equal } from 'assert'
import sum from './sum.mjs'

const test = tehanu('sum')

test('one number', () => equal(sum(1), 1))
test('two numbers', () => equal(sum(1, 2), 3))

ESM in Node.js (unnamed suite):

import test from 'tehanu/suite'
import { equal } from 'assert'
import sum from './sum.mjs'

test('one number', () => equal(sum(1), 1))
test('two numbers', () => equal(sum(1, 2), 3))

UMD in browser:

<script src="node_modules/tehanu/dist/index.min.js"></script>
<script src="node_modules/tehanu-repo-tape/dist/index.min.js"></script>
<script src="node_modules/tehanu-teas/dist/index.min.js"></script>
<script src="sum.js"></script>
<script>
  const test = tehanu('sum'),
        { equal } = tehanuTeas

  test('one number', () => equal(sum(1), 1))
  test('two numbers', () => equal(sum(1, 2), 3))
</script>

ESM in browser:

<script type="module">
  import test from './node_modules/tehanu/dist/suite.min.mjs?name=sum'
  import './node_modules/tehanu-repo-tape/dist/index.min.mjs'
  import { equal } from './node_modules/tehanu-teas/dist/index.min.mjs'
  import sum from './sum.mjs'

  test('one number', () => equal(sum(1), 1))
  test('two numbers', () => equal(sum(1, 2), 3))
</script>

Installation

You can install the test harness, typically with a chosen reporter like the colourful console or tap, and optionally with the command-line runner, using your favourite Node.js package manager:

npm i -D tehanu tehanu-repo-coco tehanu-teru
yarn add -D tehanu tehanu-repo-coco tehanu-teru
pnpm i -D tehanu tehanu-repo-coco tehanu-teru

Packages

  • tehanu - a framework for creation and execution of test suites.
  • teas - a set of assertion methods compatible with the built-in assert module usable in both Node.js and the browser.
  • tenbo - an experimental test runner for tests written with tehanu in the web browser.
  • teru - an optional test runner for tests written with tehanu.
  • coco - a colourful console reporter.
  • tape - a reporter compatible with the TAP format specification.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code using npm test.

License

Copyright (c) 2021-2024 Ferdinand Prantl

Licensed under the MIT license.