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.
This commit is contained in:
Jesse Gibson
2016-03-03 16:26:41 -07:00
parent 3e4946951a
commit 87332c088b
6 changed files with 51 additions and 9 deletions

View File

@@ -4,8 +4,16 @@
// deeply merge objects
var assign = require('object-assign-deep');
var defaults = require('./defaults');
var Gun = require('gun/gun');
/*
This is the test configuration constructor.
An instance is created each time a new
`test()` is declared, and is later configured
dynamically by "Context.js".
*/
function Response(obj) {
this.testID = Gun.text.random();
// provide defaults
assign(this, defaults);

View File

@@ -14,7 +14,6 @@ function done() {
}
function Test(name, cb, time) {
var ctx;
if (!(this instanceof Test)) {
return new Test(name, cb);
}
@@ -22,7 +21,11 @@ function Test(name, cb, time) {
cb = name;
}
ctx = new Context(this);
if (typeof name === 'string') {
this.description = name;
}
var ctx = new Context(this);
stack.push(ctx);
cb.call(ctx, ctx);
bump(ctx, done);