mocha 5.0.3 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -9
- package/bin/_mocha +10 -1
- package/lib/context.js +4 -2
- package/lib/hook.js +11 -2
- package/lib/interfaces/common.js +2 -0
- package/lib/mocha.js +43 -2
- package/lib/ms.js +5 -1
- package/lib/reporters/base.js +11 -1
- package/lib/reporters/doc.js +7 -1
- package/lib/reporters/dot.js +7 -1
- package/lib/reporters/html.js +7 -1
- package/lib/reporters/json-stream.js +9 -2
- package/lib/reporters/json.js +36 -3
- package/lib/reporters/json.js.orig +128 -0
- package/lib/reporters/landing.js +7 -1
- package/lib/reporters/list.js +7 -1
- package/lib/reporters/markdown.js +7 -1
- package/lib/reporters/min.js +7 -1
- package/lib/reporters/nyan.js +7 -1
- package/lib/reporters/progress.js +7 -1
- package/lib/reporters/spec.js +7 -1
- package/lib/reporters/tap.js +7 -1
- package/lib/reporters/xunit.js +7 -1
- package/lib/runnable.js +31 -11
- package/lib/runner.js +19 -13
- package/lib/suite.js +38 -31
- package/lib/utils.js +53 -0
- package/mocha.js +438 -131
- package/package.json +433 -283
- package/CHANGELOG.md.orig +0 -1736
- package/README.md.orig +0 -132
- package/bin/.eslintrc.yml +0 -3
- package/lib/browser/.eslintrc.yml +0 -4
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* Module dependencies.
|
|
5
9
|
*/
|
|
@@ -8,8 +12,15 @@ var debug = require('debug')('mocha:watch');
|
|
|
8
12
|
var fs = require('fs');
|
|
9
13
|
var glob = require('glob');
|
|
10
14
|
var path = require('path');
|
|
15
|
+
var join = path.join;
|
|
11
16
|
var he = require('he');
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Ignored directories.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
var ignore = ['node_modules', '.git'];
|
|
23
|
+
|
|
13
24
|
exports.inherits = require('util').inherits;
|
|
14
25
|
|
|
15
26
|
/**
|
|
@@ -54,6 +65,46 @@ exports.watch = function (files, fn) {
|
|
|
54
65
|
});
|
|
55
66
|
};
|
|
56
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Ignored files.
|
|
70
|
+
*
|
|
71
|
+
* @api private
|
|
72
|
+
* @param {string} path
|
|
73
|
+
* @return {boolean}
|
|
74
|
+
*/
|
|
75
|
+
function ignored (path) {
|
|
76
|
+
return !~ignore.indexOf(path);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Lookup files in the given `dir`.
|
|
81
|
+
*
|
|
82
|
+
* @api private
|
|
83
|
+
* @param {string} dir
|
|
84
|
+
* @param {string[]} [ext=['.js']]
|
|
85
|
+
* @param {Array} [ret=[]]
|
|
86
|
+
* @return {Array}
|
|
87
|
+
*/
|
|
88
|
+
exports.files = function (dir, ext, ret) {
|
|
89
|
+
ret = ret || [];
|
|
90
|
+
ext = ext || ['js'];
|
|
91
|
+
|
|
92
|
+
var re = new RegExp('\\.(' + ext.join('|') + ')$');
|
|
93
|
+
|
|
94
|
+
fs.readdirSync(dir)
|
|
95
|
+
.filter(ignored)
|
|
96
|
+
.forEach(function (path) {
|
|
97
|
+
path = join(dir, path);
|
|
98
|
+
if (fs.lstatSync(path).isDirectory()) {
|
|
99
|
+
exports.files(path, ext, ret);
|
|
100
|
+
} else if (path.match(re)) {
|
|
101
|
+
ret.push(path);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return ret;
|
|
106
|
+
};
|
|
107
|
+
|
|
57
108
|
/**
|
|
58
109
|
* Compute a slug from the given `str`.
|
|
59
110
|
*
|
|
@@ -414,6 +465,8 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
414
465
|
/**
|
|
415
466
|
* Lookup file names at the given `path`.
|
|
416
467
|
*
|
|
468
|
+
* @memberof Mocha.utils
|
|
469
|
+
* @public
|
|
417
470
|
* @api public
|
|
418
471
|
* @param {string} filepath Base path to start searching from.
|
|
419
472
|
* @param {string[]} extensions File extensions to look for.
|