-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
55 lines (45 loc) · 1.27 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var tape = require('tape');
var isNode = require("is-node");
var refine = require("./lib/refine");
var command = require('./lib/command');
var isProvaFrame = !isNode && document;
var nodeRequire = require;
var view, tests;
empty.skip = empty;
empty.only = empty;
if (command.launch === true) {
nodeRequire('./lib/cli').launch();
module.exports = empty;
return;
}
if (command.examples) {
nodeRequire('./lib/cli').examples();
module.exports = empty;
return;
}
if (command.browser) {
nodeRequire('./lib/cli').launch();
nodeRequire('./lib/browser')([require.main.filename], command);
} else if ((isNode || isProvaFrame) && !command.tap) {
view = isNode ? nodeRequire('./lib/node-reporter') : require('./lib/browser-reporter');
tape.createStream({ objectMode: true }).pipe(refine()).pipe(view());
}
if (isNode) {
tests = require('./lib/tests');
}
module.exports = prova;
module.exports.skip = skip;
module.exports.only = only;
function prova (title, fn) {
if (command.browser) return;
if (command.grep && title.indexOf(command.grep) == -1) return skip(title, fn);
if (isNode) tests.add(title);
return tape(title, fn);
}
function skip (title, fn) {
return tape.skip(title, fn);
}
function only (title, fn) {
return tape.only(title, fn);
}
function empty () {}