Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-message-util

Package Overview
Dependencies
Maintainers
5
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-message-util - npm Package Compare versions

Comparing version 22.4.0 to 22.4.3

184

build/index.js

@@ -1,31 +0,53 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.separateMessageFromStack = exports.formatResultsErrors = exports.formatStackTrace = exports.formatExecError = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.separateMessageFromStack = exports.formatResultsErrors = exports.formatStackTrace = exports.formatExecError = undefined;
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _micromatch = require('micromatch');
var _micromatch2 = _interopRequireDefault(_micromatch);
var _slash = require('slash');
var _fs = require('fs');var _fs2 = _interopRequireDefault(_fs);
var _path = require('path');var _path2 = _interopRequireDefault(_path);
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);
var _micromatch = require('micromatch');var _micromatch2 = _interopRequireDefault(_micromatch);
var _slash = require('slash');var _slash2 = _interopRequireDefault(_slash);
var _slash2 = _interopRequireDefault(_slash);
var _codeFrame = require('@babel/code-frame');
var _stackUtils = require('stack-utils');var _stackUtils2 = _interopRequireDefault(_stackUtils);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _stackUtils = require('stack-utils');
var _stackUtils2 = _interopRequireDefault(_stackUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// stack utils tries to create pretty stack by making paths relative.
const stackUtils = new _stackUtils2.default({
cwd: 'something which does not exist' }); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/let nodeInternals = [];try {nodeInternals = _stackUtils2.default.nodeInternals() // this is to have the tests be the same in node 4 and node 6.
cwd: 'something which does not exist'
}); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
let nodeInternals = [];
try {
nodeInternals = _stackUtils2.default.nodeInternals()
// this is to have the tests be the same in node 4 and node 6.
// TODO: Remove when we drop support for node 4

@@ -38,11 +60,2 @@ .concat(new RegExp('internal/process/next_tick.js'));

const PATH_NODE_MODULES = `${_path2.default.sep}node_modules${_path2.default.sep}`;

@@ -74,17 +87,9 @@ const PATH_EXPECT_BUILD = `${_path2.default.sep}expect${_path2.default.sep}build${_path2.default.sep}`;

// which will get misaligned.
const trimPaths = string =>
string.match(STACK_PATH_REGEXP) ? trim(string) : string;
const trimPaths = string => string.match(STACK_PATH_REGEXP) ? trim(string) : string;
const getRenderedCallsite = (fileContent, line) => {
let renderedCallsite = (0, _codeFrame.codeFrameColumns)(
fileContent,
{ start: { line } },
{ highlightCode: true });
let renderedCallsite = (0, _codeFrame.codeFrameColumns)(fileContent, { start: { line } }, { highlightCode: true });
renderedCallsite = renderedCallsite.split('\n').map(line => MESSAGE_INDENT + line).join('\n');
renderedCallsite = renderedCallsite.
split('\n').
map(line => MESSAGE_INDENT + line).
join('\n');
renderedCallsite = `\n${renderedCallsite}\n`;

@@ -97,8 +102,3 @@ return renderedCallsite;

// are executed.
const formatExecError = exports.formatExecError = (
testResult,
config,
options,
testPath) =>
{
const formatExecError = exports.formatExecError = (testResult, config, options, testPath) => {
let error = testResult.testExecError;

@@ -108,6 +108,9 @@ if (!error || typeof error === 'number') {

error.stack = '';
}var _error =
}
error;let message = _error.message,stack = _error.stack;
var _error = error;
let message = _error.message,
stack = _error.stack;
if (typeof error === 'string' || !error) {

@@ -127,10 +130,4 @@ error || (error = 'EMPTY ERROR');

message = message.
split(/\n/).
map(line => MESSAGE_INDENT + line).
join('\n');
stack =
stack && !options.noStackTrace ?
'\n' + formatStackTrace(stack, config, options, testPath) :
'';
message = message.split(/\n/).map(line => MESSAGE_INDENT + line).join('\n');
stack = stack && !options.noStackTrace ? '\n' + formatStackTrace(stack, config, options, testPath) : '';

@@ -142,11 +139,3 @@ if (message.match(/^\s*$/) && stack.match(/^\s*$/)) {

return (
TITLE_INDENT +
TITLE_BULLET +
EXEC_ERROR_MESSAGE +
'\n\n' +
message +
stack +
'\n');
return TITLE_INDENT + TITLE_BULLET + EXEC_ERROR_MESSAGE + '\n\n' + message + stack + '\n';
};

@@ -202,8 +191,3 @@

const formatPaths = (
config,
options,
relativeTestPath,
line) =>
{
const formatPaths = (config, options, relativeTestPath, line) => {
// Extract the file path from the trace line.

@@ -217,8 +201,3 @@ const match = line.match(/(^\s*at .*?\(?)([^()]+)(:[0-9]+:[0-9]+\)?.*$)/);

// highlight paths from the current test file
if (
config.testMatch &&
config.testMatch.length &&
(0, _micromatch2.default)(filePath, config.testMatch) ||
filePath === relativeTestPath)
{
if (config.testMatch && config.testMatch.length && (0, _micromatch2.default)(filePath, config.testMatch) || filePath === relativeTestPath) {
filePath = _chalk2.default.reset.cyan(filePath);

@@ -245,13 +224,6 @@ }

const formatStackTrace = exports.formatStackTrace = (
stack,
config,
options,
testPath) =>
{
const formatStackTrace = exports.formatStackTrace = (stack, config, options, testPath) => {
let lines = stack.split(/\n/);
let renderedCallsite = '';
const relativeTestPath = testPath ?
(0, _slash2.default)(_path2.default.relative(config.rootDir, testPath)) :
null;
const relativeTestPath = testPath ? (0, _slash2.default)(_path2.default.relative(config.rootDir, testPath)) : null;
lines = removeInternalStackEntries(lines, options);

@@ -277,19 +249,8 @@

const stacktrace = lines.
map(
line =>
STACK_INDENT +
formatPaths(config, options, relativeTestPath, trimPaths(line))).
const stacktrace = lines.map(line => STACK_INDENT + formatPaths(config, options, relativeTestPath, trimPaths(line))).join('\n');
join('\n');
return renderedCallsite + stacktrace;
};
const formatResultsErrors = exports.formatResultsErrors = (
testResults,
config,
options,
testPath) =>
{
const formatResultsErrors = exports.formatResultsErrors = (testResults, config, options, testPath) => {
const failedResults = testResults.reduce((errors, result) => {

@@ -304,28 +265,19 @@ result.failureMessages.forEach(content => errors.push({ content, result }));

return failedResults.
map((_ref) => {let result = _ref.result,content = _ref.content;var _separateMessageFromS =
separateMessageFromStack(content);let message = _separateMessageFromS.message,stack = _separateMessageFromS.stack;
stack = options.noStackTrace ?
'' :
STACK_TRACE_COLOR(
formatStackTrace(stack, config, options, testPath)) +
'\n';
return failedResults.map((_ref) => {
let result = _ref.result,
content = _ref.content;
message = message.
split(/\n/).
map(line => MESSAGE_INDENT + line).
join('\n');
var _separateMessageFromS = separateMessageFromStack(content);
const title =
_chalk2.default.bold.red(
TITLE_INDENT +
TITLE_BULLET +
result.ancestorTitles.join(ANCESTRY_SEPARATOR) + (
result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') +
result.title) +
'\n';
let message = _separateMessageFromS.message,
stack = _separateMessageFromS.stack;
stack = options.noStackTrace ? '' : STACK_TRACE_COLOR(formatStackTrace(stack, config, options, testPath)) + '\n';
message = message.split(/\n/).map(line => MESSAGE_INDENT + line).join('\n');
const title = _chalk2.default.bold.red(TITLE_INDENT + TITLE_BULLET + result.ancestorTitles.join(ANCESTRY_SEPARATOR) + (result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + result.title) + '\n';
return title + '\n' + message + '\n' + stack;
}).
join('\n');
}).join('\n');
};

@@ -332,0 +284,0 @@

{
"name": "jest-message-util",
"version": "22.4.0",
"version": "22.4.3",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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