0.6.1 • Published 3 years ago

tapzero v0.6.1

Weekly downloads
13
License
-
Repository
github
Last release
3 years ago

tapzero

Zero dependency test framework

Source code

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

Migrating from tape

const test = require('tape')
// Tapzero exports an object with a test function property.
const test = require('tapzero').test
tape('my test', (t) => {
  t.equal(2, 2, 'ok')
  t.end()
})
// Auto ending behavior on function completion
tapzero('my test', (t) => {
  t.equal(2, 2, 'ok')
  // t.end() does not exist.
})
// 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)
  })
})
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)
})

Motivation

Small library, 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 library, small install size.

tapzerobaretestzoraptatape
pkg sizetapzerobaretestzoraptatape
Min.js sizetapzerobaretestzoraptatape
dep counttapzerobaretestzoraptatape
MochaAvaJesttap
pkg sizemochaavajesttap
Min.js sizemochaavajesttap
dep countmochaavajesttap

Docs

const test = require('tapzero').test

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

Harness docs

const testHarness = require('tapzero/harness')

See HARNESS.md

0.6.1

3 years ago

0.6.0

3 years ago

0.4.5

3 years ago

0.5.0

3 years ago

0.4.4

3 years ago

0.3.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago