Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run cleanup with vows.js?

Tags:

node.js

bdd

vows

I'm using Vows.js to test some node.js which is creating records in a database. As a result of this it creates some test records in the database. I'd like to remove these records once the tests have run. Is there a way to run a cleanup function when a batch of tests is run in Vows?

like image 363
tooba Avatar asked Aug 15 '11 12:08

tooba


1 Answers

You can define the teardown function in your context that is executed once all the tests in your context are run.

vows.describe('Foo').addBatch({
    'A Context' : {
       topic : { foo: 'bar' },
       'it works' : function (topic) { assert.equal(topic.foo, "bar"); },
       teardown : function (topic) { topic.foo = "baz" }
    }
});

You can see this in Vows own tests.

like image 183
Rahman Kalfane Avatar answered Sep 28 '22 16:09

Rahman Kalfane