mocha
Advanced tools
Comparing version 8.0.1 to 8.1.0
@@ -12,2 +12,4 @@ 'use strict'; | ||
var parseQuery = require('./lib/browser/parse-query'); | ||
var highlightTags = require('./lib/browser/highlight-tags'); | ||
var Mocha = require('./lib/mocha'); | ||
@@ -81,2 +83,9 @@ | ||
process.listeners = function(e) { | ||
if (e === 'uncaughtException') { | ||
return uncaughtExceptionHandlers; | ||
} | ||
return []; | ||
}; | ||
// The BDD UI is registered by default, but no UI will be functional in the | ||
@@ -144,7 +153,15 @@ // browser without an explicit call to the overridden `mocha.ui` (see below). | ||
} | ||
for (var opt in opts) { | ||
if (Object.prototype.hasOwnProperty.call(opts, opt)) { | ||
this[opt](opts[opt]); | ||
} | ||
if (opts.delay === true) { | ||
this.delay(); | ||
} | ||
var self = this; | ||
Object.keys(opts) | ||
.filter(function(opt) { | ||
return opt !== 'delay'; | ||
}) | ||
.forEach(function(opt) { | ||
if (Object.prototype.hasOwnProperty.call(opts, opt)) { | ||
self[opt](opts[opt]); | ||
} | ||
}); | ||
return this; | ||
@@ -161,3 +178,3 @@ }; | ||
var query = Mocha.utils.parseQuery(global.location.search || ''); | ||
var query = parseQuery(global.location.search || ''); | ||
if (query.grep) { | ||
@@ -181,3 +198,3 @@ mocha.grep(query.grep); | ||
) { | ||
Mocha.utils.highlightTags('code'); | ||
highlightTags('code'); | ||
} | ||
@@ -201,4 +218,4 @@ if (fn) { | ||
global.Mocha = Mocha; | ||
global.mocha = mocha; | ||
mocha.Mocha = Mocha; | ||
mocha.mocha = mocha; | ||
@@ -208,2 +225,2 @@ // this allows test/acceptance/required-tokens.js to pass; thus, | ||
// browser context (assuming browserification). should fix #880 | ||
module.exports = global; | ||
module.exports = Object.assign(mocha, global); |
@@ -0,1 +1,40 @@ | ||
# 8.1.0 / 2020-07-30 | ||
In this release, Mocha now builds its browser bundle with Rollup and Babel, which will provide the project's codebase more flexibility and consistency. | ||
While we've been diligent about backwards compatibility, it's _possible_ consumers of the browser bundle will encounter differences (other than an increase in the bundle size). If you _do_ encounter an issue with the build, please [report it here](https://github.com/mochajs/mocha/issues/new?labels=unconfirmed-bug&template=bug_report.md&title=). | ||
This release **does not** drop support for IE11. | ||
Other community contributions came from [**@Devjeel**](https://github.com/Devjeel), [**@Harsha509**](https://github.com/Harsha509) and [**@sharath2106**](https://github.com/sharath2106). _Thank you_ to everyone who contributed to this release! | ||
> Do you read Korean? See [this guide to running parallel tests in Mocha](https://blog.outsider.ne.kr/1489), translated by our maintainer, [**@outsideris**](https://github.com/outsideris). | ||
## :tada: Enhancements | ||
- [#4287](https://github.com/mochajs/mocha/issues/4287): Use background colors with inline diffs for better visual distinction ([**@michael-brade**](https://github.com/michael-brade)) | ||
## :bug: Fixes | ||
- [#4328](https://github.com/mochajs/mocha/issues/4328): Fix "watch" mode when Mocha run in parallel ([**@boneskull**](https://github.com/boneskull)) | ||
- [#4382](https://github.com/mochajs/mocha/issues/4382): Fix root hook execution in "watch" mode ([**@indieisaconcept**](https://github.com/indieisaconcept)) | ||
- [#4383](https://github.com/mochajs/mocha/issues/4383): Consistent auto-generated hook titles ([**@cspotcode**](https://github.com/cspotcode)) | ||
- [#4359](https://github.com/mochajs/mocha/issues/4359): Better errors when running `mocha init` ([**@boneskull**](https://github.com/boneskull)) | ||
- [#4341](https://github.com/mochajs/mocha/issues/4341): Fix weirdness when using `delay` option in browser ([**@craigtaub**](https://github.com/craigtaub)) | ||
## :lock: Security Fixes | ||
- [#4378](https://github.com/mochajs/mocha/issues/4378), [#4333](https://github.com/mochajs/mocha/issues/4333): Update [javascript-serialize](https://npm.im/javascript-serialize) ([**@martinoppitz**](https://github.com/martinoppitz), [**@wnghdcjfe**](https://github.com/wnghdcjfe)) | ||
- [#4354](https://github.com/mochajs/mocha/issues/4354): Update [yargs-unparser](https://npm.im/yargs-unparser) ([**@martinoppitz**](https://github.com/martinoppitz)) | ||
## :book: Documentation & Website | ||
- [#4173](https://github.com/mochajs/mocha/issues/4173): Document how to use `--enable-source-maps` with Mocha ([**@bcoe**](https://github.com/bcoe)) | ||
- [#4343](https://github.com/mochajs/mocha/issues/4343): Clean up some API docs ([**@craigtaub**](https://github.com/craigtaub)) | ||
- [#4318](https://github.com/mochajs/mocha/issues/4318): Sponsor images are now self-hosted ([**@Munter**](https://github.com/Munter)) | ||
## :nut_and_bolt: Other | ||
- [#4293](https://github.com/mochajs/mocha/issues/4293): Use Rollup and Babel in build pipeline; add source map to published files ([**@Munter**](https://github.com/Munter)) | ||
# 8.0.1 / 2020-06-10 | ||
@@ -7,3 +46,3 @@ | ||
- [#4328]: Fix `--parallel` when combined with `--watch` ([**@boneskull**](https://github.com/boneskull)) | ||
- [#4328](https://github.com/mochajs/mocha/issues/4328): Fix `--parallel` when combined with `--watch` ([**@boneskull**](https://github.com/boneskull)) | ||
@@ -18,3 +57,3 @@ # 8.0.0 / 2020-06-10 | ||
- [#4164](https://github.com/mochajs/mocha/issues/4164): **Mocha v8.0.0 now requires Node.js v10.0.0 or newer.** Mocha no longer supports the Node.js v8.x line ("Carbon"), which entered End-of-Life at the end of 2019 ([**@UlisesGascon**](https://github.com/UlisesGascon)) | ||
- [#4164](https://github.com/mochajs/mocha/issues/4164): **Mocha v8.0.0 now requires Node.js v10.12.0 or newer.** Mocha no longer supports the Node.js v8.x line ("Carbon"), which entered End-of-Life at the end of 2019 ([**@UlisesGascon**](https://github.com/UlisesGascon)) | ||
@@ -40,2 +79,3 @@ - [#4175](https://github.com/mochajs/mocha/issues/4175): Having been deprecated with a warning since v7.0.0, **`mocha.opts` is no longer supported** ([**@juergba**](https://github.com/juergba)) | ||
- [#4178](https://github.com/mochajs/mocha/issues/4178): Remove previously soft-deprecated APIs ([**@wnghdcjfe**](https://github.com/wnghdcjfe)): | ||
- `Mocha.prototype.ignoreLeaks()` | ||
@@ -60,2 +100,6 @@ - `Mocha.prototype.useColors()` | ||
## :nut_and_bolt: Other | ||
- [#4200](https://github.com/mochajs/mocha/issues/4200): Drop mkdirp and replace it with fs.mkdirSync ([**@HyunSangHan**](https://github.com/HyunSangHan)) | ||
## :bug: Fixes | ||
@@ -62,0 +106,0 @@ |
'use strict'; | ||
/** | ||
@module browser/Progress | ||
*/ | ||
/** | ||
* Expose `Progress`. | ||
@@ -5,0 +9,0 @@ */ |
@@ -55,3 +55,3 @@ #!/usr/bin/env node | ||
console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`); | ||
yargs.exit(1); | ||
process.exitCode = 1; | ||
}) | ||
@@ -58,0 +58,0 @@ .help('help', 'Show usage information & exit') |
@@ -7,4 +7,4 @@ 'use strict'; | ||
const minimatch = require('minimatch'); | ||
const utils = require('../utils'); | ||
const {NO_FILES_MATCH_PATTERN} = require('../errors').constants; | ||
const lookupFiles = require('./lookup-files'); | ||
@@ -31,3 +31,3 @@ /** | ||
try { | ||
newFiles = utils.lookupFiles(arg, extension, recursive); | ||
newFiles = lookupFiles(arg, extension, recursive); | ||
} catch (err) { | ||
@@ -86,2 +86,3 @@ if (err.code === NO_FILES_MATCH_PATTERN) { | ||
* An object to configure how Mocha gathers test files | ||
* @private | ||
* @typedef {Object} FileCollectionOptions | ||
@@ -88,0 +89,0 @@ * @property {string[]} extension - File extensions to use |
@@ -22,3 +22,3 @@ 'use strict'; | ||
* watch. If not provided all files with an extension included in | ||
* `fileColletionParams.extension` are watched. See first argument of | ||
* `fileCollectionParams.extension` are watched. See first argument of | ||
* `chokidar.watch`. | ||
@@ -63,2 +63,6 @@ * @param {string[]} opts.watchIgnore - List of paths and patterns to | ||
// we need to call `newMocha.rootHooks` to set up rootHooks for the new | ||
// suite | ||
newMocha.rootHooks(newMocha.options.rootHooks); | ||
// in parallel mode, the main Mocha process doesn't actually load the | ||
@@ -82,3 +86,3 @@ // files. this flag prevents `mocha.run()` from autoloading. | ||
* watch. If not provided all files with an extension included in | ||
* `fileColletionParams.extension` are watched. See first argument of | ||
* `fileCollectionParams.extension` are watched. See first argument of | ||
* `chokidar.watch`. | ||
@@ -124,2 +128,6 @@ * @param {string[]} opts.watchIgnore - List of paths and patterns to | ||
// we need to call `newMocha.rootHooks` to set up rootHooks for the new | ||
// suite | ||
newMocha.rootHooks(newMocha.options.rootHooks); | ||
return newMocha; | ||
@@ -143,3 +151,3 @@ }, | ||
* not provided all files with an extension included in | ||
* `fileColletionParams.extension` are watched. See first argument of | ||
* `fileCollectionParams.extension` are watched. See first argument of | ||
* `chokidar.watch`. | ||
@@ -146,0 +154,0 @@ * @param {string[]} [opts.watchIgnore] - List of paths and patterns to exclude |
@@ -62,3 +62,3 @@ 'use strict'; | ||
/** | ||
* Invalid state transition occuring in `Mocha` instance | ||
* Invalid state transition occurring in `Mocha` instance | ||
*/ | ||
@@ -68,3 +68,3 @@ INSTANCE_ALREADY_RUNNING: 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING', | ||
/** | ||
* Invalid state transition occuring in `Mocha` instance | ||
* Invalid state transition occurring in `Mocha` instance | ||
*/ | ||
@@ -71,0 +71,0 @@ INSTANCE_ALREADY_DISPOSED: 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED', |
'use strict'; | ||
/** | ||
@module interfaces/common | ||
*/ | ||
var Suite = require('../suite'); | ||
@@ -12,2 +16,3 @@ var errors = require('../errors'); | ||
* | ||
* @private | ||
* @param {Suite[]} suites | ||
@@ -14,0 +19,0 @@ * @param {Context} context |
@@ -38,2 +38,3 @@ 'use strict'; | ||
* These are the states it can be in. | ||
* @private | ||
*/ | ||
@@ -43,2 +44,3 @@ var mochaStates = utils.defineConstants({ | ||
* Initial state of the mocha instance | ||
* @private | ||
*/ | ||
@@ -48,2 +50,3 @@ INIT: 'init', | ||
* Mocha instance is running tests | ||
* @private | ||
*/ | ||
@@ -54,2 +57,3 @@ RUNNING: 'running', | ||
* You can reset this state by unloading the test files. | ||
* @private | ||
*/ | ||
@@ -59,2 +63,3 @@ REFERENCES_CLEANED: 'referencesCleaned', | ||
* Mocha instance is disposed and can no longer be used. | ||
* @private | ||
*/ | ||
@@ -75,2 +80,3 @@ DISPOSED: 'disposed' | ||
* Expose internals. | ||
* @private | ||
*/ | ||
@@ -255,3 +261,3 @@ | ||
* @see [Reporters](../#reporters) | ||
* @param {String|Function} reporter - Reporter name or constructor. | ||
* @param {String|Function} reporterName - Reporter name or constructor. | ||
* @param {Object} [reporterOptions] - Options used to configure the reporter. | ||
@@ -779,4 +785,4 @@ * @returns {Mocha} this | ||
*/ | ||
Mocha.prototype.retries = function(n) { | ||
this.suite.retries(n); | ||
Mocha.prototype.retries = function(retry) { | ||
this.suite.retries(retry); | ||
return this; | ||
@@ -932,2 +938,3 @@ }; | ||
* | ||
* @private | ||
* @callback DoneCB | ||
@@ -1103,2 +1110,3 @@ * @param {number} failures - Number of failures that occurred. | ||
* An alternative way to define root hooks that works with parallel runs. | ||
* @private | ||
* @typedef {Object} MochaRootHookObject | ||
@@ -1113,4 +1121,5 @@ * @property {Function|Function[]} [beforeAll] - "Before all" hook(s) | ||
* An function that returns a {@link MochaRootHookObject}, either sync or async. | ||
* @private | ||
* @callback MochaRootHookFunction | ||
* @returns {MochaRootHookObject|Promise<MochaRootHookObject>} | ||
*/ |
@@ -284,2 +284,3 @@ /** | ||
* Listener function intended to be bound to `Process.SIGINT` event | ||
* @private | ||
* @callback SigIntListener | ||
@@ -291,2 +292,3 @@ * @returns {Promise<void>} | ||
* A function accepting a test file path and returning the results of a test run | ||
* @private | ||
* @callback FileRunner | ||
@@ -293,0 +295,0 @@ * @param {string} filename - File to run |
@@ -390,2 +390,3 @@ /** | ||
* by the deserializer. | ||
* @private | ||
* @typedef {Object} SerializedEvent | ||
@@ -399,2 +400,3 @@ * @property {object?} data - Optional serialized data | ||
* by the deserializer. | ||
* @private | ||
* @typedef {Object} SerializedWorkerResult | ||
@@ -401,0 +403,0 @@ * @property {number} failureCount - Number of failures |
'use strict'; | ||
/** | ||
@module Pending | ||
*/ | ||
module.exports = Pending; | ||
@@ -4,0 +8,0 @@ |
@@ -9,7 +9,6 @@ 'use strict'; | ||
var tty = require('tty'); | ||
var diff = require('diff'); | ||
var milliseconds = require('ms'); | ||
var utils = require('../utils'); | ||
var supportsColor = utils.isBrowser() ? null : require('supports-color'); | ||
var supportsColor = require('supports-color'); | ||
var constants = require('../runner').constants; | ||
@@ -19,2 +18,12 @@ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; | ||
var isBrowser = require('../utils').isBrowser; | ||
function getBrowserWindowSize() { | ||
if ('innerHeight' in global) { | ||
return [global.innerHeight, global.innerWidth]; | ||
} | ||
// In a Web Worker, the DOM Window is not available. | ||
return [640, 480]; | ||
} | ||
/** | ||
@@ -30,3 +39,3 @@ * Expose `Base`. | ||
var isatty = process.stdout.isTTY && process.stderr.isTTY; | ||
var isatty = isBrowser ? true : process.stdout.isTTY && process.stderr.isTTY; | ||
@@ -75,3 +84,5 @@ /** | ||
'diff added': 32, | ||
'diff removed': 31 | ||
'diff removed': 31, | ||
'diff added inline': '30;42', | ||
'diff removed inline': '30;41' | ||
}; | ||
@@ -125,5 +136,7 @@ | ||
if (isatty) { | ||
exports.window.width = process.stdout.getWindowSize | ||
? process.stdout.getWindowSize(1)[0] | ||
: tty.getWindowSize()[1]; | ||
if (isBrowser) { | ||
exports.window.width = getBrowserWindowSize()[1]; | ||
} else { | ||
exports.window.width = process.stdout.getWindowSize(1)[0]; | ||
} | ||
} | ||
@@ -414,5 +427,5 @@ | ||
'\n' + | ||
color('diff removed', 'actual') + | ||
color('diff removed inline', 'actual') + | ||
' ' + | ||
color('diff added', 'expected') + | ||
color('diff added inline', 'expected') + | ||
'\n\n' + | ||
@@ -483,6 +496,6 @@ msg + | ||
if (str.added) { | ||
return colorLines('diff added', str.value); | ||
return colorLines('diff added inline', str.value); | ||
} | ||
if (str.removed) { | ||
return colorLines('diff removed', str.value); | ||
return colorLines('diff removed inline', str.value); | ||
} | ||
@@ -489,0 +502,0 @@ return str.value; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
* Save timer references to avoid Sinon interfering (see GH-237). | ||
* @private | ||
*/ | ||
@@ -16,0 +17,0 @@ var Date = global.Date; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
* Module dependencies. | ||
* @private | ||
*/ | ||
@@ -35,2 +36,3 @@ var util = require('util'); | ||
* Non-enumerable globals. | ||
* @private | ||
* @readonly | ||
@@ -363,2 +365,15 @@ */ | ||
* | ||
* If `test` is a hook, failures work in the following pattern: | ||
* - If bail, run corresponding `after each` and `after` hooks, | ||
* then exit | ||
* - Failed `before` hook skips all tests in a suite and subsuites, | ||
* but jumps to corresponding `after` hook | ||
* - Failed `before each` hook skips remaining tests in a | ||
* suite and jumps to corresponding `after each` hook, | ||
* which is run only once | ||
* - Failed `after` hook does not alter execution order | ||
* - Failed `after each` hook skips remaining tests in a | ||
* suite and subsuites, but executes other `after each` | ||
* hooks | ||
* | ||
* @private | ||
@@ -403,40 +418,2 @@ * @param {Runnable} test | ||
/** | ||
* Fail the given `hook` with `err`. | ||
* | ||
* Hook failures work in the following pattern: | ||
* - If bail, run corresponding `after each` and `after` hooks, | ||
* then exit | ||
* - Failed `before` hook skips all tests in a suite and subsuites, | ||
* but jumps to corresponding `after` hook | ||
* - Failed `before each` hook skips remaining tests in a | ||
* suite and jumps to corresponding `after each` hook, | ||
* which is run only once | ||
* - Failed `after` hook does not alter execution order | ||
* - Failed `after each` hook skips remaining tests in a | ||
* suite and subsuites, but executes other `after each` | ||
* hooks | ||
* | ||
* @private | ||
* @param {Hook} hook | ||
* @param {Error} err | ||
*/ | ||
Runner.prototype.failHook = function(hook, err) { | ||
hook.originalTitle = hook.originalTitle || hook.title; | ||
if (hook.ctx && hook.ctx.currentTest) { | ||
hook.title = | ||
hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); | ||
} else { | ||
var parentTitle; | ||
if (hook.parent.title) { | ||
parentTitle = hook.parent.title; | ||
} else { | ||
parentTitle = hook.parent.root ? '{root}' : ''; | ||
} | ||
hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); | ||
} | ||
this.fail(hook, err); | ||
}; | ||
/** | ||
* Run hook `name` callbacks and then invoke `fn()`. | ||
@@ -469,2 +446,4 @@ * | ||
setHookTitle(hook); | ||
hook.allowUncaught = self.allowUncaught; | ||
@@ -476,3 +455,3 @@ | ||
self._addEventListener(hook, 'error', function(err) { | ||
self.failHook(hook, err); | ||
self.fail(hook, err); | ||
}); | ||
@@ -511,7 +490,7 @@ } | ||
var errForbid = createUnsupportedError('`this.skip` forbidden'); | ||
self.failHook(hook, errForbid); | ||
self.fail(hook, errForbid); | ||
return fn(errForbid); | ||
} | ||
} else if (err) { | ||
self.failHook(hook, err); | ||
self.fail(hook, err); | ||
// stop executing hooks, notify callee of hook err | ||
@@ -522,4 +501,21 @@ return fn(err); | ||
delete hook.ctx.currentTest; | ||
setHookTitle(hook); | ||
next(++i); | ||
}); | ||
function setHookTitle(hook) { | ||
hook.originalTitle = hook.originalTitle || hook.title; | ||
if (hook.ctx && hook.ctx.currentTest) { | ||
hook.title = | ||
hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); | ||
} else { | ||
var parentTitle; | ||
if (hook.parent.title) { | ||
parentTitle = hook.parent.title; | ||
} else { | ||
parentTitle = hook.parent.root ? '{root}' : ''; | ||
} | ||
hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); | ||
} | ||
} | ||
} | ||
@@ -526,0 +522,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
* Module dependencies. | ||
* @private | ||
*/ | ||
@@ -7,0 +8,0 @@ var EventEmitter = require('events').EventEmitter; |
202
lib/utils.js
@@ -12,10 +12,5 @@ 'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var util = require('util'); | ||
var glob = require('glob'); | ||
var he = require('he'); | ||
var errors = require('./errors'); | ||
var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError; | ||
var createMissingArgumentError = errors.createMissingArgumentError; | ||
@@ -101,63 +96,2 @@ var assign = (exports.assign = require('object.assign').getPolyfill()); | ||
/** | ||
* Parse the given `qs`. | ||
* | ||
* @private | ||
* @param {string} qs | ||
* @return {Object} | ||
*/ | ||
exports.parseQuery = function(qs) { | ||
return qs | ||
.replace('?', '') | ||
.split('&') | ||
.reduce(function(obj, pair) { | ||
var i = pair.indexOf('='); | ||
var key = pair.slice(0, i); | ||
var val = pair.slice(++i); | ||
// Due to how the URLSearchParams API treats spaces | ||
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20')); | ||
return obj; | ||
}, {}); | ||
}; | ||
/** | ||
* Highlight the given string of `js`. | ||
* | ||
* @private | ||
* @param {string} js | ||
* @return {string} | ||
*/ | ||
function highlight(js) { | ||
return js | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>') | ||
.replace(/('.*?')/gm, '<span class="string">$1</span>') | ||
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>') | ||
.replace(/(\d+)/gm, '<span class="number">$1</span>') | ||
.replace( | ||
/\bnew[ \t]+(\w+)/gm, | ||
'<span class="keyword">new</span> <span class="init">$1</span>' | ||
) | ||
.replace( | ||
/\b(function|new|throw|return|var|if|else)\b/gm, | ||
'<span class="keyword">$1</span>' | ||
); | ||
} | ||
/** | ||
* Highlight the contents of tag `name`. | ||
* | ||
* @private | ||
* @param {string} name | ||
*/ | ||
exports.highlightTags = function(name) { | ||
var code = document.getElementById('mocha').getElementsByTagName(name); | ||
for (var i = 0, len = code.length; i < len; ++i) { | ||
code[i].innerHTML = highlight(code[i].innerHTML); | ||
} | ||
}; | ||
/** | ||
* If a value could have properties, and has none, this function is called, | ||
@@ -450,136 +384,2 @@ * which returns a string representation of the empty value. | ||
/** | ||
* Determines if pathname has a matching file extension. | ||
* | ||
* @private | ||
* @param {string} pathname - Pathname to check for match. | ||
* @param {string[]} exts - List of file extensions (sans period). | ||
* @return {boolean} whether file extension matches. | ||
* @example | ||
* hasMatchingExtname('foo.html', ['js', 'css']); // => false | ||
*/ | ||
function hasMatchingExtname(pathname, exts) { | ||
var suffix = path.extname(pathname).slice(1); | ||
return exts.some(function(element) { | ||
return suffix === element; | ||
}); | ||
} | ||
/** | ||
* Determines if pathname would be a "hidden" file (or directory) on UN*X. | ||
* | ||
* @description | ||
* On UN*X, pathnames beginning with a full stop (aka dot) are hidden during | ||
* typical usage. Dotfiles, plain-text configuration files, are prime examples. | ||
* | ||
* @see {@link http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html|Origin of Dot File Names} | ||
* | ||
* @private | ||
* @param {string} pathname - Pathname to check for match. | ||
* @return {boolean} whether pathname would be considered a hidden file. | ||
* @example | ||
* isHiddenOnUnix('.profile'); // => true | ||
*/ | ||
function isHiddenOnUnix(pathname) { | ||
return path.basename(pathname)[0] === '.'; | ||
} | ||
/** | ||
* Lookup file names at the given `path`. | ||
* | ||
* @description | ||
* Filenames are returned in _traversal_ order by the OS/filesystem. | ||
* **Make no assumption that the names will be sorted in any fashion.** | ||
* | ||
* @public | ||
* @param {string} filepath - Base path to start searching from. | ||
* @param {string[]} [extensions=[]] - File extensions to look for. | ||
* @param {boolean} [recursive=false] - Whether to recurse into subdirectories. | ||
* @return {string[]} An array of paths. | ||
* @throws {Error} if no files match pattern. | ||
* @throws {TypeError} if `filepath` is directory and `extensions` not provided. | ||
*/ | ||
exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) { | ||
extensions = extensions || []; | ||
recursive = recursive || false; | ||
var files = []; | ||
var stat; | ||
if (!fs.existsSync(filepath)) { | ||
var pattern; | ||
if (glob.hasMagic(filepath)) { | ||
// Handle glob as is without extensions | ||
pattern = filepath; | ||
} else { | ||
// glob pattern e.g. 'filepath+(.js|.ts)' | ||
var strExtensions = extensions | ||
.map(function(v) { | ||
return '.' + v; | ||
}) | ||
.join('|'); | ||
pattern = filepath + '+(' + strExtensions + ')'; | ||
} | ||
files = glob.sync(pattern, {nodir: true}); | ||
if (!files.length) { | ||
throw createNoFilesMatchPatternError( | ||
'Cannot find any files matching pattern ' + exports.dQuote(filepath), | ||
filepath | ||
); | ||
} | ||
return files; | ||
} | ||
// Handle file | ||
try { | ||
stat = fs.statSync(filepath); | ||
if (stat.isFile()) { | ||
return filepath; | ||
} | ||
} catch (err) { | ||
// ignore error | ||
return; | ||
} | ||
// Handle directory | ||
fs.readdirSync(filepath).forEach(function(dirent) { | ||
var pathname = path.join(filepath, dirent); | ||
var stat; | ||
try { | ||
stat = fs.statSync(pathname); | ||
if (stat.isDirectory()) { | ||
if (recursive) { | ||
files = files.concat(lookupFiles(pathname, extensions, recursive)); | ||
} | ||
return; | ||
} | ||
} catch (err) { | ||
// ignore error | ||
return; | ||
} | ||
if (!extensions.length) { | ||
throw createMissingArgumentError( | ||
util.format( | ||
'Argument %s required when argument %s is a directory', | ||
exports.sQuote('extensions'), | ||
exports.sQuote('filepath') | ||
), | ||
'extensions', | ||
'array' | ||
); | ||
} | ||
if ( | ||
!stat.isFile() || | ||
!hasMatchingExtname(pathname, extensions) || | ||
isHiddenOnUnix(pathname) | ||
) { | ||
return; | ||
} | ||
files.push(pathname); | ||
}); | ||
return files; | ||
}; | ||
/** | ||
* process.emitWarning or a polyfill | ||
@@ -810,3 +610,3 @@ * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options | ||
* @description | ||
* Versions prior to 10 did not support ES Modules, and version 10 has an old incompatibile version of ESM. | ||
* Versions prior to 10 did not support ES Modules, and version 10 has an old incompatible version of ESM. | ||
* This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs, | ||
@@ -813,0 +613,0 @@ * which is version >=12.11. |
{ | ||
"name": "mocha", | ||
"version": "8.0.1", | ||
"version": "8.1.0", | ||
"description": "simple, flexible, fun test framework", | ||
@@ -70,3 +70,3 @@ "keywords": [ | ||
"promise.allsettled": "1.0.2", | ||
"serialize-javascript": "3.0.0", | ||
"serialize-javascript": "4.0.0", | ||
"strip-json-comments": "3.0.1", | ||
@@ -79,3 +79,3 @@ "supports-color": "7.1.0", | ||
"yargs-parser": "13.1.2", | ||
"yargs-unparser": "1.6.0" | ||
"yargs-unparser": "1.6.1" | ||
}, | ||
@@ -85,10 +85,16 @@ "devDependencies": { | ||
"@11ty/eleventy-plugin-inclusive-language": "^1.0.0", | ||
"@babel/preset-env": "^7.10.4", | ||
"@mocha/docdash": "^2.1.3", | ||
"assetgraph-builder": "^8.0.1", | ||
"@rollup/plugin-babel": "^5.0.4", | ||
"@rollup/plugin-commonjs": "^13.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-multi-entry": "^3.0.1", | ||
"@rollup/plugin-node-resolve": "^8.1.0", | ||
"assetgraph-builder": "^8.1.0", | ||
"autoprefixer": "^9.7.4", | ||
"babel-eslint": "^10.1.0", | ||
"browserify": "^16.5.0", | ||
"browserify-package-json": "^1.0.1", | ||
"canvas": "^2.6.1", | ||
"chai": "^4.2.0", | ||
"coffee-script": "^1.12.7", | ||
"core-js": "^3.6.5", | ||
"coveralls": "^3.0.11", | ||
@@ -108,10 +114,9 @@ "cross-env": "^6.0.3", | ||
"husky": "^4.2.3", | ||
"hyperlink": "^4.4.3", | ||
"image-size": "^0.8.3", | ||
"hyperlink": "^4.5.0", | ||
"jsdoc": "^3.6.3", | ||
"karma": "^4.4.1", | ||
"karma-browserify": "^7.0.0", | ||
"karma": "^5.1.1", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha": "^2.0.1", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-requirejs": "^1.1.0", | ||
"karma-sauce-launcher": "^2.0.2", | ||
@@ -133,4 +138,9 @@ "lint-staged": "^9.5.0", | ||
"remark-inline-links": "^3.1.3", | ||
"requirejs": "^2.3.6", | ||
"rewiremock": "^3.14.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.18.2", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"rollup-plugin-node-globals": "^1.4.0", | ||
"rollup-plugin-visualizer": "^3.3.2", | ||
"sinon": "^9.0.1", | ||
@@ -145,2 +155,3 @@ "strip-ansi": "^6.0.0", | ||
"uslug": "^1.0.4", | ||
"uuid": "^8.0.0", | ||
"watchify": "^3.11.1" | ||
@@ -155,17 +166,10 @@ }, | ||
"mocha.js", | ||
"mocha.js.map", | ||
"browser-entry.js" | ||
], | ||
"browserify": { | ||
"transform": [ | ||
"./scripts/package-json-cullify" | ||
] | ||
}, | ||
"browser": { | ||
"./index.js": "./browser-entry.js", | ||
"./lib/nodejs/growl.js": "./lib/browser/growl.js", | ||
"tty": "./lib/browser/tty.js", | ||
"./lib/cli/*.js": false, | ||
"chokidar": false, | ||
"./lib/esm-utils.js": false, | ||
"fs": false, | ||
"glob": false, | ||
"path": false, | ||
@@ -172,0 +176,0 @@ "supports-color": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
2682024
73
33230
17
1
71
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedserialize-javascript@4.0.0(transitive)
+ Addedyargs@14.2.3(transitive)
+ Addedyargs-parser@15.0.3(transitive)
+ Addedyargs-unparser@1.6.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedserialize-javascript@3.0.0(transitive)
- Removedyargs-unparser@1.6.0(transitive)
Updatedserialize-javascript@4.0.0
Updatedyargs-unparser@1.6.1