Promise-first testing with no surprises.
If your test runs synchronously, just write it:
const sticky = ;const test = ;;
If it's async, just return a promise:
const sticky = ;const test = ;;; // `resolve` never gets called so this test times out
→ Off to the races (1) → This test takes FOR EVVVVVVER (0) 1 tests failed :( × This test takes FOR EVVVVVVER Test rejected with TestTimeout (Test timed out) TestTimeout at CustomError.Error (native) at new CustomError (/home/phil/code/sticky/errors.js:15:27) at null._onTimeout (/home/phil/code/sticky/run-one.js:45:25) at Timer.listOnTimeout (timers.js:89:15) FAILED in 1.919s :(
sticky(options: object): func
test function that you can use to register tests to run.
options.timeout: number: How long to wait for an async test before failing it. Defaults to 100ms.
options.registerTimeout: number: How long to keep polling for new tests to be registered since the last test ran. You can call
test asynchronously with
sticky, no need to register them all in the first tick. However, if you need to start up a slow resource, you may need to increase this timeout. Defaults to 5ms.
test(plan: number, message: string, testFn: func)
sticky() (see above).
plan: The number of
asserts your tests will call.
msg: A description of this test
testFn: a callback to run your actual tests.
testFn is called with a single argument,
assert. If you return a promise,
sticky will wait for it to resolve or reject before moving on to the next test.
Provided as the only parameter to
testFn callbacks (see above).
A proxied version of nodejs's builtin
assert. The API is the same, except for
assert.fail, which only takes a single argument (the message to fail with).
Run sticky's own unit tests with