testlite

2.0.2 • Public • Published

testlite

Easy, lightweight testing

testlite on NPM

Build Status testlite's Total Downloads on NPM testlite's Version on NPM bitHound Overall Score bitHound Code Dependencies Dev Dependencies Known Vulnerabilities testlite's License testlite's Stars on GitHub

Example Usage

// add.js
 
module.exports = (num1, num2) => {
    return num1 + num2
};
 
// tests/addTest.js
 
const assert = require('assert');
const add = require('../add.js');
module.exports = {
    'exports' : {
        'should add two numbers': () => {
            assert.strictEqual(add(1, 2), 3);
            assert.strictEqual(add(4, 5), 9);
        }, 'should return NaN if one of the arguments is NaN': () => {
            assert.strictEqual(add(NaN, 2), NaN);
            assert.strictEqual(add(parseInt('...'), 5), NaN);
            assert.strictEqual(add(NaN, NaN), NaN);
        }
    }
};
 
// tests/test.js
 
const tl = require('testlite');
tl('add.js', require('./addTest.js'));
tl.test();

Note that it is extremely important to call tl.test() or else nothing will happen.

API

  • require('testlite'): Function - the function to create a test.
    • testName: String - the high-level name of the test, ex. Array.
    • testTests: Object - the tests.
      • The key is the lower-level name of the test, ex. indexOf().
      • The value is an object.
        • The key is the name of the test, ex. should return -1 when element is not found
        • The value is a function that test this functionality.
          • returns
            • Nothing, if the test is synchronous.
            • If the test is asynchronous, a promise. A promise that resolves means success, a promise that rejects means failure.
  • require('testlite').test: Function - the function to be called to start testing.

Package Sidebar

Install

npm i testlite

Weekly Downloads

4

Version

2.0.2

License

MIT

Last publish

Collaborators

  • bdsomer