open-index/open-npm huggingface dataset:
npm package: @logicos/tinytest
Description: Minimal testing framework
Author: Brilliance Labs
Latest version: 0.4.1

# @logicos/tinytest

Minimal testing framework

```bash
npm i -D @logicos/tinytest
```

or

```bash
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 \}

```js
const { test } = require('@logicos/tinytest');
```

```js
test(something(), somethingElse());

// --> Test has passed!
// or
// --> Test has failed!
```

```js
test(something(), somethingElse(), 'Something check');

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

## How to use \{ runSpec \}

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

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

```bash
Example of a pass ✅
```

```js
runSpec({
  name: 'Example of a fail',
  test: truthy.validate('foo', 'isBar'),
  expect: true,
});
```

```bash
Example of a fail ❌
```

### RunSpec also works with Async

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

```bash
Function that returns "foo" after some time ✅
```

## How to use \{ btest \}

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

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

```bash
true
false
true
```