Updating NPM dependencies
This commit is contained in:
175
node_modules/@jest/reporters/build/utils.js
generated
vendored
175
node_modules/@jest/reporters/build/utils.js
generated
vendored
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.wrapAnsiString = exports.getSummary = exports.relativePath = exports.formatTestPath = exports.trimAndFormatPath = exports.printDisplayName = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ function _path() {
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function _chalk() {
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ function _chalk() {
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
|
||||
_slash = function _slash() {
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ function _slash() {
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -49,6 +49,48 @@ function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
@@ -58,7 +100,7 @@ function _interopRequireDefault(obj) {
|
||||
const PROGRESS_BAR_WIDTH = 40;
|
||||
|
||||
const printDisplayName = config => {
|
||||
const displayName = config.displayName;
|
||||
const {displayName} = config;
|
||||
|
||||
const white = _chalk().default.reset.inverse.white;
|
||||
|
||||
@@ -66,14 +108,7 @@ const printDisplayName = config => {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (typeof displayName === 'string') {
|
||||
return _chalk().default.supportsColor
|
||||
? white(` ${displayName} `)
|
||||
: displayName;
|
||||
}
|
||||
|
||||
const name = displayName.name,
|
||||
color = displayName.color;
|
||||
const {name, color} = displayName;
|
||||
const chosenColor = _chalk().default.reset.inverse[color]
|
||||
? _chalk().default.reset.inverse[color]
|
||||
: white;
|
||||
@@ -85,12 +120,12 @@ exports.printDisplayName = printDisplayName;
|
||||
const trimAndFormatPath = (pad, config, testPath, columns) => {
|
||||
const maxLength = columns - pad;
|
||||
const relative = relativePath(config, testPath);
|
||||
const basename = relative.basename;
|
||||
let dirname = relative.dirname; // length is ok
|
||||
const {basename} = relative;
|
||||
let {dirname} = relative; // length is ok
|
||||
|
||||
if ((dirname + _path().default.sep + basename).length <= maxLength) {
|
||||
if ((dirname + path().sep + basename).length <= maxLength) {
|
||||
return (0, _slash().default)(
|
||||
_chalk().default.dim(dirname + _path().default.sep) +
|
||||
_chalk().default.dim(dirname + path().sep) +
|
||||
_chalk().default.bold(basename)
|
||||
);
|
||||
} // we can fit trimmed dirname and full basename
|
||||
@@ -102,15 +137,14 @@ const trimAndFormatPath = (pad, config, testPath, columns) => {
|
||||
dirname =
|
||||
'...' + dirname.slice(dirname.length - dirnameLength, dirname.length);
|
||||
return (0, _slash().default)(
|
||||
_chalk().default.dim(dirname + _path().default.sep) +
|
||||
_chalk().default.dim(dirname + path().sep) +
|
||||
_chalk().default.bold(basename)
|
||||
);
|
||||
}
|
||||
|
||||
if (basenameLength + 4 === maxLength) {
|
||||
return (0, _slash().default)(
|
||||
_chalk().default.dim('...' + _path().default.sep) +
|
||||
_chalk().default.bold(basename)
|
||||
_chalk().default.dim('...' + path().sep) + _chalk().default.bold(basename)
|
||||
);
|
||||
} // can't fit dirname, but can fit trimmed basename
|
||||
|
||||
@@ -124,13 +158,9 @@ const trimAndFormatPath = (pad, config, testPath, columns) => {
|
||||
exports.trimAndFormatPath = trimAndFormatPath;
|
||||
|
||||
const formatTestPath = (config, testPath) => {
|
||||
const _relativePath = relativePath(config, testPath),
|
||||
dirname = _relativePath.dirname,
|
||||
basename = _relativePath.basename;
|
||||
|
||||
const {dirname, basename} = relativePath(config, testPath);
|
||||
return (0, _slash().default)(
|
||||
_chalk().default.dim(dirname + _path().default.sep) +
|
||||
_chalk().default.bold(basename)
|
||||
_chalk().default.dim(dirname + path().sep) + _chalk().default.bold(basename)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -140,12 +170,9 @@ const relativePath = (config, testPath) => {
|
||||
// this function can be called with ProjectConfigs or GlobalConfigs. GlobalConfigs
|
||||
// do not have config.cwd, only config.rootDir. Try using config.cwd, fallback
|
||||
// to config.rootDir. (Also, some unit just use config.rootDir, which is ok)
|
||||
testPath = _path().default.relative(config.cwd || config.rootDir, testPath);
|
||||
|
||||
const dirname = _path().default.dirname(testPath);
|
||||
|
||||
const basename = _path().default.basename(testPath);
|
||||
|
||||
testPath = path().relative(config.cwd || config.rootDir, testPath);
|
||||
const dirname = path().dirname(testPath);
|
||||
const basename = path().basename(testPath);
|
||||
return {
|
||||
basename,
|
||||
dirname
|
||||
@@ -154,6 +181,46 @@ const relativePath = (config, testPath) => {
|
||||
|
||||
exports.relativePath = relativePath;
|
||||
|
||||
const getValuesCurrentTestCases = (currentTestCases = []) => {
|
||||
let numFailingTests = 0;
|
||||
let numPassingTests = 0;
|
||||
let numPendingTests = 0;
|
||||
let numTodoTests = 0;
|
||||
let numTotalTests = 0;
|
||||
currentTestCases.forEach(testCase => {
|
||||
switch (testCase.testCaseResult.status) {
|
||||
case 'failed': {
|
||||
numFailingTests++;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'passed': {
|
||||
numPassingTests++;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'skipped': {
|
||||
numPendingTests++;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'todo': {
|
||||
numTodoTests++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
numTotalTests++;
|
||||
});
|
||||
return {
|
||||
numFailingTests,
|
||||
numPassingTests,
|
||||
numPendingTests,
|
||||
numTodoTests,
|
||||
numTotalTests
|
||||
};
|
||||
};
|
||||
|
||||
const getSummary = (aggregatedResults, options) => {
|
||||
let runTime = (Date.now() - aggregatedResults.startTime) / 1000;
|
||||
|
||||
@@ -161,6 +228,9 @@ const getSummary = (aggregatedResults, options) => {
|
||||
runTime = Math.floor(runTime);
|
||||
}
|
||||
|
||||
const valuesForCurrentTestCases = getValuesCurrentTestCases(
|
||||
options === null || options === void 0 ? void 0 : options.currentTestCases
|
||||
);
|
||||
const estimatedTime = (options && options.estimatedTime) || 0;
|
||||
const snapshotResults = aggregatedResults.snapshot;
|
||||
const snapshotsAdded = snapshotResults.added;
|
||||
@@ -197,21 +267,30 @@ const getSummary = (aggregatedResults, options) => {
|
||||
? suitesRun + ' of ' + suitesTotal
|
||||
: suitesTotal) +
|
||||
` total`;
|
||||
const updatedTestsFailed =
|
||||
testsFailed + valuesForCurrentTestCases.numFailingTests;
|
||||
const updatedTestsPending =
|
||||
testsPending + valuesForCurrentTestCases.numPendingTests;
|
||||
const updatedTestsTodo = testsTodo + valuesForCurrentTestCases.numTodoTests;
|
||||
const updatedTestsPassed =
|
||||
testsPassed + valuesForCurrentTestCases.numPassingTests;
|
||||
const updatedTestsTotal =
|
||||
testsTotal + valuesForCurrentTestCases.numTotalTests;
|
||||
const tests =
|
||||
_chalk().default.bold('Tests: ') +
|
||||
(testsFailed
|
||||
? _chalk().default.bold.red(`${testsFailed} failed`) + ', '
|
||||
(updatedTestsFailed > 0
|
||||
? _chalk().default.bold.red(`${updatedTestsFailed} failed`) + ', '
|
||||
: '') +
|
||||
(testsPending
|
||||
? _chalk().default.bold.yellow(`${testsPending} skipped`) + ', '
|
||||
(updatedTestsPending > 0
|
||||
? _chalk().default.bold.yellow(`${updatedTestsPending} skipped`) + ', '
|
||||
: '') +
|
||||
(testsTodo
|
||||
? _chalk().default.bold.magenta(`${testsTodo} todo`) + ', '
|
||||
(updatedTestsTodo > 0
|
||||
? _chalk().default.bold.magenta(`${updatedTestsTodo} todo`) + ', '
|
||||
: '') +
|
||||
(testsPassed
|
||||
? _chalk().default.bold.green(`${testsPassed} passed`) + ', '
|
||||
(updatedTestsPassed > 0
|
||||
? _chalk().default.bold.green(`${updatedTestsPassed} passed`) + ', '
|
||||
: '') +
|
||||
`${testsTotal} total`;
|
||||
`${updatedTestsTotal} total`;
|
||||
const snapshots =
|
||||
_chalk().default.bold('Snapshots: ') +
|
||||
(snapshotsFailed
|
||||
@@ -254,12 +333,12 @@ const renderTime = (runTime, estimatedTime, width) => {
|
||||
// If we are more than one second over the estimated time, highlight it.
|
||||
const renderedTime =
|
||||
estimatedTime && runTime >= estimatedTime + 1
|
||||
? _chalk().default.bold.yellow(runTime + 's')
|
||||
: runTime + 's';
|
||||
? _chalk().default.bold.yellow((0, _jestUtil().formatTime)(runTime, 0))
|
||||
: (0, _jestUtil().formatTime)(runTime, 0);
|
||||
let time = _chalk().default.bold(`Time:`) + ` ${renderedTime}`;
|
||||
|
||||
if (runTime < estimatedTime) {
|
||||
time += `, estimated ${estimatedTime}s`;
|
||||
time += `, estimated ${(0, _jestUtil().formatTime)(estimatedTime, 0)}`;
|
||||
} // Only show a progress bar if the test run is actually going to take
|
||||
// some time.
|
||||
|
||||
@@ -273,9 +352,7 @@ const renderTime = (runTime, estimatedTime, width) => {
|
||||
if (availableWidth >= 2) {
|
||||
time +=
|
||||
'\n' +
|
||||
_chalk()
|
||||
.default.green('█')
|
||||
.repeat(length) +
|
||||
_chalk().default.green('█').repeat(length) +
|
||||
_chalk()
|
||||
.default.white('█')
|
||||
.repeat(availableWidth - length);
|
||||
|
||||
Reference in New Issue
Block a user