@logicos/tinytest

0.4.1 • Public • Published

@logicos/tinytest

Minimal testing framework

npm i -D @logicos/tinytest

or

yarn add -D @logicos/tinytest

Purpose

To test conditions, functions, and data structures in a simple and lightweight manner.

This package exposes testing tools for quick logic expectations to the more formal runSpec which allows for testing of sync and async functions simply.

@NOTE: truthy not required, just used as an example :)

How to use { test }

const { test } = require('@logicos/tinytest');
test(something(), somethingElse());

// --> Test has passed!
// or
// --> Test has failed!
test(something(), somethingElse(), 'Something check');

// --> Something check has passed!
// or
// --> Something check has failed!

How to use { runSpec }

const { runSpec } = require('@logicos/tinytest');

runSpec({
  name: 'Example of a pass',
  test: truthy.validate('foo', 'isFoo'),
  expect: true,
});
Example of a pass ✅
runSpec({
  name: 'Example of a fail',
  test: truthy.validate('foo', 'isBar'),
  expect: true,
});
Example of a fail ❌

RunSpec also works with Async

runSpec({
  name: 'Function that returns "foo" after some time',
  test: truthy.validate(eventuallyFoo(), 'isFoo'),
  expect: true,
});
Function that returns "foo" after some time

How to use { btest }

btest only returns a boolean result of your test, no special messages.

btest(truthy.validate(2, 'isEven'), true);
btest(truthy.validate(2, 'isOdd'), true);
btest(truthy.validate(2, 'isOdd'), false);
true
false
true

Readme

Keywords

none

Package Sidebar

Install

npm i @logicos/tinytest

Weekly Downloads

9

Version

0.4.1

License

0BSD

Unpacked Size

3.28 kB

Total Files

5

Last publish

Collaborators

  • dwayneford