azer / prova

Test runner based on Tape and Browserify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include setup/teardown via wrapping-tape or similar

knownasilya opened this issue · comments

https://www.npmjs.org/package/wrapping-tape

Looks like a nice way to add setup/teardown functionality to tape, would be nice to have this baked into prova.

sorry, prova wouldn't have this kind of extras since it follows the same simplicity goal with tape and we wanna keep it compatible.

I'd recommend to just use functions. e.g

test("foo", function () {
  setup()
  teardown()
})

function setup () {}
function teardown () {}

@azer so how would I have the teardown function run after the test finishes? Is there a way to hook into t.end or t.plan?

there are lots of ways, for example;

test("foo", finish(function (assert) {
  assert.plan(1)
  assert.equal(3.14, 3.14)
})

function finish (fn) {
  return function (assert) {
    fn()
    teardown()
    otherstuff()
  }
})

@azer ah, the obvious solution 👍

let me know your experience. it may be getting more complex once you need your teardown to be async, etc. we can keep using this issue as a place for improving the experience and sharing solutions, so I'm reopening...