Created
May 13, 2014 21:20
-
-
Save hayes/f6b5ea55c506c9f8b62c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tape = require('tape') | |
module.exports = setup | |
function setup(up, down, run) { | |
return function add_test(name, fn) { | |
var test_state = {} | |
var test = tape(name, function(t) { | |
test_state = up ? up(test_state) : test_state | |
fn.call(this, t, context) | |
}) | |
}) | |
test.on('end', function() { | |
if(down) { | |
down(test_state) | |
} | |
}) | |
if(run) { | |
test.on('run', function() { | |
run(test_state) | |
}) | |
} | |
return test | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var setup = require('./setup') | |
var test = setup(up, down, run) | |
test('something', function(t, state) { | |
t.equal(state.setup, 'yup') | |
t.end() | |
}) | |
function up(state) { | |
//called right after test is added | |
state.up = 'yup' | |
return state | |
} | |
function run(state) { | |
//callled when test is about to start | |
} | |
function down(state) { | |
//callled after the test ends | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment