tst
v7.3.0
Published
Tests without efforts
Downloads
1,145
Readme
tst
Test without efforts.
- tape API
- no tooling, vanilla ESM
- async functions support
- inspectable errors
- correct stacktrace with sourcemaps
- good l&f in browser/node
- supports assert, chai etc.
- tiny bundle, 0dep
usage
import test, { ok, is, not, throws } from 'tst.js'
test('pass', () => {
ok(true);
ok(true, 'this time with an optional message');
ok('not true, but truthy enough');
is(1 + 1, 2);
is(Math.max(1, 2, 3), 3);
is({}, {})
throws(() => {
throw new Error('oh no!');
}, /oh no!/);
})
test('fail', () => {
is(42, '42');
is({}, {x:1});
})
Creates output in console:
api
test.skip
− bypass test, mutes outputtest.only
− run only the indicated test, can be multipletest.todo
− bypass test, indicate WIP signtest.demo
− demo run, skips failed assertions.
assert
ok(a, msg?)
− generic truthfulness assertis(a, b, msg?)
− assert withObject.is
for primitives anddeepEqual
for objectsnot(a, b, msg?)
- assert with!Object.is
for primitives and!deepEqual
for objectsany(a, [a, b, c], msg?)
− assert with optional resultsalmost(a, b, eps, msg?)
− assert approximate value/arraysame(listA, listB, msg?)
− assert same members of a list/set/map/objectthrows(fn, msg?)
− fn must throwpass(msg)
,fail(msf)
− pass or fail the whole test.
why?
Testing should not involve maintaining test runner. It should be simple as tap/tape, working in browser/node, ESM, with nice l&f, done in a straightforward way. I wasn't able to find such test runner that so I had to create one.