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

Package detail

@bicycle-codes/tapzero

bicycle-codes1k0.10.10TypeScript support: included

Smallest test library

readme

tapzero

tests module dependencies type-coverage semantic versioning license

Zero dependency test framework

A fork of raynos/tapzero

Source code

The implementation is <250 loc, (<500 with comments) ( https://github.com/bicycle-codes/tapzero/blob/fork/index.js ) and very readable.

install

npm i -D @bicycle-codes/tapzero

Migrating from tape

import tape from 'tape'
// Tapzero exports an object with a test function property.
import { test } from '@bicycle-codes/tapzero'
tape('my test', (t) => {
  t.equal(2, 2, 'ok')
  t.end()
})

// Auto ending behavior on function completion
test('my test', (t) => {
  t.equal(2, 2, 'ok')
  // t.end() does not exist.
})

End automatically

Return a promise. The test will end when the promise resolves.

// tapzero "auto" ends async tests when the async function completes
tapzero('my cb test', async (t) => {
  await new Promise((resolve) => {
    t.equal(2, 2, 'ok')
    setTimeout(() => {
      // instead of calling t.end(), resolve a promise
      resolve()
    }, 10)
  })
})

Plan the number of assertions

tapzero('planning example', t => {
  // this test will fail if we execute more or fewer
  //   than planned assertions
  t.plan(2)
  t.ok('hello')
  t.equal(2, 2, 'two is two')
})

API

No aliases, smaller API surface area

import { test } from '@bicycle-codes/tapzero'

test('example test name', async t => {
  // ...
})
tape('my test', (t) => {
  t.equals(2, 2)
  t.is(2, 2)
  t.isEqual(2, 2)
})

tapzero('my test', (t) => {
  // tapzero does not implement any aliases, very small surface area.
  t.equal(2, 2)
  t.equal(2, 2)
  t.equal(2, 2)
})

test(name, [fn])

Run a single named test case. The fn will be called with the t test object.

Tests run one at a time and complete when the fn completes. The fn can be async.

test.only(name, fn)

Like test(name, fn) 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.

test.skip(name, [fn])

Creates a test case that will be skipped

t.deepEqual (actual, expected, msg)

Check that two objects have equal shapes.

t.notDeepEqual (actual, expected, msg)

Passes if the two given objects are not equal.

t.equal (actual, expected, msg)

Check that two given values are equal.

t.notEqual (actual, expected, msg)

Pass if the two values are not equal.

t.fail (msg)

Explicitly fail.

t.ok (value, msg)

Check that value is truthy.

t.throws (fn, expected, message)

Check that fn does throw an error.

Motivation

Small library, zero dependencies

Zero dependencies

$ package-size ./build/src/index.js zora baretest,assert qunit tape jasmine mocha

  package                      size       minified   gzipped
  ./build/src/index.js         8.97 KB    3.92 KB    1.53 KB
  zora@3.1.8                   32.44 KB   11.65 KB   4.08 KB
  baretest@1.0.0,assert@2.0.0  51.61 KB   16.48 KB   5.82 KB
  qunit@2.9.3                  195.83 KB  62.04 KB   20.38 KB
  tape@4.13.0                  304.71 KB  101.46 KB  28.8 KB
  jasmine@3.5.0                413.61 KB  145.2 KB   41.07 KB
  mocha@7.0.1                  811.55 KB  273.07 KB  91.61 KB

Small install size

| | @bicycle-codes/tapzero | baretest | zora | pta | tape | |--------|:---------:|:----------:|:------:|:-----:|:------:| |pkg size| tapzero | baretest | zora | pta | tape | |dep count| @bicycle-codes/tapzero | baretest | zora | pta | tape |

| | Mocha | Ava | Jest | tap | |:------:|:-------:|:-----:|:------:|:-----:| |pkg size| mocha | ava | jest | tap | |Min.js size| mocha | ava | jest | tap | |dep count| mocha | ava | jest | tap |

develop

Run the tests

npm test

Check type coverage

npm run coverage

visual type report

This will use the tool typescript-coverage-report, and open an HTML page in your default browser.

npm run report

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Generated by auto-changelog.

v0.10.10

v0.10.9 - 2025-01-01

Commits

v0.10.8 - 2025-01-01

Commits

v0.10.7 - 2025-01-01

Commits

v0.10.6 - 2024-12-31

Merged

  • Configure Mend Bolt for GitHub #1

Commits

v0.10.5 - 2024-10-10

v0.10.4 - 2024-10-10

Commits

v0.10.3 - 2024-06-25

Commits

v0.10.2 - 2024-06-25

Commits

v0.10.1 - 2024-06-25

Commits

v0.10.0 - 2024-06-14

Commits

v0.9.3 - 2024-05-07

Commits

v0.9.2 - 2024-03-02

Commits

v0.9.1 - 2024-03-02

Commits

v0.9.0 - 2024-03-02

Commits

  • Breaking change: BREAKING CHANGE: rm harness 87cb325

v0.8.12 - 2024-03-02

v0.8.11 - 2024-03-02

Commits

v0.8.10 - 2024-02-29

Commits

  • bundle the code during build 1d5b58b

v0.8.9 - 2024-02-28

Commits

v0.8.7 - 2024-02-27

Commits

v0.8.6 - 2024-02-27

Commits

  • rm lint script b/c it's failing f664e10

v0.8.5 - 2024-02-26

Commits

v0.8.4 - 2023-11-09

Commits

v0.8.3 - 2023-11-07

Commits

v0.8.2 - 2023-11-07

Commits

v0.8.1 - 2023-11-07

Merged

Commits

v0.8.0 - 2023-09-29

Commits

  • Merge pull request #20 from socketsupply/bret/readme b06b0cb
  • Update package name in readme ed0f3b9
  • Merge pull request #19 from nichoth/plan-test 2e5b3d9

v0.7.1 - 2023-05-15

Commits

  • fix: display undefined in error reports 113c0b9
  • update package.json b5e2fc2

v0.7.0 - 2022-12-23

Merged

  • add onFinish #11

Commits

v0.6.1 - 2021-11-01

Merged

  • Add strict mode. #5

Commits

v0.6.0 - 2021-10-15

Merged

  • Make exception handling opt out #4

Commits

  • harness: Simplify implentation by removing callbacks 9d853be
  • update tests 29854aa
  • index: Make exception rethrow possible to opt out a15bf02

v0.5.0 - 2021-09-29

Commits

v0.4.5 - 2021-09-29

Commits

v0.4.4 - 2021-09-29

Commits

v0.4.3 - 2021-09-28

Commits

v0.4.2 - 2021-09-28

Commits

  • whitelist file for npm publish 3000c28

v0.4.1 - 2021-09-28

Commits

v0.4.0 - 2021-09-28

Commits

  • add tape harness inline into package 310bc8f

v0.3.0 - 2021-09-28

Commits

v0.2.2 - 2021-01-28

Commits

  • Do not rely on __filename 2b2e647

v0.2.1 - 2021-01-28

Commits

v0.2.0 - 2021-01-28

v0.1.4 - 2021-01-28

Merged

  • Fix typo #2

Commits

v0.1.3 - 2020-02-23

Commits

v0.1.2 - 2020-02-23

Commits

v0.1.1 - 2020-02-23

Commits