mocha 7.0.0-esm1 → 7.0.0
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 +0 -21
- package/lib/cli/config.js +1 -2
- package/lib/cli/options.js +1 -1
- package/lib/cli/run-helpers.js +3 -11
- package/lib/cli/run.js +2 -8
- package/lib/mocha.js +6 -85
- package/lib/mocharc.json +1 -1
- package/lib/utils.js +0 -43
- package/mocha.js +9 -131
- package/package.json +2 -4
- package/lib/esm-utils.js +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
# 7.0.0-esm1 / 2020-01-12
|
|
2
|
-
|
|
3
|
-
**This is an experimental release** based on v7.0.0: `npm i mocha@7.0.0-esm1`
|
|
4
|
-
|
|
5
|
-
## :tada: Enhancements
|
|
6
|
-
|
|
7
|
-
[#4038](https://github.com/mochajs/mocha/issues/4038): Add Node.js native ESM support ([**@giltayar**](https://github.com/giltayar))
|
|
8
|
-
|
|
9
|
-
Enables Mocha to load ECMAScript Modules test files, also valid for `--file` option.
|
|
10
|
-
|
|
11
|
-
Limitations:
|
|
12
|
-
|
|
13
|
-
- Node.js only v12.11.0 and above
|
|
14
|
-
- Node.js below v13.2.0, you must set `--experimental-modules` option
|
|
15
|
-
- ESM not (yet) supported for:
|
|
16
|
-
- `--watch` mode
|
|
17
|
-
- `--require` option
|
|
18
|
-
- `--reporter` custom reporters
|
|
19
|
-
- `--ui` custom interfaces
|
|
20
|
-
- `mocharc` configuration file
|
|
21
|
-
|
|
22
1
|
# 7.0.0 / 2020-01-05
|
|
23
2
|
|
|
24
3
|
## :boom: Breaking Changes
|
package/lib/cli/config.js
CHANGED
|
@@ -21,7 +21,6 @@ const findUp = require('find-up');
|
|
|
21
21
|
* @private
|
|
22
22
|
*/
|
|
23
23
|
exports.CONFIG_FILES = [
|
|
24
|
-
'.mocharc.cjs',
|
|
25
24
|
'.mocharc.js',
|
|
26
25
|
'.mocharc.yaml',
|
|
27
26
|
'.mocharc.yml',
|
|
@@ -76,7 +75,7 @@ exports.loadConfig = filepath => {
|
|
|
76
75
|
try {
|
|
77
76
|
if (ext === '.yml' || ext === '.yaml') {
|
|
78
77
|
config = parsers.yaml(filepath);
|
|
79
|
-
} else if (ext === '.js'
|
|
78
|
+
} else if (ext === '.js') {
|
|
80
79
|
config = parsers.js(filepath);
|
|
81
80
|
} else {
|
|
82
81
|
config = parsers.json(filepath);
|
package/lib/cli/options.js
CHANGED
|
@@ -265,7 +265,7 @@ module.exports.loadPkgRc = loadPkgRc;
|
|
|
265
265
|
* Priority list:
|
|
266
266
|
*
|
|
267
267
|
* 1. Command-line args
|
|
268
|
-
* 2. RC file (`.mocharc.
|
|
268
|
+
* 2. RC file (`.mocharc.js`, `.mocharc.ya?ml`, `mocharc.json`)
|
|
269
269
|
* 3. `mocha` prop of `package.json`
|
|
270
270
|
* 4. `mocha.opts`
|
|
271
271
|
* 5. default configuration (`lib/mocharc.json`)
|
package/lib/cli/run-helpers.js
CHANGED
|
@@ -98,21 +98,14 @@ exports.handleRequires = (requires = []) => {
|
|
|
98
98
|
* @param {boolean} [opts.exit] - Whether or not to force-exit after tests are complete
|
|
99
99
|
* @param {Object} fileCollectParams - Parameters that control test
|
|
100
100
|
* file collection. See `lib/cli/collect-files.js`.
|
|
101
|
-
* @returns {
|
|
101
|
+
* @returns {Runner}
|
|
102
102
|
* @private
|
|
103
103
|
*/
|
|
104
104
|
exports.singleRun = (mocha, {exit}, fileCollectParams) => {
|
|
105
105
|
const files = collectFiles(fileCollectParams);
|
|
106
106
|
debug('running tests with files', files);
|
|
107
107
|
mocha.files = files;
|
|
108
|
-
|
|
109
|
-
return mocha.runAsync().then(exitCode => {
|
|
110
|
-
if (exit) {
|
|
111
|
-
exitMocha(exitCode);
|
|
112
|
-
} else {
|
|
113
|
-
exitMochaLater(exitCode);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
108
|
+
return mocha.run(exit ? exitMocha : exitMochaLater);
|
|
116
109
|
};
|
|
117
110
|
|
|
118
111
|
/**
|
|
@@ -120,7 +113,6 @@ exports.singleRun = (mocha, {exit}, fileCollectParams) => {
|
|
|
120
113
|
* @param {Mocha} mocha - Mocha instance
|
|
121
114
|
* @param {Object} opts - Command line options
|
|
122
115
|
* @private
|
|
123
|
-
* @returns {Promise}
|
|
124
116
|
*/
|
|
125
117
|
exports.runMocha = (mocha, options) => {
|
|
126
118
|
const {
|
|
@@ -148,7 +140,7 @@ exports.runMocha = (mocha, options) => {
|
|
|
148
140
|
if (watch) {
|
|
149
141
|
watchRun(mocha, {watchFiles, watchIgnore}, fileCollectParams);
|
|
150
142
|
} else {
|
|
151
|
-
|
|
143
|
+
exports.singleRun(mocha, {exit}, fileCollectParams);
|
|
152
144
|
}
|
|
153
145
|
};
|
|
154
146
|
|
package/lib/cli/run.js
CHANGED
|
@@ -299,14 +299,8 @@ exports.builder = yargs =>
|
|
|
299
299
|
.number(types.number)
|
|
300
300
|
.alias(aliases);
|
|
301
301
|
|
|
302
|
-
exports.handler =
|
|
302
|
+
exports.handler = argv => {
|
|
303
303
|
debug('post-yargs config', argv);
|
|
304
304
|
const mocha = new Mocha(argv);
|
|
305
|
-
|
|
306
|
-
try {
|
|
307
|
-
await runMocha(mocha, argv);
|
|
308
|
-
} catch (err) {
|
|
309
|
-
console.error(err.stack || `Error: ${err.message || err}`);
|
|
310
|
-
process.exit(1);
|
|
311
|
-
}
|
|
305
|
+
runMocha(mocha, argv);
|
|
312
306
|
};
|
package/lib/mocha.js
CHANGED
|
@@ -14,7 +14,6 @@ var utils = require('./utils');
|
|
|
14
14
|
var mocharc = require('./mocharc.json');
|
|
15
15
|
var errors = require('./errors');
|
|
16
16
|
var Suite = require('./suite');
|
|
17
|
-
var esmUtils = utils.supportsEsModules() ? require('./esm-utils') : undefined;
|
|
18
17
|
var createStatsCollector = require('./stats-collector');
|
|
19
18
|
var createInvalidReporterError = errors.createInvalidReporterError;
|
|
20
19
|
var createInvalidInterfaceError = errors.createInvalidInterfaceError;
|
|
@@ -288,18 +287,16 @@ Mocha.prototype.ui = function(ui) {
|
|
|
288
287
|
};
|
|
289
288
|
|
|
290
289
|
/**
|
|
291
|
-
* Loads `files` prior to execution.
|
|
290
|
+
* Loads `files` prior to execution.
|
|
292
291
|
*
|
|
293
292
|
* @description
|
|
294
293
|
* The implementation relies on Node's `require` to execute
|
|
295
294
|
* the test interface functions and will be subject to its cache.
|
|
296
|
-
* Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync.
|
|
297
295
|
*
|
|
298
296
|
* @private
|
|
299
297
|
* @see {@link Mocha#addFile}
|
|
300
298
|
* @see {@link Mocha#run}
|
|
301
299
|
* @see {@link Mocha#unloadFiles}
|
|
302
|
-
* @see {@link Mocha#loadFilesAsync}
|
|
303
300
|
* @param {Function} [fn] - Callback invoked upon completion.
|
|
304
301
|
*/
|
|
305
302
|
Mocha.prototype.loadFiles = function(fn) {
|
|
@@ -314,43 +311,6 @@ Mocha.prototype.loadFiles = function(fn) {
|
|
|
314
311
|
fn && fn();
|
|
315
312
|
};
|
|
316
313
|
|
|
317
|
-
/**
|
|
318
|
-
* Loads `files` prior to execution. Supports Node ES Modules.
|
|
319
|
-
*
|
|
320
|
-
* @description
|
|
321
|
-
* The implementation relies on Node's `require` and `import` to execute
|
|
322
|
-
* the test interface functions and will be subject to its cache.
|
|
323
|
-
* Supports both CJS and ESM modules.
|
|
324
|
-
*
|
|
325
|
-
* @private
|
|
326
|
-
* @see {@link Mocha#addFile}
|
|
327
|
-
* @see {@link Mocha#run}
|
|
328
|
-
* @see {@link Mocha#unloadFiles}
|
|
329
|
-
*
|
|
330
|
-
* @returns {Promise}
|
|
331
|
-
*/
|
|
332
|
-
Mocha.prototype.loadFilesAsync = function() {
|
|
333
|
-
var self = this;
|
|
334
|
-
var suite = this.suite;
|
|
335
|
-
|
|
336
|
-
if (!esmUtils) {
|
|
337
|
-
return new Promise(function(resolve) {
|
|
338
|
-
self.loadFiles(resolve);
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return esmUtils.loadFilesAsync(
|
|
343
|
-
this.files,
|
|
344
|
-
function(file) {
|
|
345
|
-
suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
|
|
346
|
-
},
|
|
347
|
-
function(file, resultModule) {
|
|
348
|
-
suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self);
|
|
349
|
-
suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
};
|
|
353
|
-
|
|
354
314
|
/**
|
|
355
315
|
* Removes a previously loaded file from Node's `require` cache.
|
|
356
316
|
*
|
|
@@ -875,11 +835,7 @@ Object.defineProperty(Mocha.prototype, 'version', {
|
|
|
875
835
|
* already in the `require` cache), make sure to clear them from
|
|
876
836
|
* the cache first!
|
|
877
837
|
*
|
|
878
|
-
* This method supports only CommonJS test files, and not ES modules ones.
|
|
879
|
-
* To use ES module (and CommonJS) test files, call Mocha#runAsync instead.
|
|
880
|
-
*
|
|
881
838
|
* @public
|
|
882
|
-
* @see {@link Mocha#runAsync}
|
|
883
839
|
* @see {@link Mocha#unloadFiles}
|
|
884
840
|
* @see {@link Runner#run}
|
|
885
841
|
* @param {DoneCB} [fn] - Callback invoked when test execution completed.
|
|
@@ -889,17 +845,12 @@ Mocha.prototype.run = function(fn) {
|
|
|
889
845
|
if (this.files.length) {
|
|
890
846
|
this.loadFiles();
|
|
891
847
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
Mocha.prototype._startRunning = function(fn) {
|
|
896
|
-
var self = this;
|
|
897
|
-
var suite = self.suite;
|
|
898
|
-
var options = self.options;
|
|
899
|
-
options.files = self.files;
|
|
848
|
+
var suite = this.suite;
|
|
849
|
+
var options = this.options;
|
|
850
|
+
options.files = this.files;
|
|
900
851
|
var runner = new exports.Runner(suite, options.delay);
|
|
901
852
|
createStatsCollector(runner);
|
|
902
|
-
var reporter = new
|
|
853
|
+
var reporter = new this._reporter(runner, options);
|
|
903
854
|
runner.checkLeaks = options.checkLeaks === true;
|
|
904
855
|
runner.fullStackTrace = options.fullTrace;
|
|
905
856
|
runner.asyncOnly = options.asyncOnly;
|
|
@@ -913,7 +864,7 @@ Mocha.prototype._startRunning = function(fn) {
|
|
|
913
864
|
runner.globals(options.global);
|
|
914
865
|
}
|
|
915
866
|
if (options.growl) {
|
|
916
|
-
|
|
867
|
+
this._growl(runner);
|
|
917
868
|
}
|
|
918
869
|
if (options.color !== undefined) {
|
|
919
870
|
exports.reporters.Base.useColors = options.color;
|
|
@@ -932,33 +883,3 @@ Mocha.prototype._startRunning = function(fn) {
|
|
|
932
883
|
|
|
933
884
|
return runner.run(done);
|
|
934
885
|
};
|
|
935
|
-
|
|
936
|
-
/**
|
|
937
|
-
* Runs root suite and invokes `fn()` when complete. Supports ES Modules.
|
|
938
|
-
*
|
|
939
|
-
* @description
|
|
940
|
-
* To run tests multiple times (or to run tests in files that are
|
|
941
|
-
* already in the `require` cache), make sure to clear them from
|
|
942
|
-
* the cache first!
|
|
943
|
-
*
|
|
944
|
-
* This method supports both ES Modules and CommonJS test files.
|
|
945
|
-
*
|
|
946
|
-
* @public
|
|
947
|
-
* @see {@link Mocha#unloadFiles}
|
|
948
|
-
* @see {@link Runner#run}
|
|
949
|
-
* @return {Promise<Runner>} runner instance
|
|
950
|
-
*/
|
|
951
|
-
Mocha.prototype.runAsync = function() {
|
|
952
|
-
var loadResult = this.files.length
|
|
953
|
-
? this.loadFilesAsync()
|
|
954
|
-
: Promise.resolve();
|
|
955
|
-
|
|
956
|
-
var self = this;
|
|
957
|
-
return loadResult.then(function() {
|
|
958
|
-
return new Promise(function(resolve) {
|
|
959
|
-
self._startRunning(function(result) {
|
|
960
|
-
resolve(result);
|
|
961
|
-
});
|
|
962
|
-
});
|
|
963
|
-
});
|
|
964
|
-
};
|
package/lib/mocharc.json
CHANGED
package/lib/utils.js
CHANGED
|
@@ -831,46 +831,3 @@ exports.defineConstants = function(obj) {
|
|
|
831
831
|
}
|
|
832
832
|
return Object.freeze(exports.createMap(obj));
|
|
833
833
|
};
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* Whether current version of Node support ES modules
|
|
837
|
-
*
|
|
838
|
-
* @description
|
|
839
|
-
* Versions prior to 10 did not support ES Modules, and version 10 has an old incompatibile version of ESM.
|
|
840
|
-
* This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs,
|
|
841
|
-
* which is version 12 and older
|
|
842
|
-
*
|
|
843
|
-
* @param {Boolean} unflagged whether the support is unflagged (`true`) or only using the `--experimental-modules` flag (`false`)
|
|
844
|
-
* @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatbile with Mocha
|
|
845
|
-
*/
|
|
846
|
-
exports.supportsEsModules = function(unflagged) {
|
|
847
|
-
if (typeof document !== 'undefined') {
|
|
848
|
-
return false;
|
|
849
|
-
}
|
|
850
|
-
if (
|
|
851
|
-
typeof process !== 'object' ||
|
|
852
|
-
!process.versions ||
|
|
853
|
-
!process.versions.node
|
|
854
|
-
) {
|
|
855
|
-
return false;
|
|
856
|
-
}
|
|
857
|
-
var versionFields = process.versions.node.split('.');
|
|
858
|
-
var major = +versionFields[0];
|
|
859
|
-
var minor = +versionFields[1];
|
|
860
|
-
|
|
861
|
-
if (major >= 13) {
|
|
862
|
-
if (unflagged) {
|
|
863
|
-
return minor >= 2;
|
|
864
|
-
}
|
|
865
|
-
return true;
|
|
866
|
-
}
|
|
867
|
-
if (unflagged) {
|
|
868
|
-
return false;
|
|
869
|
-
}
|
|
870
|
-
if (major < 12) {
|
|
871
|
-
return false;
|
|
872
|
-
}
|
|
873
|
-
// major === 12
|
|
874
|
-
|
|
875
|
-
return minor >= 11;
|
|
876
|
-
};
|
package/mocha.js
CHANGED
|
@@ -1408,7 +1408,6 @@ var utils = require('./utils');
|
|
|
1408
1408
|
var mocharc = require('./mocharc.json');
|
|
1409
1409
|
var errors = require('./errors');
|
|
1410
1410
|
var Suite = require('./suite');
|
|
1411
|
-
var esmUtils = utils.supportsEsModules() ? require('./esm-utils') : undefined;
|
|
1412
1411
|
var createStatsCollector = require('./stats-collector');
|
|
1413
1412
|
var createInvalidReporterError = errors.createInvalidReporterError;
|
|
1414
1413
|
var createInvalidInterfaceError = errors.createInvalidInterfaceError;
|
|
@@ -1682,18 +1681,16 @@ Mocha.prototype.ui = function(ui) {
|
|
|
1682
1681
|
};
|
|
1683
1682
|
|
|
1684
1683
|
/**
|
|
1685
|
-
* Loads `files` prior to execution.
|
|
1684
|
+
* Loads `files` prior to execution.
|
|
1686
1685
|
*
|
|
1687
1686
|
* @description
|
|
1688
1687
|
* The implementation relies on Node's `require` to execute
|
|
1689
1688
|
* the test interface functions and will be subject to its cache.
|
|
1690
|
-
* Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync.
|
|
1691
1689
|
*
|
|
1692
1690
|
* @private
|
|
1693
1691
|
* @see {@link Mocha#addFile}
|
|
1694
1692
|
* @see {@link Mocha#run}
|
|
1695
1693
|
* @see {@link Mocha#unloadFiles}
|
|
1696
|
-
* @see {@link Mocha#loadFilesAsync}
|
|
1697
1694
|
* @param {Function} [fn] - Callback invoked upon completion.
|
|
1698
1695
|
*/
|
|
1699
1696
|
Mocha.prototype.loadFiles = function(fn) {
|
|
@@ -1708,43 +1705,6 @@ Mocha.prototype.loadFiles = function(fn) {
|
|
|
1708
1705
|
fn && fn();
|
|
1709
1706
|
};
|
|
1710
1707
|
|
|
1711
|
-
/**
|
|
1712
|
-
* Loads `files` prior to execution. Supports Node ES Modules.
|
|
1713
|
-
*
|
|
1714
|
-
* @description
|
|
1715
|
-
* The implementation relies on Node's `require` and `import` to execute
|
|
1716
|
-
* the test interface functions and will be subject to its cache.
|
|
1717
|
-
* Supports both CJS and ESM modules.
|
|
1718
|
-
*
|
|
1719
|
-
* @private
|
|
1720
|
-
* @see {@link Mocha#addFile}
|
|
1721
|
-
* @see {@link Mocha#run}
|
|
1722
|
-
* @see {@link Mocha#unloadFiles}
|
|
1723
|
-
*
|
|
1724
|
-
* @returns {Promise}
|
|
1725
|
-
*/
|
|
1726
|
-
Mocha.prototype.loadFilesAsync = function() {
|
|
1727
|
-
var self = this;
|
|
1728
|
-
var suite = this.suite;
|
|
1729
|
-
|
|
1730
|
-
if (!esmUtils) {
|
|
1731
|
-
return new Promise(function(resolve) {
|
|
1732
|
-
self.loadFiles(resolve);
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
return esmUtils.loadFilesAsync(
|
|
1737
|
-
this.files,
|
|
1738
|
-
function(file) {
|
|
1739
|
-
suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
|
|
1740
|
-
},
|
|
1741
|
-
function(file, resultModule) {
|
|
1742
|
-
suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self);
|
|
1743
|
-
suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
|
|
1744
|
-
}
|
|
1745
|
-
);
|
|
1746
|
-
};
|
|
1747
|
-
|
|
1748
1708
|
/**
|
|
1749
1709
|
* Removes a previously loaded file from Node's `require` cache.
|
|
1750
1710
|
*
|
|
@@ -2269,11 +2229,7 @@ Object.defineProperty(Mocha.prototype, 'version', {
|
|
|
2269
2229
|
* already in the `require` cache), make sure to clear them from
|
|
2270
2230
|
* the cache first!
|
|
2271
2231
|
*
|
|
2272
|
-
* This method supports only CommonJS test files, and not ES modules ones.
|
|
2273
|
-
* To use ES module (and CommonJS) test files, call Mocha#runAsync instead.
|
|
2274
|
-
*
|
|
2275
2232
|
* @public
|
|
2276
|
-
* @see {@link Mocha#runAsync}
|
|
2277
2233
|
* @see {@link Mocha#unloadFiles}
|
|
2278
2234
|
* @see {@link Runner#run}
|
|
2279
2235
|
* @param {DoneCB} [fn] - Callback invoked when test execution completed.
|
|
@@ -2283,17 +2239,12 @@ Mocha.prototype.run = function(fn) {
|
|
|
2283
2239
|
if (this.files.length) {
|
|
2284
2240
|
this.loadFiles();
|
|
2285
2241
|
}
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
Mocha.prototype._startRunning = function(fn) {
|
|
2290
|
-
var self = this;
|
|
2291
|
-
var suite = self.suite;
|
|
2292
|
-
var options = self.options;
|
|
2293
|
-
options.files = self.files;
|
|
2242
|
+
var suite = this.suite;
|
|
2243
|
+
var options = this.options;
|
|
2244
|
+
options.files = this.files;
|
|
2294
2245
|
var runner = new exports.Runner(suite, options.delay);
|
|
2295
2246
|
createStatsCollector(runner);
|
|
2296
|
-
var reporter = new
|
|
2247
|
+
var reporter = new this._reporter(runner, options);
|
|
2297
2248
|
runner.checkLeaks = options.checkLeaks === true;
|
|
2298
2249
|
runner.fullStackTrace = options.fullTrace;
|
|
2299
2250
|
runner.asyncOnly = options.asyncOnly;
|
|
@@ -2307,7 +2258,7 @@ Mocha.prototype._startRunning = function(fn) {
|
|
|
2307
2258
|
runner.globals(options.global);
|
|
2308
2259
|
}
|
|
2309
2260
|
if (options.growl) {
|
|
2310
|
-
|
|
2261
|
+
this._growl(runner);
|
|
2311
2262
|
}
|
|
2312
2263
|
if (options.color !== undefined) {
|
|
2313
2264
|
exports.reporters.Base.useColors = options.color;
|
|
@@ -2327,41 +2278,11 @@ Mocha.prototype._startRunning = function(fn) {
|
|
|
2327
2278
|
return runner.run(done);
|
|
2328
2279
|
};
|
|
2329
2280
|
|
|
2330
|
-
/**
|
|
2331
|
-
* Runs root suite and invokes `fn()` when complete. Supports ES Modules.
|
|
2332
|
-
*
|
|
2333
|
-
* @description
|
|
2334
|
-
* To run tests multiple times (or to run tests in files that are
|
|
2335
|
-
* already in the `require` cache), make sure to clear them from
|
|
2336
|
-
* the cache first!
|
|
2337
|
-
*
|
|
2338
|
-
* This method supports both ES Modules and CommonJS test files.
|
|
2339
|
-
*
|
|
2340
|
-
* @public
|
|
2341
|
-
* @see {@link Mocha#unloadFiles}
|
|
2342
|
-
* @see {@link Runner#run}
|
|
2343
|
-
* @return {Promise<Runner>} runner instance
|
|
2344
|
-
*/
|
|
2345
|
-
Mocha.prototype.runAsync = function() {
|
|
2346
|
-
var loadResult = this.files.length
|
|
2347
|
-
? this.loadFilesAsync()
|
|
2348
|
-
: Promise.resolve();
|
|
2349
|
-
|
|
2350
|
-
var self = this;
|
|
2351
|
-
return loadResult.then(function() {
|
|
2352
|
-
return new Promise(function(resolve) {
|
|
2353
|
-
self._startRunning(function(result) {
|
|
2354
|
-
resolve(result);
|
|
2355
|
-
});
|
|
2356
|
-
});
|
|
2357
|
-
});
|
|
2358
|
-
};
|
|
2359
|
-
|
|
2360
2281
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
2361
|
-
},{"../package.json":90,"./context":5,"./errors":6,"./
|
|
2282
|
+
},{"../package.json":90,"./context":5,"./errors":6,"./growl":2,"./hook":7,"./interfaces":11,"./mocharc.json":15,"./reporters":21,"./runnable":33,"./runner":34,"./stats-collector":35,"./suite":36,"./test":37,"./utils":38,"_process":69,"escape-string-regexp":49,"path":42}],15:[function(require,module,exports){
|
|
2362
2283
|
module.exports={
|
|
2363
2284
|
"diff": true,
|
|
2364
|
-
"extension": ["js"
|
|
2285
|
+
"extension": ["js"],
|
|
2365
2286
|
"opts": "./test/mocha.opts",
|
|
2366
2287
|
"package": "./package.json",
|
|
2367
2288
|
"reporter": "spec",
|
|
@@ -8288,49 +8209,6 @@ exports.defineConstants = function(obj) {
|
|
|
8288
8209
|
return Object.freeze(exports.createMap(obj));
|
|
8289
8210
|
};
|
|
8290
8211
|
|
|
8291
|
-
/**
|
|
8292
|
-
* Whether current version of Node support ES modules
|
|
8293
|
-
*
|
|
8294
|
-
* @description
|
|
8295
|
-
* Versions prior to 10 did not support ES Modules, and version 10 has an old incompatibile version of ESM.
|
|
8296
|
-
* This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs,
|
|
8297
|
-
* which is version 12 and older
|
|
8298
|
-
*
|
|
8299
|
-
* @param {Boolean} unflagged whether the support is unflagged (`true`) or only using the `--experimental-modules` flag (`false`)
|
|
8300
|
-
* @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatbile with Mocha
|
|
8301
|
-
*/
|
|
8302
|
-
exports.supportsEsModules = function(unflagged) {
|
|
8303
|
-
if (typeof document !== 'undefined') {
|
|
8304
|
-
return false;
|
|
8305
|
-
}
|
|
8306
|
-
if (
|
|
8307
|
-
typeof process !== 'object' ||
|
|
8308
|
-
!process.versions ||
|
|
8309
|
-
!process.versions.node
|
|
8310
|
-
) {
|
|
8311
|
-
return false;
|
|
8312
|
-
}
|
|
8313
|
-
var versionFields = process.versions.node.split('.');
|
|
8314
|
-
var major = +versionFields[0];
|
|
8315
|
-
var minor = +versionFields[1];
|
|
8316
|
-
|
|
8317
|
-
if (major >= 13) {
|
|
8318
|
-
if (unflagged) {
|
|
8319
|
-
return minor >= 2;
|
|
8320
|
-
}
|
|
8321
|
-
return true;
|
|
8322
|
-
}
|
|
8323
|
-
if (unflagged) {
|
|
8324
|
-
return false;
|
|
8325
|
-
}
|
|
8326
|
-
if (major < 12) {
|
|
8327
|
-
return false;
|
|
8328
|
-
}
|
|
8329
|
-
// major === 12
|
|
8330
|
-
|
|
8331
|
-
return minor >= 11;
|
|
8332
|
-
};
|
|
8333
|
-
|
|
8334
8212
|
}).call(this,require('_process'),require("buffer").Buffer)
|
|
8335
8213
|
},{"./errors":6,"_process":69,"buffer":43,"fs":42,"glob":42,"he":54,"object.assign":65,"path":42,"util":89}],39:[function(require,module,exports){
|
|
8336
8214
|
'use strict'
|
|
@@ -18212,7 +18090,7 @@ function hasOwnProperty(obj, prop) {
|
|
|
18212
18090
|
},{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
|
|
18213
18091
|
module.exports={
|
|
18214
18092
|
"name": "mocha",
|
|
18215
|
-
"version": "7.0.0
|
|
18093
|
+
"version": "7.0.0",
|
|
18216
18094
|
"homepage": "https://mochajs.org/",
|
|
18217
18095
|
"notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
|
|
18218
18096
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "simple, flexible, fun test framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mocha",
|
|
@@ -179,7 +179,6 @@
|
|
|
179
179
|
"Gavin Mogan <GavinM@airg.com>",
|
|
180
180
|
"gaye <gaye@mozilla.com>",
|
|
181
181
|
"gigadude <gigadude@users.noreply.github.com>",
|
|
182
|
-
"Gil Tayar <gil@tayar.org>",
|
|
183
182
|
"Giovanni Bassi <giggio@giggio.net>",
|
|
184
183
|
"gizemkeser <44727928+gizemkeser@users.noreply.github.com>",
|
|
185
184
|
"Glen Huang <curvedmark@gmail.com>",
|
|
@@ -547,7 +546,7 @@
|
|
|
547
546
|
"growl": "1.10.5",
|
|
548
547
|
"he": "1.2.0",
|
|
549
548
|
"js-yaml": "3.13.1",
|
|
550
|
-
"log-symbols": "
|
|
549
|
+
"log-symbols": "2.2.0",
|
|
551
550
|
"minimatch": "3.0.4",
|
|
552
551
|
"mkdirp": "0.5.1",
|
|
553
552
|
"ms": "2.1.1",
|
|
@@ -568,7 +567,6 @@
|
|
|
568
567
|
"acorn": "^7.0.0",
|
|
569
568
|
"assetgraph-builder": "^6.10.1",
|
|
570
569
|
"autoprefixer": "^9.6.0",
|
|
571
|
-
"babel-eslint": "^10.0.3",
|
|
572
570
|
"browserify": "^16.2.3",
|
|
573
571
|
"browserify-package-json": "^1.0.1",
|
|
574
572
|
"chai": "^4.2.0",
|
package/lib/esm-utils.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// This file is allowed to use async/await because it is not exposed to browsers (see the `eslintrc`),
|
|
2
|
-
// and Node supports async/await in all its non-dead version.
|
|
3
|
-
|
|
4
|
-
const url = require('url');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
exports.requireOrImport = async file => {
|
|
8
|
-
file = path.resolve(file);
|
|
9
|
-
|
|
10
|
-
if (path.extname(file) === '.mjs') {
|
|
11
|
-
return import(url.pathToFileURL(file));
|
|
12
|
-
}
|
|
13
|
-
// This way of figuring out whether a test file is CJS or ESM is currently the only known
|
|
14
|
-
// way of figuring out whether a file is CJS or ESM.
|
|
15
|
-
// If Node.js or the community establish a better procedure for that, we can fix this code.
|
|
16
|
-
// Another option here would be to always use `import()`, as this also supports CJS, but I would be
|
|
17
|
-
// wary of using it for _all_ existing test files, till ESM is fully stable.
|
|
18
|
-
try {
|
|
19
|
-
return require(file);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
if (err.code === 'ERR_REQUIRE_ESM') {
|
|
22
|
-
return import(url.pathToFileURL(file));
|
|
23
|
-
} else {
|
|
24
|
-
throw err;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.loadFilesAsync = async (files, preLoadFunc, postLoadFunc) => {
|
|
30
|
-
for (const file of files) {
|
|
31
|
-
preLoadFunc(file);
|
|
32
|
-
const result = await exports.requireOrImport(file);
|
|
33
|
-
postLoadFunc(file, result);
|
|
34
|
-
}
|
|
35
|
-
};
|