Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

highkick

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highkick

Asynchronous, no-style, super simple testing tool.

  • 1.3.2
  • Source
  • npm
  • Socket score

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

Asynchronous, no-style, super simple testing tool for NodeJS.

Screenshot

Motivation

  • No sphagetti: The tests coded for HighKick seem very simple, apparent and familiar.
  • Continuations: HighKick provides an asynchronous API that uses the NodeJS' continuation passing style.
  • Nested Tests: Before I started coding HighKick, I had needed to test some JavaScript code that is generated by OneJS dynamically. Now, OneJS' main test module has some test functions that create temporary JS modules and execute HighKick to run some other test modules against dynamically generated NodeJS modules. Highkick simplifies this progress by letting us code nested tests...

Installation

$ git clone git@github.com:azer/highkick.git
$ cd highkick
$ npm install
$ make test

Introduction

Code your tests in a separated module, naming them starting with "test":


// tests.js

var assert = require('assert'); // highkick doesn't provide a new assertion library. NodeJS has a good one already.

exports.testFoo = function(callback){
  setTimeout(function(){
    try {
      do();
      something();
      and();
      callback();
    } catch (error)
      callback(error);
    }
  }, 1000);
}

exports.testBar = function(callback){
  callback();
}

You can optionally add an init function that will be called before each test.

An init function takes two arguments, first one is the options of the test, and second one is the callback that will fire the pending test.

Init functions may pass any number of parameters to the test functions. See the below example;


exports.init = function init(options, callback){
  callback(null, +(new Date), Math.random());
}

exports.testCorge = function(date, randomNumber, callback){
  callback();
}

You may be curious about the options variable passed to the init function (if you've defined one). You pass the options object to the highkick function itself, to run the tests.

In the below example, I create a new module and call HighKick, passing the tests module I've coded above.


// run.js

var highkick = require('highkick');

highkick({ 'module':require('./tests'), 'name':'main tests', 'silent':false }, function(error, result){
  if(error) throw error;
  
  console.log('Ran '+result.len+' tests with '+result.fail+' fail(s).');
});

Only required option field is module, see the Available Options section for details. feel free to skip name and ```silent`` fields if you dont need.

Let's call the module above;

$ node run.js

That's all. See test/ dir for a basic usage example.

Available Options

module Passes the module that contains the tests. Required. name A name that'll be seen as a prefix of the messages produced by the related tests. silent Keeps the tests silent. ordered Each test waits its previous sibling to produce a result by running its callback.

More Examples

I use HighKick in my OneJS project heavily. You may take a look at its tests;

https://github.com/azer/onejs/tree/master/test

Keywords

FAQs

Package last updated on 27 Nov 2011

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