Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
Maintainers
3
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha - npm Package Compare versions

Comparing version 9.2.2 to 10.0.0

bin/mocha.js

2

lib/cli/commands.js

@@ -5,3 +5,3 @@ 'use strict';

* Exports Yargs commands
* @see https://git.io/fpJ0G
* @see https://github.com/yargs/yargs/blob/main/docs/advanced.md
* @private

@@ -8,0 +8,0 @@ * @module

@@ -42,3 +42,2 @@ 'use strict';

'full-trace',
'growl',
'inline-diffs',

@@ -80,3 +79,2 @@ 'invert',

grep: ['g'],
growl: ['G'],
ignore: ['exclude'],

@@ -83,0 +81,0 @@ invert: ['i'],

@@ -144,6 +144,2 @@ 'use strict';

},
growl: {
description: 'Enable Growl notifications',
group: GROUPS.OUTPUT
},
ignore: {

@@ -337,3 +333,3 @@ defaultDescription: '(none)',

`--compilers is DEPRECATED and no longer supported.
See https://git.io/vdcSr for migration information.`
See https://github.com/mochajs/mocha/wiki/compilers-deprecation for migration information.`
);

@@ -340,0 +336,0 @@ }

@@ -12,3 +12,2 @@ 'use strict';

var builtinReporters = require('./reporters');
var growl = require('./nodejs/growl');
var utils = require('./utils');

@@ -169,3 +168,2 @@ var mocharc = require('./mocharc.json');

* @param {RegExp|string} [options.grep] - Test filter given regular expression.
* @param {boolean} [options.growl] - Enable desktop notifications?
* @param {boolean} [options.inlineDiffs] - Display inline diffs?

@@ -200,3 +198,3 @@ * @param {boolean} [options.invert] - Invert test filter matches?

options.reporter,
options.reporterOption || options.reporterOptions // for backwards compability
options.reporterOption || options.reporterOptions // for backwards compatibility
)

@@ -228,3 +226,2 @@ .slow(options.slow)

'fullTrace',
'growl',
'inlineDiffs',

@@ -475,3 +472,3 @@ 'invert'

throw createUnsupportedError(
'unloadFile() is only suported in a Node.js environment'
'unloadFile() is only supported in a Node.js environment'
);

@@ -656,45 +653,2 @@ }

