mocha 9.1.2
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 +1015 -0
- package/LICENSE +22 -0
- package/README.md +70 -0
- package/assets/growl/error.png +0 -0
- package/assets/growl/ok.png +0 -0
- package/bin/_mocha +10 -0
- package/bin/mocha +142 -0
- package/browser-entry.js +216 -0
- package/index.js +3 -0
- package/lib/browser/growl.js +169 -0
- package/lib/browser/highlight-tags.js +39 -0
- package/lib/browser/parse-query.js +24 -0
- package/lib/browser/progress.js +123 -0
- package/lib/browser/template.html +20 -0
- package/lib/cli/cli.js +89 -0
- package/lib/cli/collect-files.js +92 -0
- package/lib/cli/commands.js +13 -0
- package/lib/cli/config.js +105 -0
- package/lib/cli/index.js +3 -0
- package/lib/cli/init.js +36 -0
- package/lib/cli/lookup-files.js +145 -0
- package/lib/cli/node-flags.js +85 -0
- package/lib/cli/one-and-dones.js +69 -0
- package/lib/cli/options.js +261 -0
- package/lib/cli/run-helpers.js +243 -0
- package/lib/cli/run-option-metadata.js +117 -0
- package/lib/cli/run.js +379 -0
- package/lib/cli/watch-run.js +380 -0
- package/lib/context.js +86 -0
- package/lib/errors.js +563 -0
- package/lib/hook.js +89 -0
- package/lib/interfaces/bdd.js +111 -0
- package/lib/interfaces/common.js +193 -0
- package/lib/interfaces/exports.js +60 -0
- package/lib/interfaces/index.js +6 -0
- package/lib/interfaces/qunit.js +98 -0
- package/lib/interfaces/tdd.js +106 -0
- package/lib/mocha.js +1374 -0
- package/lib/mocharc.json +10 -0
- package/lib/nodejs/buffered-worker-pool.js +172 -0
- package/lib/nodejs/esm-utils.js +109 -0
- package/lib/nodejs/file-unloader.js +15 -0
- package/lib/nodejs/growl.js +137 -0
- package/lib/nodejs/parallel-buffered-runner.js +433 -0
- package/lib/nodejs/reporters/parallel-buffered.js +165 -0
- package/lib/nodejs/serializer.js +412 -0
- package/lib/nodejs/worker.js +151 -0
- package/lib/pending.js +16 -0
- package/lib/plugin-loader.js +286 -0
- package/lib/reporters/base.js +537 -0
- package/lib/reporters/doc.js +95 -0
- package/lib/reporters/dot.js +81 -0
- package/lib/reporters/html.js +390 -0
- package/lib/reporters/index.js +19 -0
- package/lib/reporters/json-stream.js +92 -0
- package/lib/reporters/json.js +162 -0
- package/lib/reporters/landing.js +116 -0
- package/lib/reporters/list.js +78 -0
- package/lib/reporters/markdown.js +112 -0
- package/lib/reporters/min.js +52 -0
- package/lib/reporters/nyan.js +276 -0
- package/lib/reporters/progress.js +104 -0
- package/lib/reporters/spec.js +99 -0
- package/lib/reporters/tap.js +293 -0
- package/lib/reporters/xunit.js +217 -0
- package/lib/runnable.js +476 -0
- package/lib/runner.js +1269 -0
- package/lib/stats-collector.js +83 -0
- package/lib/suite.js +695 -0
- package/lib/test.js +113 -0
- package/lib/utils.js +641 -0
- package/mocha-es2018.js +19816 -0
- package/mocha.css +325 -0
- package/mocha.js +30844 -0
- package/mocha.js.map +1 -0
- package/package.json +200 -0
package/lib/test.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var Runnable = require('./runnable');
|
|
3
|
+
var utils = require('./utils');
|
|
4
|
+
var errors = require('./errors');
|
|
5
|
+
var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
|
|
6
|
+
var isString = utils.isString;
|
|
7
|
+
|
|
8
|
+
const {MOCHA_ID_PROP_NAME} = utils.constants;
|
|
9
|
+
|
|
10
|
+
module.exports = Test;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Initialize a new `Test` with the given `title` and callback `fn`.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @class
|
|
17
|
+
* @extends Runnable
|
|
18
|
+
* @param {String} title - Test title (required)
|
|
19
|
+
* @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
|
|
20
|
+
*/
|
|
21
|
+
function Test(title, fn) {
|
|
22
|
+
if (!isString(title)) {
|
|
23
|
+
throw createInvalidArgumentTypeError(
|
|
24
|
+
'Test argument "title" should be a string. Received type "' +
|
|
25
|
+
typeof title +
|
|
26
|
+
'"',
|
|
27
|
+
'title',
|
|
28
|
+
'string'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
this.type = 'test';
|
|
32
|
+
Runnable.call(this, title, fn);
|
|
33
|
+
this.reset();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Inherit from `Runnable.prototype`.
|
|
38
|
+
*/
|
|
39
|
+
utils.inherits(Test, Runnable);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resets the state initially or for a next run.
|
|
43
|
+
*/
|
|
44
|
+
Test.prototype.reset = function() {
|
|
45
|
+
Runnable.prototype.reset.call(this);
|
|
46
|
+
this.pending = !this.fn;
|
|
47
|
+
delete this.state;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Set or get retried test
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
Test.prototype.retriedTest = function(n) {
|
|
56
|
+
if (!arguments.length) {
|
|
57
|
+
return this._retriedTest;
|
|
58
|
+
}
|
|
59
|
+
this._retriedTest = n;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Add test to the list of tests marked `only`.
|
|
64
|
+
*
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
Test.prototype.markOnly = function() {
|
|
68
|
+
this.parent.appendOnlyTest(this);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Test.prototype.clone = function() {
|
|
72
|
+
var test = new Test(this.title, this.fn);
|
|
73
|
+
test.timeout(this.timeout());
|
|
74
|
+
test.slow(this.slow());
|
|
75
|
+
test.retries(this.retries());
|
|
76
|
+
test.currentRetry(this.currentRetry());
|
|
77
|
+
test.retriedTest(this.retriedTest() || this);
|
|
78
|
+
test.globals(this.globals());
|
|
79
|
+
test.parent = this.parent;
|
|
80
|
+
test.file = this.file;
|
|
81
|
+
test.ctx = this.ctx;
|
|
82
|
+
return test;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns an minimal object suitable for transmission over IPC.
|
|
87
|
+
* Functions are represented by keys beginning with `$$`.
|
|
88
|
+
* @private
|
|
89
|
+
* @returns {Object}
|
|
90
|
+
*/
|
|
91
|
+
Test.prototype.serialize = function serialize() {
|
|
92
|
+
return {
|
|
93
|
+
$$currentRetry: this._currentRetry,
|
|
94
|
+
$$fullTitle: this.fullTitle(),
|
|
95
|
+
$$isPending: Boolean(this.pending),
|
|
96
|
+
$$retriedTest: this._retriedTest || null,
|
|
97
|
+
$$slow: this._slow,
|
|
98
|
+
$$titlePath: this.titlePath(),
|
|
99
|
+
body: this.body,
|
|
100
|
+
duration: this.duration,
|
|
101
|
+
err: this.err,
|
|
102
|
+
parent: {
|
|
103
|
+
$$fullTitle: this.parent.fullTitle(),
|
|
104
|
+
[MOCHA_ID_PROP_NAME]: this.parent.id
|
|
105
|
+
},
|
|
106
|
+
speed: this.speed,
|
|
107
|
+
state: this.state,
|
|
108
|
+
title: this.title,
|
|
109
|
+
type: this.type,
|
|
110
|
+
file: this.file,
|
|
111
|
+
[MOCHA_ID_PROP_NAME]: this.id
|
|
112
|
+
};
|
|
113
|
+
};
|