Comparing version 9.2.0 to 9.2.1
@@ -33,6 +33,2 @@ 'use strict'; | ||
const isModuleNotFoundError = err => | ||
err.code === 'MODULE_NOT_FOUND' || | ||
err.message.indexOf('Cannot find module') !== -1; | ||
/** | ||
@@ -45,13 +41,12 @@ * Parsers for various config filetypes. Each accepts a filepath and | ||
js: filepath => { | ||
const cwdFilepath = path.resolve(filepath); | ||
let cwdFilepath; | ||
try { | ||
debug('parsers: load using cwd-relative path: "%s"', cwdFilepath); | ||
debug('parsers: load cwd-relative path: "%s"', path.resolve(filepath)); | ||
cwdFilepath = require.resolve(path.resolve(filepath)); // evtl. throws | ||
return require(cwdFilepath); | ||
} catch (err) { | ||
if (isModuleNotFoundError(err)) { | ||
debug('parsers: retry load as module-relative path: "%s"', filepath); | ||
return require(filepath); | ||
} else { | ||
throw err; // rethrow | ||
} | ||
if (cwdFilepath) throw err; | ||
debug('parsers: retry load as module-relative path: "%s"', filepath); | ||
return require(filepath); | ||
} | ||
@@ -58,0 +53,0 @@ }, |
@@ -60,2 +60,7 @@ 'use strict'; | ||
/** | ||
* Truncate diffs longer than this value to avoid slow performance | ||
*/ | ||
exports.maxDiffSize = 8192; | ||
/** | ||
* Default color map. | ||
@@ -192,14 +197,19 @@ */ | ||
*/ | ||
var generateDiff = (exports.generateDiff = function (actual, expected) { | ||
try { | ||
const diffSize = 2048; | ||
if (actual.length > diffSize) { | ||
actual = actual.substring(0, diffSize) + ' ... Lines skipped'; | ||
var maxLen = exports.maxDiffSize; | ||
var skipped = 0; | ||
if (maxLen > 0) { | ||
skipped = Math.max(actual.length - maxLen, expected.length - maxLen); | ||
actual = actual.slice(0, maxLen); | ||
expected = expected.slice(0, maxLen); | ||
} | ||
if (expected.length > diffSize) { | ||
expected = expected.substring(0, diffSize) + ' ... Lines skipped'; | ||
} | ||
return exports.inlineDiffs | ||
let result = exports.inlineDiffs | ||
? inlineDiff(actual, expected) | ||
: unifiedDiff(actual, expected); | ||
if (skipped > 0) { | ||
result = `${result}\n [mocha] output truncated to ${maxLen} characters, see "maxDiffSize" reporter-option\n`; | ||
} | ||
return result; | ||
} catch (err) { | ||
@@ -323,2 +333,8 @@ var msg = | ||
var maxDiffSizeOpt = | ||
this.options.reporterOption && this.options.reporterOption.maxDiffSize; | ||
if (maxDiffSizeOpt !== undefined && !isNaN(Number(maxDiffSizeOpt))) { | ||
exports.maxDiffSize = Number(maxDiffSizeOpt); | ||
} | ||
runner.on(EVENT_TEST_PASS, function (test) { | ||
@@ -325,0 +341,0 @@ if (test.duration > test.slow()) { |
{ | ||
"name": "mocha", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"description": "simple, flexible, fun test framework", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3776602
56259
21