3.1.0 • Published 5 years ago

nefarious v3.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

nefarious

Quick and easy testing library

Intro

nefarious is an extremely simple testing library meant for inline use, no test-runner included.

Example (test file)

const test = require('nefarious');

const sleep = t => new Promise(resolve => setTimeout(resolve, t));

async function delayedIdentity(a, b) {
    await sleep(a);
    return b;
}

test('Basic test', async t => {
    t.is(await delayedIdentity(1000, 5), 5);
});

Running this file directly will run the tests and print a report.

Example (inline testing)

const test = require('nefarious');

function sum(arr) {
    return arr.reduce((s, c) => s + c, 0);
}

test.export('Sum of empty array is 0', t => {
    t.is(sum([]), 0);
});

test.export('Sum logic makes sense', t => {
    t.is(sum([1, 2, 3, 4]), 10);
});

module.exports = sum;

Simply running (or requiring) this file, won't run any tests. However, this:

const test = require('nefarious');
test.suite(__dirname, '../src/**/*.spec.js');

Will run the tests. Basically, use test.suite when you need to run multiple tests.

More features can be found in the examples directory.

3.1.0

5 years ago

3.0.0

5 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago

0.0.1

8 years ago