Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dy/tst
Tests without efforts
https://github.com/dy/tst
mocha tap test
Last synced: 18 days ago
JSON representation
Tests without efforts
- Host: GitHub
- URL: https://github.com/dy/tst
- Owner: dy
- License: other
- Created: 2016-01-05T19:48:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T21:08:53.000Z (3 months ago)
- Last Synced: 2024-10-20T12:44:44.859Z (25 days ago)
- Topics: mocha, tap, test
- Language: JavaScript
- Homepage:
- Size: 290 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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](https://www.npmjs.com/package/assert), [chai](https://www.npmjs.com/package/chai) etc.
* tiny bundle, 0dep## usage
```js
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](./preview.png)
## 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](https://ghub.io/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
* [uvu](https://github.com/lukeed/uvu)
* [tape-modern](https://ghub.io/tape-modern)
* [@goto-bus-stop/tape-modern](https://github.com/goto-bus-stop/tape-modern#readme)
* [brittle](https://github.com/davidmarkclements/brittle)