2

Vows has an undocumented teardown feature, but I cannot see any way to setup stuff before each test (a.k.a. beforeEach).

One would think it would be possible to cheat and use the topic, but a topic is only run once (like teardown), whereas I would like this to be run before each test. Can this not be done in vows?

CletusW
  • 3,890
  • 1
  • 27
  • 42
Thomas Watson
  • 6,507
  • 5
  • 33
  • 43
  • 2
    I doubt it, have you considered using mocha instead? – Raynos Jan 04 '12 at 20:42
  • Yes I've been looking at Mocha as well, but the vows syntax just seems more clean without all the nested functions. To me it seems weird not having a beforeEach/setup feature. Even weirder that I cannot find anybody asking for it. Am I totally of base here? – Thomas Watson Jan 04 '12 at 21:33
  • Vows is an old library and it isnt actively being worked on, only maintained. You can use the exports interface of mocha if you want – Raynos Jan 04 '12 at 22:17
  • @Raynos Seriously? It seems pretty active when looking at the commits https://github.com/cloudhead/vows/commits/master - But if you are correct there should be some notice in the README file. I've just spend a lot of time testing out this module :( – Thomas Watson Jan 05 '12 at 09:20

1 Answers1

3

You can create a topic that does the setup, and the tests come after that. If you want it to run multiple times, create a function and have multiple topics that call that function.

It is a bit convoluted because it is not explicit, you should definitely consider mocha not only because it is actively maintained, but it makes tests easier to read than what you end up with when using vows.

staackuser2
  • 12,172
  • 4
  • 42
  • 40
  • Thanks for the tip. @Raynos also mentioned in his comment above that vows isn't an active project any more. What a shame :( I really liked the clean syntax. But you might be right... I should probably be moving to Mocha instead – Thomas Watson Jan 05 '12 at 09:23
  • Mocha runs test serially, which is a huge turn off (for some uses) – Bijou Trouvaille Jun 20 '12 at 02:24