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

1

6

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
});
Shah answered 30/6, 2015 at 2:50 Comment(0)
J
6

A little too late for the reply but yes there is. By substack himself.

Basically you just write it simply as another test spec but with setup and teardown.

test('setup', function(t){
t.end();
});
test('teardown', function(t){
t.end();
});
Jerboa answered 9/8, 2015 at 1:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.