Files
panic-server/lib/framework/Test.js
Jesse Gibson 87332c088b Add UID to each test, save test name when available
Each test now has a unique ID to reference by. This will be useful for reporters and tracking of "done" events. Also, each test now saves the name it's been given.
2016-03-03 16:26:41 -07:00

35 lines
535 B
JavaScript

/*jslint node: true*/
'use strict';
var Context = require('./Context');
var bump = require('../../server/bump');
var stack = [];
function done() {
stack.pop();
var next = stack.slice(-1)[0];
if (next) {
bump(next, done);
}
}
function Test(name, cb, time) {
if (!(this instanceof Test)) {
return new Test(name, cb);
}
if (!cb) {
cb = name;
}
if (typeof name === 'string') {
this.description = name;
}
var ctx = new Context(this);
stack.push(ctx);
cb.call(ctx, ctx);
bump(ctx, done);
}
module.exports = Test;