/**
* Enables desktop notification support if prerequisite software installed.
*
* @public
* @see [CLI option](../#-growl-g)
* @return {Mocha} this
* @chainable
*/
Mocha.prototype.growl = function () {
this.options.growl = this.isGrowlCapable();
if (!this.options.growl) {
var detail = utils.isBrowser()
? 'notification support not available in this browser...'
: 'notification support prerequisites not installed...';
console.error(detail + ' cannot enable!');
}
return this;
};
/**
* @summary
* Determines if Growl support seems likely.
*
* @description
* <strong>Not available when run in browser.</strong>
*
* @private
* @see {@link Growl#isCapable}
* @see {@link Mocha#growl}
* @return {boolean} whether Growl support can be expected
*/
Mocha.prototype.isGrowlCapable = growl.isCapable;
/**
* Implements desktop notifications using a pseudo-reporter.
*
* @private
* @see {@link Mocha#growl}
* @see {@link Growl#notify}
* @param {Runner} runner - Runner instance.
*/
Mocha.prototype._growl = growl.notify;
/**
* Specifies whitelist of variable names to be expected in global scope.

@@ -722,3 +676,3 @@ *

};
// for backwards compability, 'globals' is an alias of 'global'
// for backwards compatibility, 'globals' is an alias of 'global'
Mocha.prototype.globals = Mocha.prototype.global;

@@ -1047,5 +1001,2 @@

}
if (options.growl) {
this._growl(runner);
}
if (options.color !== undefined) {

@@ -1052,0 +1003,0 @@ exports.reporters.Base.useColors = options.color;

@@ -13,3 +13,3 @@ const path = require('path');

// so we add the file location to the error.
// This `if` should be removed once Node.js fixes the problem.
// TODO: remove once Node.js fixes the problem.
if (

@@ -34,60 +34,48 @@ err instanceof SyntaxError &&

const hasStableEsmImplementation = (() => {
const [major, minor] = process.version.split('.');
// ESM is stable from v12.22.0 onward
// https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules
const majorNumber = parseInt(major.slice(1), 10);
const minorNumber = parseInt(minor, 10);
return majorNumber > 12 || (majorNumber === 12 && minorNumber >= 22);
})();
exports.requireOrImport = hasStableEsmImplementation
? async file => {
if (path.extname(file) === '.mjs') {
return formattedImport(file);
}
exports.requireOrImport = async file => {
if (path.extname(file) === '.mjs') {
return formattedImport(file);
}
try {
return dealWithExports(await formattedImport(file));
} catch (err) {
if (
err.code === 'ERR_MODULE_NOT_FOUND' ||
err.code === 'ERR_UNKNOWN_FILE_EXTENSION' ||
err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
) {
try {
return dealWithExports(await formattedImport(file));
} catch (err) {
// Importing a file usually works, but the resolution of `import` is the ESM
// resolution algorithm, and not the CJS resolution algorithm. We may have
// failed because we tried the ESM resolution, so we try to `require` it.
return require(file);
} catch (requireErr) {
if (
err.code === 'ERR_MODULE_NOT_FOUND' ||
err.code === 'ERR_UNKNOWN_FILE_EXTENSION' ||
err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
requireErr.code === 'ERR_REQUIRE_ESM' ||
(requireErr instanceof SyntaxError &&
requireErr
.toString()
.includes('Cannot use import statement outside a module'))
) {
try {
// Importing a file usually works, but the resolution of `import` is the ESM
// resolution algorithm, and not the CJS resolution algorithm. So in this case
// if we fail, we may have failed because we tried the ESM resolution and failed
// So we try to `require` it
return require(file);
} catch (requireErr) {
if (
requireErr.code === 'ERR_REQUIRE_ESM' ||
(requireErr instanceof SyntaxError &&
requireErr
.toString()
.includes('Cannot use import statement outside a module'))
) {
// ERR_REQUIRE_ESM happens when the test file is a JS file, but via type:module is actually ESM,
// AND has an import to a file that doesn't exist.
// This throws an `ERR_MODULE_NOT_FOUND` error above,
// and when we try to `require` it here, it throws an `ERR_REQUIRE_ESM`.
// What we want to do is throw the original error (the `ERR_MODULE_NOT_FOUND`),
// and not the `ERR_REQUIRE_ESM` error, which is a red herring.
//
// SyntaxError happens when in an edge case: when we're using an ESM loader that loads
// a `test.ts` file (i.e. unrecognized extension), and that file includes an unknown
// import (which thows an ERR_MODULE_NOT_FOUND). require-ing it will throw the
// syntax error, because we cannot require a file that has import-s.
throw err;
} else {
throw requireErr;
}
}
// ERR_REQUIRE_ESM happens when the test file is a JS file, but via type:module is actually ESM,
// AND has an import to a file that doesn't exist.
// This throws an `ERR_MODULE_NOT_FOUND` error above,
// and when we try to `require` it here, it throws an `ERR_REQUIRE_ESM`.
// What we want to do is throw the original error (the `ERR_MODULE_NOT_FOUND`),
// and not the `ERR_REQUIRE_ESM` error, which is a red herring.
//
// SyntaxError happens when in an edge case: when we're using an ESM loader that loads
// a `test.ts` file (i.e. unrecognized extension), and that file includes an unknown
// import (which throws an ERR_MODULE_NOT_FOUND). `require`-ing it will throw the
// syntax error, because we cannot require a file that has `import`-s.
throw err;
} else {
throw err;
throw requireErr;
}
}
} else {
throw err;
}
: implementationOfRequireOrImportForUnstableEsm;
}
};

@@ -109,19 +97,1 @@ function dealWithExports(module) {

};
/* istanbul ignore next */
async function implementationOfRequireOrImportForUnstableEsm(file) {
if (path.extname(file) === '.mjs') {
return formattedImport(file);
}
// This is currently the only known way of figuring out whether a file is CJS or ESM in
// Node.js that doesn't necessitate calling `import` first.
try {
return require(file);
} catch (err) {
if (err.code === 'ERR_REQUIRE_ESM') {
return formattedImport(file);
} else {
throw err;
}
}
}

@@ -274,4 +274,5 @@ /**

* number of test failures.
* @param {{files: string[], options: Options}} opts - Files to run and
* command-line options, respectively.
* @param {Object} [opts] - options
* @param {string[]} opts.files - Files to run
* @param {Options} opts.options - command-line options
*/

