New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sutest

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sutest

Simple unit test framework for not node based javascript modules.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

SimpleUnitTest

Simple unit test framework for not node based javascript modules.

Usage

Install the package with npm:

npm install -g sutest

Write your test script file:

module.exports = function (unitTest) {

	unitTest.AddTest ('AdditionTest', function (test) {
		test.Assert (2 + 3 == 5);
	});
	
};

Run the test from command line:

sutest mytestfile.js

Create suites

You can create test suites, and add tests to suites:

module.exports = function (unitTest) {

	var opTestSuite = unitTest.AddTestSuite ('OperationsTest');
	
	opTestSuite.AddTest ('AdditionTest', function (test) {
		test.Assert (2 + 3 == 5);
	});
	
	opTestSuite.AddTest ('SubtractionTest', function (test) {
		test.Assert (2 - 3 == -1);
	});
	
};

Include modules

You can add not node based modules, and use them in your tests.

For example, create a module with this content:

function Addition (a, b)
{
	return a + b;
}

function Subtraction (a, b)
{
	return a - b;
}

Now you can add this module to your test:

module.exports = function (unitTest) {

	unitTest.AddSourceFile ('./operationsmodule.js');
	
	var opTestSuiteLib = unitTest.AddTestSuite ('OperationsTestFromLib');
	
	opTestSuiteLib.AddTest ('AdditionTest', function (test) {
		test.Assert (Addition (2, 3) == 5);
	});
	
	opTestSuiteLib.AddTest ('SubtractionTest', function (test) {
		test.Assert (Subtraction (2, 3) == -1);
	});
	
};

Create multiple test files

You can create multiple test files, and call them from a main test file:

module.exports = function (unitTest)
{

	unitTest.AddTestFile ('./additiontest.js');
	unitTest.AddTestFile ('./subtractiontest.js');

};

Usage as library

Install the package locally:

npm install sutest

Create your standalone test file:

var path = require ('path');
var dirName = path.dirname (require.main.filename);

var sutest = require ('sutest');
var unitTest = new sutest.UnitTest (dirName, process.argv);

var opTestSuite = unitTest.AddTestSuite ('OperationsTest');
opTestSuite.AddTest ('AdditionTest', function (test) {
	test.Assert (2 + 3 == 5);
});

opTestSuite.AddTest ('SubtractionTest', function (test) {
	test.Assert (2 - 3 == -1);
});

unitTest.Run ();

Run the test from command line:

node mytestfile.js

Keywords

FAQs

Package last updated on 11 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc