lundi 29 juin 2015

Is there a way to make a setUp and tearDown methods on tape?

I am using tape for testing in JavaScript, but in some cases I want to set some configuration variables that are available in all the tests within a file. Something like the setUp and tearDown methods available in PhpUnit. Those methods will be executed before and after every test in the file, respectively.

e.g:

test("setUp", function(t){
    var person = {name: 'Jose', programmer: true};
});

test("Name isn't undefined", function(){
    t.notEqual(person.name, undefined);
});

test("Is a programmer", function(t){
    t.ok(person.programmer);
});

test("tearDown", function(){
    //Do something else
});

Aucun commentaire:

Enregistrer un commentaire