@@ -278,0 +279,0 @@ run(callback, {files, options = {}} = {}) {

@@ -184,3 +184,3 @@ 'use strict';

} else {
stackString = test.err.stack.substr(
stackString = test.err.stack.slice(
test.err.message.length + indexOfMessage

@@ -187,0 +187,0 @@ );

@@ -138,3 +138,3 @@ 'use strict';

* @param {Suite} suite - Root suite
* @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether to delay execution of root suite until ready.
* @param {Object} [opts] - Settings object
* @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.

@@ -145,17 +145,5 @@ * @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.

*/
constructor(suite, opts) {
constructor(suite, opts = {}) {
super();
if (opts === undefined) {
opts = {};
}
if (typeof opts === 'boolean') {
// TODO: remove this
require('./errors').deprecate(
'"Runner(suite: Suite, delay: boolean)" is deprecated. Use "Runner(suite: Suite, {delay: boolean})" instead.'
);
this._delay = opts;
opts = {};
} else {
this._delay = opts.delay;
}
var self = this;

@@ -1036,3 +1024,5 @@ this._globals = [];

* @param {Function} fn - Callback when finished
* @param {{files: string[], options: Options}} [opts] - For subclasses
* @param {Object} [opts] - For subclasses
* @param {string[]} opts.files - Files to run
* @param {Options} opts.options - command-line options
* @returns {Runner} Runner instance.

@@ -1070,3 +1060,3 @@ */

this.state = constants.STATE_RUNNING;
if (this._delay) {
if (this._opts.delay) {
this.emit(constants.EVENT_DELAY_END);

@@ -1098,3 +1088,3 @@ debug('run(): "delay" ended');

if (this._delay) {
if (this._opts.delay) {
// for reporters, I guess.

@@ -1101,0 +1091,0 @@ // might be nice to debounce some dots while we wait.

{
"name": "mocha",
"version": "9.2.2",
"version": "10.0.0",
"type": "commonjs",

@@ -39,3 +39,3 @@ "description": "simple, flexible, fun test framework",

"bin": {
"mocha": "./bin/mocha",
"mocha": "./bin/mocha.js",
"_mocha": "./bin/_mocha"

@@ -48,3 +48,3 @@ },

"engines": {
"node": ">= 12.0.0"
"node": ">= 14.0.0"
},

@@ -63,3 +63,3 @@ "scripts": {

"chokidar": "3.5.3",
"debug": "4.3.3",
"debug": "4.3.4",
"diff": "5.0.0",

@@ -69,14 +69,12 @@ "escape-string-regexp": "4.0.0",

"glob": "7.2.0",
"growl": "1.10.5",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
"minimatch": "4.2.1",
"minimatch": "5.0.1",
"ms": "2.1.3",
"nanoid": "3.3.1",
"nanoid": "3.3.3",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
"which": "2.0.2",
"workerpool": "6.2.0",
"workerpool": "6.2.1",
"yargs": "16.2.0",

@@ -87,12 +85,10 @@ "yargs-parser": "20.2.4",

"devDependencies": {
"@11ty/eleventy": "^0.12.1",
"@11ty/eleventy": "^1.0.0",
"@11ty/eleventy-plugin-inclusive-language": "^1.0.3",
"@babel/eslint-parser": "^7.16.5",
"@babel/preset-env": "^7.16.11",
"@mocha/docdash": "^4.0.0",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@mocha/docdash": "^4.0.1",
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^3.0.1",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-multi-entry": "^4.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"assetgraph-builder": "^9.0.0",

@@ -102,5 +98,4 @@ "autoprefixer": "^9.8.6",

"chai": "^4.3.4",
"coffee-script": "^1.12.7",
"coffeescript": "^2.6.1",
"configstore": "^5.0.1",
"core-js": "^3.20.3",
"coveralls": "^3.1.1",

@@ -126,3 +121,2 @@ "cross-env": "^7.0.2",

"karma-mocha-reporter": "^2.2.5",
"karma-requirejs": "^1.1.0",
"karma-sauce-launcher": "^4.3.6",

@@ -142,13 +136,11 @@ "lint-staged": "^10.2.11",

"prettier": "^2.4.1",
"regenerator-runtime": "0.13.7",
"remark": "^14.0.2",
"remark-github": "^11.2.2",
"remark-inline-links": "^6.0.1",
"requirejs": "^2.3.6",
"rewiremock": "^3.14.3",
"rimraf": "^3.0.2",
"rollup": "^2.66.0",
"rollup": "^2.70.1",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-visualizer": "^5.5.4",
"rollup-plugin-polyfill-node": "^0.8.0",
"rollup-plugin-visualizer": "^5.6.0",
"sinon": "^9.0.3",

@@ -172,4 +164,3 @@ "strip-ansi": "^6.0.0",

"files": [
"bin/*mocha",
"assets/growl/*.png",
"bin/*mocha*",
"lib/**/*.{js,html,json}",

@@ -180,3 +171,2 @@ "index.js",

"mocha.js.map",
"mocha-es2018.js",
"browser-entry.js"

@@ -186,3 +176,2 @@ ],

"./index.js": "./browser-entry.js",
"./lib/nodejs/growl.js": "./lib/browser/growl.js",
"fs": false,

@@ -189,0 +178,0 @@ "path": false,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc