vendredi 27 novembre 2015

Using chaijs to test for correctness of datatypes of function arguments

I am using assert-type module to test for correctness of datatypes of function arguments.

Sample code of what I did;

var cs = require("coffee-script/register");//this line needed to require("assert-type"). Some bug.
var ty = require("assert-type"); //http://ift.tt/1HlV5C9
var T = ty.Assert;

function test_func(file_name, start_time, end_time) {
    T(ty.str, ty.obj.not.null, ty.obj.not.null)(file_name, start_time, end_time);
    //action code
}

What is the corresponding code if I were to use chaijs module? http://chaijs.com/

I went through the documentation but failed to find the corresponding code. Should I stick to using assert-type module?

Aucun commentaire:

Enregistrer un commentaire