7.3.0 • Published 11 months ago

tst v7.3.0

Weekly downloads
22
License
MIT
Repository
github
Last release
11 months ago

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:

preview

api

  • test.skip − bypass test, mutes output
  • test.only − run only the indicated test, can be multiple
  • test.todo − bypass test, indicate WIP sign
  • test.demo − demo run, skips failed assertions.

assert

  • ok(a, msg?) − generic truthfulness assert
  • is(a, b, msg?) − assert with Object.is for primitives and deepEqual for objects
  • not(a, b, msg?) - assert with !Object.is for primitives and !deepEqual for objects
  • any(a, [a, b, c], msg?) − assert with optional results
  • almost(a, b, eps, msg?) − assert approximate value/array
  • same(listA, listB, msg?) − assert same members of a list/set/map/object
  • throws(fn, msg?) − fn must throw
  • pass(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.

similar

7.3.0

11 months ago

7.2.0

1 year ago

7.1.1

3 years ago

7.1.0

3 years ago

7.0.0

4 years ago

6.1.1

5 years ago

6.1.0

5 years ago

6.0.2

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

5.3.3

5 years ago

5.3.2

5 years ago

5.3.1

5 years ago

5.3.0

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.1.1

5 years ago

5.1.0

6 years ago

5.0.11

6 years ago

5.0.10

6 years ago

5.0.9

6 years ago

5.0.8

6 years ago

5.0.7

6 years ago

5.0.6

6 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.2.3

6 years ago

4.2.2

6 years ago

4.2.1

6 years ago

4.2.0

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.4.2

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.0

6 years ago

1.3.2

8 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.8

9 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.2

12 years ago

0.0.1

12 years ago