README
tst
Test without efforts.
Gems
- no tooling, vanilla ESM
- works with any assert, chai etc.
- async functions support
- inspectable errors
- correct stacktrace with sourcemaps
- nice look & feel in browser/node
- tiny bundle, 0dep
Usage
import test, {ok,is,not,throws} from 'tst.js'
test('these tests will all 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('these tests will not pass', () => {
is(42, '42');
is({}, {x:1});
})
test.skip('this test will not run', () => {
})
test.browser('browser-only test', () => {
})
Creates output in console:

test types
test.skip− bypass test, mutes outputtest.only− run only the indicated test, can be multipletest.todo− bypass test, indicate WIP signtest.node− run test in node/deno only env.test.browser− run test in browser only test.
assertions
ok(a, msg?)− generic truthfulness assertis(a, b, msg?)− assert withequalfor primitives anddeepEqualfor objectsnot(a, b, msg?)- assert withequalfor primitives anddeepEqualfor 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.
Neighbors
🕉️