Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
73
Maintainers
3
Versions
192
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 10.1.0 to 10.2.0

7

lib/mocha.js

@@ -432,2 +432,4 @@ 'use strict';

* @see {@link Mocha#unloadFiles}
* @param {Object} [options] - Settings object.
* @param {Function} [options.esmDecorator] - Function invoked on esm module name right before importing it. By default will passthrough as is.
* @returns {Promise}

@@ -441,3 +443,3 @@ * @example

*/
Mocha.prototype.loadFilesAsync = function () {
Mocha.prototype.loadFilesAsync = function ({esmDecorator} = {}) {
var self = this;

@@ -455,3 +457,4 @@ var suite = this.suite;

suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
}
},
esmDecorator
);

@@ -458,0 +461,0 @@ };

const path = require('path');
const url = require('url');
const formattedImport = async file => {
const forward = x => x;
const formattedImport = async (file, esmDecorator = forward) => {
if (path.isAbsolute(file)) {
try {
return await import(url.pathToFileURL(file));
return await exports.doImport(esmDecorator(url.pathToFileURL(file)));
} catch (err) {

@@ -30,11 +32,13 @@ // This is a hack created because ESM in Node.js (at least in Node v15.5.1) does not emit

}
return import(file);
return exports.doImport(esmDecorator(file));
};
exports.requireOrImport = async file => {
exports.doImport = async file => import(file);
exports.requireOrImport = async (file, esmDecorator) => {
if (path.extname(file) === '.mjs') {
return formattedImport(file);
return formattedImport(file, esmDecorator);
}
try {
return dealWithExports(await formattedImport(file));
return dealWithExports(await formattedImport(file, esmDecorator));
} catch (err) {

@@ -89,8 +93,16 @@ if (

exports.loadFilesAsync = async (files, preLoadFunc, postLoadFunc) => {
exports.loadFilesAsync = async (
files,
preLoadFunc,
postLoadFunc,
esmDecorator
) => {
for (const file of files) {
preLoadFunc(file);
const result = await exports.requireOrImport(path.resolve(file));
const result = await exports.requireOrImport(
path.resolve(file),
esmDecorator
);
postLoadFunc(file, result);
}
};
{
"name": "mocha",
"version": "10.1.0",
"version": "10.2.0",
"type": "commonjs",

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

"coffeescript": "^2.6.1",
"configstore": "^5.0.1",
"coveralls": "^3.1.1",

@@ -141,3 +140,2 @@ "cross-env": "^7.0.2",

"svgo": "^1.3.2",
"through2": "^4.0.2",
"touch": "^3.1.0",

@@ -152,3 +150,2 @@ "unexpected": "^11.14.0",

"uuid": "^8.3.0",
"watchify": "^4.0.0",
"webpack": "^5.67.0",

@@ -155,0 +152,0 @@ "webpack-cli": "^4.9.1"

Sorry, the diff of this file is not supported yet

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc