Skip to content

bdsomer/testlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Easy, lightweight testing

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors