Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tehanu-teru

prantlf81MIT1.0.1

Runs test suites written with tehanu in multiple source files.

testing, unit-testing, test-runner

readme

Test Runner

NPM version

Runs test suites written with tehanu in multiple source files.

Synopsis

Test runner

sum1.test.js:

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

test('one number', () => equal(sum(1), 1))

sum2.test.js:

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

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

Running teru *.test.js or teru sum1.test.js sum2.test.js allows executing some or all test suites.

Installation

You can install the test runner using your favourite Node.js package manager:

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

Usage

Run tests written with Tehanu:

teru [option ...] [pattern ...]

If you use an NPM module with a conflicting binary, you can use aliases tehanu or teru-cjs instead of teru to execute the tests. If your tests are in the ESM format, use only teru-esm to run them.

Options

-r|--reporter <name>       choose a reporter (coco, tape or custom)
-R|--require <module>      preload a Node.js module to the process
-b|--[no-]bail             abort after the first failure occurs
-p|--[no-]parallel         execute test suites concurrently
-s|--[no-]parallel-suites  execute tests in a suite concurrently
-V|--version               print version number
-h|--help                  print usage instructions

If no pattern is provided, ./**/*.js will be used by default. If no reporter is provided, just errors will be printed on the console.

Examples

teru -b
teru -r tape test/*.js

Alternative

The alternative to the teru test runner is creating a test suite index and executing it by node tests:

tests.js:

require('./sum1.test')
require('./sum2.test')

changelog

Changes

teru 1.0.1

  • Insert shebang to the bin script for compatibility with Bun.

tenbo 0.2.1

  • Insert shebang to the bin script for compatibility with Bun.

coco 1.0.1

  • Make the green tick thicker.

tenbo 0.2.0

  • Allow specifying multiple HTML pages on the command line.
  • Recognise -D as --no-disconnect on the command line.
  • Avoid favicon requests from the test pages.
  • Enable browser cache for 5 seconds.

tenbo 0.1.0

  • Add parameter -t|--timeout=ms to fail the tests if a log or a network request does not occur in time.
  • Set process.exitCode = 1 is a test failed.

tape 1.0.1

  • Fix formatting of error message, location and call stack

tehanu 1.0.1

  • Cut relative path from file URL too, not only from absolute path
  • Cut the JavaScript file extension from the suite name based on file path

tehanu 1.0.0, teru 1.0.0, teas 1.0.0, tape 1.0.0, coco 1.0.0, tenbo: 0.0.1

  • Support ESM projects in Node.js and in the browser.
  • Export get and set methods to read and write configuration parameters, which are usually passed by the tehanu object from pacjkage.json or window (in the browser), but it may be useful to access them from test scripts too.
  • Add an ESM runner in Node.js - teru-esm.
  • Add another alias for CJS/UMD runner in Node.js - teru-cjs.
  • Add an experimental runner in browser - tenbo.
  • Complete the assertions in teas to match Node.js 18.
  • Replace esbuild with swc and use it only for minification. Bundle with rollup. (esbuild doesn't support UMD and I don't have time to maintain @prantlf/esbuild any more. rollup produces the most readable output, which is useful, if source maps fail.)

NOTE: The ESM support needs Node.js 14.13 or newer.

tehanu 0.2.2

  • Fix occasional re-initialising the tests. At least it did not lead to re-running the tests.

teru 0.2.2

  • Move tehanu to peer dependencies of teru.

tehanu 0.2.1

  • Stop using fs sync methods to read from package.json.

tehanu 0.2.0, teru 0.2.1

  • Export schedule to allow executing the test suites manually and compatibly with teru.
  • Export factory together with schedule to allow importing both of them as named exports.

teru 0.2.0

  • Add alias tehanu to the script teru to solve conflicts in some projects.

tehanu 0.0.4, teru 0.1.2

  • Cut the relative path from the test suite name if __filename is specified.
  • Upgrade NPM dependencies.

teru 0.1.1

  • Fix version dependencies.

teru 0.1.0

  • Add an option to preload Node.js modules.

tehanu 0.0.3

  • Fix typescript type for the test callback.

0.0.2

  • Fix running in the browser.
  • Fix the list of distributed files in tehanu and tehanu-repo-tape.
  • Add minified ESM build output.
  • Improve the package ionformation and the documentation.

0.0.1

Initial release.