jcoglan / jstest

The cross-platform JavaScript test framework
38 stars 3 forks source link

suggesting beforeOnce and afterOnce hooks. #5

Closed eurekaa closed 10 years ago

eurekaa commented 10 years ago

Hi, great job at first!

i have the need to create a testing environment (making directories etc...) before the test runs, and to destroy it when the test ends.

The problem is that 'setup' and 'teardown' hooks fires for every inlined test, so my environment will be continuosly created and destroyed.

Thanks a lot!

jcoglan commented 10 years ago

before(function() {}) is actually short-hand for before('each', function() {}). If you use before('all', function() {}), then that hook will run just once, before all the tests in the enclosed suite are run. Likewise, after('all', function() {}) runs once after all the tests in the describe() block have run.

eurekaa commented 10 years ago

Perfect, thanks! I did'nt saw it in the documentation, maybe it should be useful to add cause i think many people need it. I see also that setup and teardown are aliases of before and after, maybe it can be useful if they behave like `before|after ('all', function(){}); Is it possible? Thanks! Stefano