tst
Test without efforts.
- no tooling, vanilla ESM
- works both node/browser
- async functions support
- inspectable errors
- stacktrace with sourcemaps
- clean l&f in browser/node
- supports assert, chai etc.
- minimal, 0dep
- tape API
usage
import test, { ok, is, not, throws } from 'tst.js'
test('tst demo test', () => {
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!/);
})
api
test.only− run only selected test(s)test.mute− run test(s), mute assertionstest.skip− bypass test(s)test.todo− bypass test(s), mark as WIPtest.demo− demo run, skip failed assertions.
assert
ok(a, msg?)− generic truthfulness assertis(a, b, msg?)− assert withObject.isfor primitives anddeepEqualfor objectsnot(a, b, msg?)- assert with!Object.isfor primitives and!deepEqualfor objectsany(a, [a, b, c], msg?)− assert with optional resultssame(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.