Socket
Socket
Sign inDemoInstall

jest-message-util

Package Overview
Dependencies
34
Maintainers
6
Versions
200
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 29.4.3 to 29.5.0

104

build/index.js

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

let cause = '';
const subErrors = [];
if (typeof error === 'string' || !error) {

@@ -209,2 +210,16 @@ error || (error = 'EMPTY ERROR');

}
if ('errors' in error && Array.isArray(error.errors)) {
for (const subError of error.errors) {
subErrors.push(
formatExecError(
subError,
config,
options,
testPath,
reuseMessage,
true
)
);
}
}
}

@@ -242,3 +257,9 @@ if (cause !== '') {

const title = noTitle ? '' : `${TITLE_INDENT + TITLE_BULLET}`;
return `${title + messageToUse + stack + cause}\n`;
const subErrorStr =
subErrors.length > 0
? indentAllLines(
`\n\nErrors contained in AggregateError:\n${subErrors.join('\n')}`
)
: '';
return `${title + messageToUse + stack + cause + subErrorStr}\n`;
};

@@ -363,7 +384,64 @@ exports.formatExecError = formatExecError;

exports.formatStackTrace = formatStackTrace;
function isErrorOrStackWithCause(errorOrStack) {
return (
typeof errorOrStack !== 'string' &&
'cause' in errorOrStack &&
(typeof errorOrStack.cause === 'string' ||
_util.types.isNativeError(errorOrStack.cause) ||
errorOrStack.cause instanceof Error)
);
}
function formatErrorStack(errorOrStack, config, options, testPath) {
// The stack of new Error('message') contains both the message and the stack,
// thus we need to sanitize and clean it for proper display using separateMessageFromStack.
const sourceStack =
typeof errorOrStack === 'string' ? errorOrStack : errorOrStack.stack || '';
let {message, stack} = separateMessageFromStack(sourceStack);
stack = options.noStackTrace
? ''
: `${STACK_TRACE_COLOR(
formatStackTrace(stack, config, options, testPath)
)}\n`;
message = checkForCommonEnvironmentErrors(message);
message = indentAllLines(message);
let cause = '';
if (isErrorOrStackWithCause(errorOrStack)) {
const nestedCause = formatErrorStack(
errorOrStack.cause,
config,
options,
testPath
);
cause = `\n${MESSAGE_INDENT}Cause:\n${nestedCause}`;
}
return `${message}\n${stack}${cause}`;
}
function failureDetailsToErrorOrStack(failureDetails, content) {
if (!failureDetails) {
return content;
}
if (
_util.types.isNativeError(failureDetails) ||
failureDetails instanceof Error
) {
return failureDetails; // receiving raw errors for jest-circus
}
if (
typeof failureDetails === 'object' &&
'error' in failureDetails &&
(_util.types.isNativeError(failureDetails.error) ||
failureDetails.error instanceof Error)
) {
return failureDetails.error; // receiving instances of FailedAssertion for jest-jasmine
}
return content;
}
const formatResultsErrors = (testResults, config, options, testPath) => {
const failedResults = testResults.reduce((errors, result) => {
result.failureMessages.forEach(item => {
result.failureMessages.forEach((item, index) => {
errors.push({
content: checkForCommonEnvironmentErrors(item),
content: item,
failureDetails: result.failureDetails[index],
result

@@ -378,10 +456,7 @@ });

return failedResults
.map(({result, content}) => {
let {message, stack} = separateMessageFromStack(content);
stack = options.noStackTrace
? ''
: `${STACK_TRACE_COLOR(
formatStackTrace(stack, config, options, testPath)
)}\n`;
message = indentAllLines(message);
.map(({result, content, failureDetails}) => {
const rootErrorOrStack = failureDetailsToErrorOrStack(
failureDetails,
content
);
const title = `${_chalk.default.bold.red(

@@ -394,3 +469,8 @@ TITLE_INDENT +

)}\n`;
return `${title}\n${message}\n${stack}`;
return `${title}\n${formatErrorStack(
rootErrorOrStack,
config,
options,
testPath
)}`;
})

@@ -397,0 +477,0 @@ .join('\n');

8

package.json
{
"name": "jest-message-util",
"version": "29.4.3",
"version": "29.5.0",
"repository": {

@@ -24,3 +24,3 @@ "type": "git",

"@babel/code-frame": "^7.12.13",
"@jest/types": "^29.4.3",
"@jest/types": "^29.5.0",
"@types/stack-utils": "^2.0.0",

@@ -30,3 +30,3 @@ "chalk": "^4.0.0",

"micromatch": "^4.0.4",
"pretty-format": "^29.4.3",
"pretty-format": "^29.5.0",
"slash": "^3.0.0",

@@ -44,3 +44,3 @@ "stack-utils": "^2.0.3"

},
"gitHead": "a49c88610e49a3242576160740a32a2fe11161e1"
"gitHead": "39f3beda6b396665bebffab94e8d7c45be30454c"
}
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