diff options
author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 |
commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/@jest/reporters/build | |
parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/@jest/reporters/build')
32 files changed, 3639 insertions, 0 deletions
diff --git a/node_modules/@jest/reporters/build/BaseReporter.d.ts b/node_modules/@jest/reporters/build/BaseReporter.d.ts new file mode 100644 index 0000000..17b36a0 --- /dev/null +++ b/node_modules/@jest/reporters/build/BaseReporter.d.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult, TestCaseResult, TestResult } from '@jest/test-result'; +import type { Context, Reporter, ReporterOnStartOptions, Test } from './types'; +export default class BaseReporter implements Reporter { + private _error?; + log(message: string): void; + onRunStart(_results?: AggregatedResult, _options?: ReporterOnStartOptions): void; + onTestCaseResult(_test: Test, _testCaseResult: TestCaseResult): void; + onTestResult(_test?: Test, _testResult?: TestResult, _results?: AggregatedResult): void; + onTestStart(_test?: Test): void; + onRunComplete(_contexts?: Set<Context>, _aggregatedResults?: AggregatedResult): Promise<void> | void; + protected _setError(error: Error): void; + getLastError(): Error | undefined; +} diff --git a/node_modules/@jest/reporters/build/BaseReporter.js b/node_modules/@jest/reporters/build/BaseReporter.js new file mode 100644 index 0000000..d457307 --- /dev/null +++ b/node_modules/@jest/reporters/build/BaseReporter.js @@ -0,0 +1,65 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const {remove: preRunMessageRemove} = _jestUtil().preRunMessage; + +class BaseReporter { + constructor() { + _defineProperty(this, '_error', void 0); + } + + log(message) { + process.stderr.write(message + '\n'); + } + + onRunStart(_results, _options) { + preRunMessageRemove(process.stderr); + } + + onTestCaseResult(_test, _testCaseResult) {} + + onTestResult(_test, _testResult, _results) {} + + onTestStart(_test) {} + + onRunComplete(_contexts, _aggregatedResults) {} + + _setError(error) { + this._error = error; + } // Return an error that occurred during reporting. This error will + // define whether the test run was successful or failed. + + getLastError() { + return this._error; + } +} + +exports.default = BaseReporter; diff --git a/node_modules/@jest/reporters/build/CoverageReporter.d.ts b/node_modules/@jest/reporters/build/CoverageReporter.d.ts new file mode 100644 index 0000000..fd600f3 --- /dev/null +++ b/node_modules/@jest/reporters/build/CoverageReporter.d.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult, TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import BaseReporter from './BaseReporter'; +import type { Context, CoverageReporterOptions, Test } from './types'; +export default class CoverageReporter extends BaseReporter { + private _coverageMap; + private _globalConfig; + private _sourceMapStore; + private _options; + private _v8CoverageResults; + static readonly filename: string; + constructor(globalConfig: Config.GlobalConfig, options?: CoverageReporterOptions); + onTestResult(_test: Test, testResult: TestResult): void; + onRunComplete(contexts: Set<Context>, aggregatedResults: AggregatedResult): Promise<void>; + private _addUntestedFiles; + private _checkThreshold; + private _getCoverageResult; +} diff --git a/node_modules/@jest/reporters/build/CoverageReporter.js b/node_modules/@jest/reporters/build/CoverageReporter.js new file mode 100644 index 0000000..4ea3f0e --- /dev/null +++ b/node_modules/@jest/reporters/build/CoverageReporter.js @@ -0,0 +1,668 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function path() { + const data = _interopRequireWildcard(require('path')); + + path = function () { + return data; + }; + + return data; +} + +function _v8Coverage() { + const data = require('@bcoe/v8-coverage'); + + _v8Coverage = function () { + return data; + }; + + return data; +} + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _glob() { + const data = _interopRequireDefault(require('glob')); + + _glob = function () { + return data; + }; + + return data; +} + +function fs() { + const data = _interopRequireWildcard(require('graceful-fs')); + + fs = function () { + return data; + }; + + return data; +} + +function _istanbulLibCoverage() { + const data = _interopRequireDefault(require('istanbul-lib-coverage')); + + _istanbulLibCoverage = function () { + return data; + }; + + return data; +} + +function _istanbulLibReport() { + const data = _interopRequireDefault(require('istanbul-lib-report')); + + _istanbulLibReport = function () { + return data; + }; + + return data; +} + +function _istanbulLibSourceMaps() { + const data = _interopRequireDefault(require('istanbul-lib-source-maps')); + + _istanbulLibSourceMaps = function () { + return data; + }; + + return data; +} + +function _istanbulReports() { + const data = _interopRequireDefault(require('istanbul-reports')); + + _istanbulReports = function () { + return data; + }; + + return data; +} + +function _v8ToIstanbul() { + const data = _interopRequireDefault(require('v8-to-istanbul')); + + _v8ToIstanbul = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +function _jestWorker() { + const data = require('jest-worker'); + + _jestWorker = function () { + return data; + }; + + return data; +} + +var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); + +var _getWatermarks = _interopRequireDefault(require('./getWatermarks')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const FAIL_COLOR = _chalk().default.bold.red; + +const RUNNING_TEST_COLOR = _chalk().default.bold.dim; + +class CoverageReporter extends _BaseReporter.default { + constructor(globalConfig, options) { + super(); + + _defineProperty(this, '_coverageMap', void 0); + + _defineProperty(this, '_globalConfig', void 0); + + _defineProperty(this, '_sourceMapStore', void 0); + + _defineProperty(this, '_options', void 0); + + _defineProperty(this, '_v8CoverageResults', void 0); + + this._coverageMap = _istanbulLibCoverage().default.createCoverageMap({}); + this._globalConfig = globalConfig; + this._sourceMapStore = + _istanbulLibSourceMaps().default.createSourceMapStore(); + this._v8CoverageResults = []; + this._options = options || {}; + } + + onTestResult(_test, testResult) { + if (testResult.v8Coverage) { + this._v8CoverageResults.push(testResult.v8Coverage); + + return; + } + + if (testResult.coverage) { + this._coverageMap.merge(testResult.coverage); + } + } + + async onRunComplete(contexts, aggregatedResults) { + await this._addUntestedFiles(contexts); + const {map, reportContext} = await this._getCoverageResult(); + + try { + const coverageReporters = this._globalConfig.coverageReporters || []; + + if (!this._globalConfig.useStderr && coverageReporters.length < 1) { + coverageReporters.push('text-summary'); + } + + coverageReporters.forEach(reporter => { + let additionalOptions = {}; + + if (Array.isArray(reporter)) { + [reporter, additionalOptions] = reporter; + } + + _istanbulReports() + .default.create(reporter, { + maxCols: process.stdout.columns || Infinity, + ...additionalOptions + }) + .execute(reportContext); + }); + aggregatedResults.coverageMap = map; + } catch (e) { + console.error( + _chalk().default.red(` + Failed to write coverage reports: + ERROR: ${e.toString()} + STACK: ${e.stack} + `) + ); + } + + this._checkThreshold(map); + } + + async _addUntestedFiles(contexts) { + const files = []; + contexts.forEach(context => { + const config = context.config; + + if ( + this._globalConfig.collectCoverageFrom && + this._globalConfig.collectCoverageFrom.length + ) { + context.hasteFS + .matchFilesWithGlob( + this._globalConfig.collectCoverageFrom, + config.rootDir + ) + .forEach(filePath => + files.push({ + config, + path: filePath + }) + ); + } + }); + + if (!files.length) { + return; + } + + if (_jestUtil().isInteractive) { + process.stderr.write( + RUNNING_TEST_COLOR('Running coverage on untested files...') + ); + } + + let worker; + + if (this._globalConfig.maxWorkers <= 1) { + worker = require('./CoverageWorker'); + } else { + worker = new (_jestWorker().Worker)(require.resolve('./CoverageWorker'), { + exposedMethods: ['worker'], + maxRetries: 2, + numWorkers: this._globalConfig.maxWorkers + }); + } + + const instrumentation = files.map(async fileObj => { + const filename = fileObj.path; + const config = fileObj.config; + + const hasCoverageData = this._v8CoverageResults.some(v8Res => + v8Res.some(innerRes => innerRes.result.url === filename) + ); + + if ( + !hasCoverageData && + !this._coverageMap.data[filename] && + 'worker' in worker + ) { + try { + const result = await worker.worker({ + config, + globalConfig: this._globalConfig, + options: { + ...this._options, + changedFiles: + this._options.changedFiles && + Array.from(this._options.changedFiles), + sourcesRelatedToTestsInChangedFiles: + this._options.sourcesRelatedToTestsInChangedFiles && + Array.from(this._options.sourcesRelatedToTestsInChangedFiles) + }, + path: filename + }); + + if (result) { + if (result.kind === 'V8Coverage') { + this._v8CoverageResults.push([ + { + codeTransformResult: undefined, + result: result.result + } + ]); + } else { + this._coverageMap.addFileCoverage(result.coverage); + } + } + } catch (error) { + console.error( + _chalk().default.red( + [ + `Failed to collect coverage from ${filename}`, + `ERROR: ${error.message}`, + `STACK: ${error.stack}` + ].join('\n') + ) + ); + } + } + }); + + try { + await Promise.all(instrumentation); + } catch { + // Do nothing; errors were reported earlier to the console. + } + + if (_jestUtil().isInteractive) { + (0, _jestUtil().clearLine)(process.stderr); + } + + if (worker && 'end' in worker && typeof worker.end === 'function') { + await worker.end(); + } + } + + _checkThreshold(map) { + const {coverageThreshold} = this._globalConfig; + + if (coverageThreshold) { + function check(name, thresholds, actuals) { + return ['statements', 'branches', 'lines', 'functions'].reduce( + (errors, key) => { + const actual = actuals[key].pct; + const actualUncovered = actuals[key].total - actuals[key].covered; + const threshold = thresholds[key]; + + if (threshold !== undefined) { + if (threshold < 0) { + if (threshold * -1 < actualUncovered) { + errors.push( + `Jest: Uncovered count for ${key} (${actualUncovered}) ` + + `exceeds ${name} threshold (${-1 * threshold})` + ); + } + } else if (actual < threshold) { + errors.push( + `Jest: "${name}" coverage threshold for ${key} (${threshold}%) not met: ${actual}%` + ); + } + } + + return errors; + }, + [] + ); + } + + const THRESHOLD_GROUP_TYPES = { + GLOB: 'glob', + GLOBAL: 'global', + PATH: 'path' + }; + const coveredFiles = map.files(); + const thresholdGroups = Object.keys(coverageThreshold); + const groupTypeByThresholdGroup = {}; + const filesByGlob = {}; + const coveredFilesSortedIntoThresholdGroup = coveredFiles.reduce( + (files, file) => { + const pathOrGlobMatches = thresholdGroups.reduce( + (agg, thresholdGroup) => { + const absoluteThresholdGroup = path().resolve(thresholdGroup); // The threshold group might be a path: + + if (file.indexOf(absoluteThresholdGroup) === 0) { + groupTypeByThresholdGroup[thresholdGroup] = + THRESHOLD_GROUP_TYPES.PATH; + return agg.concat([[file, thresholdGroup]]); + } // If the threshold group is not a path it might be a glob: + // Note: glob.sync is slow. By memoizing the files matching each glob + // (rather than recalculating it for each covered file) we save a tonne + // of execution time. + + if (filesByGlob[absoluteThresholdGroup] === undefined) { + filesByGlob[absoluteThresholdGroup] = _glob() + .default.sync(absoluteThresholdGroup) + .map(filePath => path().resolve(filePath)); + } + + if (filesByGlob[absoluteThresholdGroup].indexOf(file) > -1) { + groupTypeByThresholdGroup[thresholdGroup] = + THRESHOLD_GROUP_TYPES.GLOB; + return agg.concat([[file, thresholdGroup]]); + } + + return agg; + }, + [] + ); + + if (pathOrGlobMatches.length > 0) { + return files.concat(pathOrGlobMatches); + } // Neither a glob or a path? Toss it in global if there's a global threshold: + + if (thresholdGroups.indexOf(THRESHOLD_GROUP_TYPES.GLOBAL) > -1) { + groupTypeByThresholdGroup[THRESHOLD_GROUP_TYPES.GLOBAL] = + THRESHOLD_GROUP_TYPES.GLOBAL; + return files.concat([[file, THRESHOLD_GROUP_TYPES.GLOBAL]]); + } // A covered file that doesn't have a threshold: + + return files.concat([[file, undefined]]); + }, + [] + ); + + const getFilesInThresholdGroup = thresholdGroup => + coveredFilesSortedIntoThresholdGroup + .filter(fileAndGroup => fileAndGroup[1] === thresholdGroup) + .map(fileAndGroup => fileAndGroup[0]); + + function combineCoverage(filePaths) { + return filePaths + .map(filePath => map.fileCoverageFor(filePath)) + .reduce((combinedCoverage, nextFileCoverage) => { + if (combinedCoverage === undefined || combinedCoverage === null) { + return nextFileCoverage.toSummary(); + } + + return combinedCoverage.merge(nextFileCoverage.toSummary()); + }, undefined); + } + + let errors = []; + thresholdGroups.forEach(thresholdGroup => { + switch (groupTypeByThresholdGroup[thresholdGroup]) { + case THRESHOLD_GROUP_TYPES.GLOBAL: { + const coverage = combineCoverage( + getFilesInThresholdGroup(THRESHOLD_GROUP_TYPES.GLOBAL) + ); + + if (coverage) { + errors = errors.concat( + check( + thresholdGroup, + coverageThreshold[thresholdGroup], + coverage + ) + ); + } + + break; + } + + case THRESHOLD_GROUP_TYPES.PATH: { + const coverage = combineCoverage( + getFilesInThresholdGroup(thresholdGroup) + ); + + if (coverage) { + errors = errors.concat( + check( + thresholdGroup, + coverageThreshold[thresholdGroup], + coverage + ) + ); + } + + break; + } + + case THRESHOLD_GROUP_TYPES.GLOB: + getFilesInThresholdGroup(thresholdGroup).forEach( + fileMatchingGlob => { + errors = errors.concat( + check( + fileMatchingGlob, + coverageThreshold[thresholdGroup], + map.fileCoverageFor(fileMatchingGlob).toSummary() + ) + ); + } + ); + break; + + default: + // If the file specified by path is not found, error is returned. + if (thresholdGroup !== THRESHOLD_GROUP_TYPES.GLOBAL) { + errors = errors.concat( + `Jest: Coverage data for ${thresholdGroup} was not found.` + ); + } + + // Sometimes all files in the coverage data are matched by + // PATH and GLOB threshold groups in which case, don't error when + // the global threshold group doesn't match any files. + } + }); + errors = errors.filter( + err => err !== undefined && err !== null && err.length > 0 + ); + + if (errors.length > 0) { + this.log(`${FAIL_COLOR(errors.join('\n'))}`); + + this._setError(new Error(errors.join('\n'))); + } + } + } + + async _getCoverageResult() { + if (this._globalConfig.coverageProvider === 'v8') { + const mergedCoverages = (0, _v8Coverage().mergeProcessCovs)( + this._v8CoverageResults.map(cov => ({ + result: cov.map(r => r.result) + })) + ); + const fileTransforms = new Map(); + + this._v8CoverageResults.forEach(res => + res.forEach(r => { + if (r.codeTransformResult && !fileTransforms.has(r.result.url)) { + fileTransforms.set(r.result.url, r.codeTransformResult); + } + }) + ); + + const transformedCoverage = await Promise.all( + mergedCoverages.result.map(async res => { + var _fileTransform$wrappe; + + const fileTransform = fileTransforms.get(res.url); + let sourcemapContent = undefined; + + if ( + fileTransform !== null && + fileTransform !== void 0 && + fileTransform.sourceMapPath && + fs().existsSync(fileTransform.sourceMapPath) + ) { + sourcemapContent = JSON.parse( + fs().readFileSync(fileTransform.sourceMapPath, 'utf8') + ); + } + + const converter = (0, _v8ToIstanbul().default)( + res.url, + (_fileTransform$wrappe = + fileTransform === null || fileTransform === void 0 + ? void 0 + : fileTransform.wrapperLength) !== null && + _fileTransform$wrappe !== void 0 + ? _fileTransform$wrappe + : 0, + fileTransform && sourcemapContent + ? { + originalSource: fileTransform.originalCode, + source: fileTransform.code, + sourceMap: { + sourcemap: { + file: res.url, + ...sourcemapContent + } + } + } + : { + source: fs().readFileSync(res.url, 'utf8') + } + ); + await converter.load(); + converter.applyCoverage(res.functions); + const istanbulData = converter.toIstanbul(); + converter.destroy(); + return istanbulData; + }) + ); + + const map = _istanbulLibCoverage().default.createCoverageMap({}); + + transformedCoverage.forEach(res => map.merge(res)); + + const reportContext = _istanbulLibReport().default.createContext({ + coverageMap: map, + dir: this._globalConfig.coverageDirectory, + watermarks: (0, _getWatermarks.default)(this._globalConfig) + }); + + return { + map, + reportContext + }; + } + + const map = await this._sourceMapStore.transformCoverage(this._coverageMap); + + const reportContext = _istanbulLibReport().default.createContext({ + coverageMap: map, + dir: this._globalConfig.coverageDirectory, + sourceFinder: this._sourceMapStore.sourceFinder, + watermarks: (0, _getWatermarks.default)(this._globalConfig) + }); + + return { + map, + reportContext + }; + } +} + +exports.default = CoverageReporter; + +_defineProperty(CoverageReporter, 'filename', __filename); diff --git a/node_modules/@jest/reporters/build/CoverageWorker.d.ts b/node_modules/@jest/reporters/build/CoverageWorker.d.ts new file mode 100644 index 0000000..068ad0f --- /dev/null +++ b/node_modules/@jest/reporters/build/CoverageWorker.d.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { Config } from '@jest/types'; +import { CoverageWorkerResult } from './generateEmptyCoverage'; +import type { CoverageReporterSerializedOptions } from './types'; +export declare type CoverageWorkerData = { + globalConfig: Config.GlobalConfig; + config: Config.ProjectConfig; + path: Config.Path; + options?: CoverageReporterSerializedOptions; +}; +export type { CoverageWorkerResult }; +export declare function worker({ config, globalConfig, path, options, }: CoverageWorkerData): Promise<CoverageWorkerResult | null>; diff --git a/node_modules/@jest/reporters/build/CoverageWorker.js b/node_modules/@jest/reporters/build/CoverageWorker.js new file mode 100644 index 0000000..24de6c6 --- /dev/null +++ b/node_modules/@jest/reporters/build/CoverageWorker.js @@ -0,0 +1,103 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.worker = worker; + +function _exit() { + const data = _interopRequireDefault(require('exit')); + + _exit = function () { + return data; + }; + + return data; +} + +function fs() { + const data = _interopRequireWildcard(require('graceful-fs')); + + fs = function () { + return data; + }; + + return data; +} + +var _generateEmptyCoverage = _interopRequireDefault( + require('./generateEmptyCoverage') +); + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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; +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +// Make sure uncaught errors are logged before we exit. +process.on('uncaughtException', err => { + console.error(err.stack); + (0, _exit().default)(1); +}); + +function worker({config, globalConfig, path, options}) { + return (0, _generateEmptyCoverage.default)( + fs().readFileSync(path, 'utf8'), + path, + globalConfig, + config, + (options === null || options === void 0 ? void 0 : options.changedFiles) && + new Set(options.changedFiles), + (options === null || options === void 0 + ? void 0 + : options.sourcesRelatedToTestsInChangedFiles) && + new Set(options.sourcesRelatedToTestsInChangedFiles) + ); +} diff --git a/node_modules/@jest/reporters/build/DefaultReporter.d.ts b/node_modules/@jest/reporters/build/DefaultReporter.d.ts new file mode 100644 index 0000000..bb346ba --- /dev/null +++ b/node_modules/@jest/reporters/build/DefaultReporter.d.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +/// <reference types="node" /> +import type { AggregatedResult, TestCaseResult, TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import BaseReporter from './BaseReporter'; +import type { ReporterOnStartOptions, Test } from './types'; +export default class DefaultReporter extends BaseReporter { + private _clear; + private _err; + protected _globalConfig: Config.GlobalConfig; + private _out; + private _status; + private _bufferedOutput; + static readonly filename: string; + constructor(globalConfig: Config.GlobalConfig); + protected __wrapStdio(stream: NodeJS.WritableStream | NodeJS.WriteStream): void; + forceFlushBufferedOutput(): void; + protected __clearStatus(): void; + protected __printStatus(): void; + onRunStart(aggregatedResults: AggregatedResult, options: ReporterOnStartOptions): void; + onTestStart(test: Test): void; + onTestCaseResult(test: Test, testCaseResult: TestCaseResult): void; + onRunComplete(): void; + onTestResult(test: Test, testResult: TestResult, aggregatedResults: AggregatedResult): void; + testFinished(config: Config.ProjectConfig, testResult: TestResult, aggregatedResults: AggregatedResult): void; + printTestFileHeader(_testPath: Config.Path, config: Config.ProjectConfig, result: TestResult): void; + printTestFileFailureMessage(_testPath: Config.Path, _config: Config.ProjectConfig, result: TestResult): void; +} diff --git a/node_modules/@jest/reporters/build/DefaultReporter.js b/node_modules/@jest/reporters/build/DefaultReporter.js new file mode 100644 index 0000000..6349e68 --- /dev/null +++ b/node_modules/@jest/reporters/build/DefaultReporter.js @@ -0,0 +1,254 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _console() { + const data = require('@jest/console'); + + _console = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); + +var _Status = _interopRequireDefault(require('./Status')); + +var _getResultHeader = _interopRequireDefault(require('./getResultHeader')); + +var _getSnapshotStatus = _interopRequireDefault(require('./getSnapshotStatus')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const TITLE_BULLET = _chalk().default.bold('\u25cf '); + +class DefaultReporter extends _BaseReporter.default { + // ANSI clear sequence for the last printed status + constructor(globalConfig) { + super(); + + _defineProperty(this, '_clear', void 0); + + _defineProperty(this, '_err', void 0); + + _defineProperty(this, '_globalConfig', void 0); + + _defineProperty(this, '_out', void 0); + + _defineProperty(this, '_status', void 0); + + _defineProperty(this, '_bufferedOutput', void 0); + + this._globalConfig = globalConfig; + this._clear = ''; + this._out = process.stdout.write.bind(process.stdout); + this._err = process.stderr.write.bind(process.stderr); + this._status = new _Status.default(); + this._bufferedOutput = new Set(); + + this.__wrapStdio(process.stdout); + + this.__wrapStdio(process.stderr); + + this._status.onChange(() => { + this.__clearStatus(); + + this.__printStatus(); + }); + } + + __wrapStdio(stream) { + const write = stream.write.bind(stream); + let buffer = []; + let timeout = null; + + const flushBufferedOutput = () => { + const string = buffer.join(''); + buffer = []; // This is to avoid conflicts between random output and status text + + this.__clearStatus(); + + if (string) { + write(string); + } + + this.__printStatus(); + + this._bufferedOutput.delete(flushBufferedOutput); + }; + + this._bufferedOutput.add(flushBufferedOutput); + + const debouncedFlush = () => { + // If the process blows up no errors would be printed. + // There should be a smart way to buffer stderr, but for now + // we just won't buffer it. + if (stream === process.stderr) { + flushBufferedOutput(); + } else { + if (!timeout) { + timeout = setTimeout(() => { + flushBufferedOutput(); + timeout = null; + }, 100); + } + } + }; + + stream.write = chunk => { + buffer.push(chunk); + debouncedFlush(); + return true; + }; + } // Don't wait for the debounced call and flush all output immediately. + + forceFlushBufferedOutput() { + for (const flushBufferedOutput of this._bufferedOutput) { + flushBufferedOutput(); + } + } + + __clearStatus() { + if (_jestUtil().isInteractive) { + if (this._globalConfig.useStderr) { + this._err(this._clear); + } else { + this._out(this._clear); + } + } + } + + __printStatus() { + const {content, clear} = this._status.get(); + + this._clear = clear; + + if (_jestUtil().isInteractive) { + if (this._globalConfig.useStderr) { + this._err(content); + } else { + this._out(content); + } + } + } + + onRunStart(aggregatedResults, options) { + this._status.runStarted(aggregatedResults, options); + } + + onTestStart(test) { + this._status.testStarted(test.path, test.context.config); + } + + onTestCaseResult(test, testCaseResult) { + this._status.addTestCaseResult(test, testCaseResult); + } + + onRunComplete() { + this.forceFlushBufferedOutput(); + + this._status.runFinished(); + + process.stdout.write = this._out; + process.stderr.write = this._err; + (0, _jestUtil().clearLine)(process.stderr); + } + + onTestResult(test, testResult, aggregatedResults) { + this.testFinished(test.context.config, testResult, aggregatedResults); + + if (!testResult.skipped) { + this.printTestFileHeader( + testResult.testFilePath, + test.context.config, + testResult + ); + this.printTestFileFailureMessage( + testResult.testFilePath, + test.context.config, + testResult + ); + } + + this.forceFlushBufferedOutput(); + } + + testFinished(config, testResult, aggregatedResults) { + this._status.testFinished(config, testResult, aggregatedResults); + } + + printTestFileHeader(_testPath, config, result) { + this.log((0, _getResultHeader.default)(result, this._globalConfig, config)); + + if (result.console) { + this.log( + ' ' + + TITLE_BULLET + + 'Console\n\n' + + (0, _console().getConsoleOutput)( + result.console, + config, + this._globalConfig + ) + ); + } + } + + printTestFileFailureMessage(_testPath, _config, result) { + if (result.failureMessage) { + this.log(result.failureMessage); + } + + const didUpdate = this._globalConfig.updateSnapshot === 'all'; + const snapshotStatuses = (0, _getSnapshotStatus.default)( + result.snapshot, + didUpdate + ); + snapshotStatuses.forEach(this.log); + } +} + +exports.default = DefaultReporter; + +_defineProperty(DefaultReporter, 'filename', __filename); diff --git a/node_modules/@jest/reporters/build/NotifyReporter.d.ts b/node_modules/@jest/reporters/build/NotifyReporter.d.ts new file mode 100644 index 0000000..eaa0f7f --- /dev/null +++ b/node_modules/@jest/reporters/build/NotifyReporter.d.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import BaseReporter from './BaseReporter'; +import type { Context, TestSchedulerContext } from './types'; +export default class NotifyReporter extends BaseReporter { + private _notifier; + private _startRun; + private _globalConfig; + private _context; + static readonly filename: string; + constructor(globalConfig: Config.GlobalConfig, startRun: (globalConfig: Config.GlobalConfig) => unknown, context: TestSchedulerContext); + onRunComplete(contexts: Set<Context>, result: AggregatedResult): void; +} diff --git a/node_modules/@jest/reporters/build/NotifyReporter.js b/node_modules/@jest/reporters/build/NotifyReporter.js new file mode 100644 index 0000000..14242b6 --- /dev/null +++ b/node_modules/@jest/reporters/build/NotifyReporter.js @@ -0,0 +1,256 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function path() { + const data = _interopRequireWildcard(require('path')); + + path = function () { + return data; + }; + + return data; +} + +function util() { + const data = _interopRequireWildcard(require('util')); + + util = function () { + return data; + }; + + return data; +} + +function _exit() { + const data = _interopRequireDefault(require('exit')); + + _exit = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const isDarwin = process.platform === 'darwin'; +const icon = path().resolve(__dirname, '../assets/jest_logo.png'); + +class NotifyReporter extends _BaseReporter.default { + constructor(globalConfig, startRun, context) { + super(); + + _defineProperty(this, '_notifier', loadNotifier()); + + _defineProperty(this, '_startRun', void 0); + + _defineProperty(this, '_globalConfig', void 0); + + _defineProperty(this, '_context', void 0); + + this._globalConfig = globalConfig; + this._startRun = startRun; + this._context = context; + } + + onRunComplete(contexts, result) { + const success = + result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0; + const firstContext = contexts.values().next(); + const hasteFS = + firstContext && firstContext.value && firstContext.value.hasteFS; + let packageName; + + if (hasteFS != null) { + // assuming root package.json is the first one + const [filePath] = hasteFS.matchFiles('package.json'); + packageName = + filePath != null + ? hasteFS.getModuleName(filePath) + : this._globalConfig.rootDir; + } else { + packageName = this._globalConfig.rootDir; + } + + packageName = packageName != null ? `${packageName} - ` : ''; + const notifyMode = this._globalConfig.notifyMode; + const statusChanged = + this._context.previousSuccess !== success || this._context.firstRun; + const testsHaveRun = result.numTotalTests !== 0; + + if ( + testsHaveRun && + success && + (notifyMode === 'always' || + notifyMode === 'success' || + notifyMode === 'success-change' || + (notifyMode === 'change' && statusChanged) || + (notifyMode === 'failure-change' && statusChanged)) + ) { + const title = util().format('%s%d%% Passed', packageName, 100); + const message = `${isDarwin ? '\u2705 ' : ''}${(0, _jestUtil().pluralize)( + 'test', + result.numPassedTests + )} passed`; + + this._notifier.notify({ + icon, + message, + timeout: false, + title + }); + } else if ( + testsHaveRun && + !success && + (notifyMode === 'always' || + notifyMode === 'failure' || + notifyMode === 'failure-change' || + (notifyMode === 'change' && statusChanged) || + (notifyMode === 'success-change' && statusChanged)) + ) { + const failed = result.numFailedTests / result.numTotalTests; + const title = util().format( + '%s%d%% Failed', + packageName, + Math.ceil(Number.isNaN(failed) ? 0 : failed * 100) + ); + const message = util().format( + (isDarwin ? '\u26D4\uFE0F ' : '') + '%d of %d tests failed', + result.numFailedTests, + result.numTotalTests + ); + const watchMode = this._globalConfig.watch || this._globalConfig.watchAll; + const restartAnswer = 'Run again'; + const quitAnswer = 'Exit tests'; + + if (!watchMode) { + this._notifier.notify({ + icon, + message, + timeout: false, + title + }); + } else { + this._notifier.notify( + { + actions: [restartAnswer, quitAnswer], + closeLabel: 'Close', + icon, + message, + timeout: false, + title + }, + (err, _, metadata) => { + if (err || !metadata) { + return; + } + + if (metadata.activationValue === quitAnswer) { + (0, _exit().default)(0); + return; + } + + if (metadata.activationValue === restartAnswer) { + this._startRun(this._globalConfig); + } + } + ); + } + } + + this._context.previousSuccess = success; + this._context.firstRun = false; + } +} + +exports.default = NotifyReporter; + +_defineProperty(NotifyReporter, 'filename', __filename); + +function loadNotifier() { + try { + return require('node-notifier'); + } catch (err) { + if (err.code !== 'MODULE_NOT_FOUND') { + throw err; + } + + throw Error( + 'notify reporter requires optional peer dependency "node-notifier" but it was not found' + ); + } +} diff --git a/node_modules/@jest/reporters/build/Status.d.ts b/node_modules/@jest/reporters/build/Status.d.ts new file mode 100644 index 0000000..36bb7d9 --- /dev/null +++ b/node_modules/@jest/reporters/build/Status.d.ts @@ -0,0 +1,42 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult, TestCaseResult, TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import type { ReporterOnStartOptions, Test } from './types'; +declare type Cache = { + content: string; + clear: string; +}; +/** + * A class that generates the CLI status of currently running tests + * and also provides an ANSI escape sequence to remove status lines + * from the terminal. + */ +export default class Status { + private _cache; + private _callback?; + private _currentTests; + private _currentTestCases; + private _done; + private _emitScheduled; + private _estimatedTime; + private _interval?; + private _aggregatedResults?; + private _showStatus; + constructor(); + onChange(callback: () => void): void; + runStarted(aggregatedResults: AggregatedResult, options: ReporterOnStartOptions): void; + runFinished(): void; + addTestCaseResult(test: Test, testCaseResult: TestCaseResult): void; + testStarted(testPath: Config.Path, config: Config.ProjectConfig): void; + testFinished(_config: Config.ProjectConfig, testResult: TestResult, aggregatedResults: AggregatedResult): void; + get(): Cache; + private _emit; + private _debouncedEmit; + private _tick; +} +export {}; diff --git a/node_modules/@jest/reporters/build/Status.js b/node_modules/@jest/reporters/build/Status.js new file mode 100644 index 0000000..72f4fc6 --- /dev/null +++ b/node_modules/@jest/reporters/build/Status.js @@ -0,0 +1,272 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _stringLength() { + const data = _interopRequireDefault(require('string-length')); + + _stringLength = function () { + return data; + }; + + return data; +} + +var _utils = require('./utils'); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const RUNNING_TEXT = ' RUNS '; +const RUNNING = _chalk().default.reset.inverse.yellow.bold(RUNNING_TEXT) + ' '; +/** + * This class is a perf optimization for sorting the list of currently + * running tests. It tries to keep tests in the same positions without + * shifting the whole list. + */ + +class CurrentTestList { + constructor() { + _defineProperty(this, '_array', void 0); + + this._array = []; + } + + add(testPath, config) { + const index = this._array.indexOf(null); + + const record = { + config, + testPath + }; + + if (index !== -1) { + this._array[index] = record; + } else { + this._array.push(record); + } + } + + delete(testPath) { + const record = this._array.find( + record => record !== null && record.testPath === testPath + ); + + this._array[this._array.indexOf(record || null)] = null; + } + + get() { + return this._array; + } +} + +/** + * A class that generates the CLI status of currently running tests + * and also provides an ANSI escape sequence to remove status lines + * from the terminal. + */ +class Status { + constructor() { + _defineProperty(this, '_cache', void 0); + + _defineProperty(this, '_callback', void 0); + + _defineProperty(this, '_currentTests', void 0); + + _defineProperty(this, '_currentTestCases', void 0); + + _defineProperty(this, '_done', void 0); + + _defineProperty(this, '_emitScheduled', void 0); + + _defineProperty(this, '_estimatedTime', void 0); + + _defineProperty(this, '_interval', void 0); + + _defineProperty(this, '_aggregatedResults', void 0); + + _defineProperty(this, '_showStatus', void 0); + + this._cache = null; + this._currentTests = new CurrentTestList(); + this._currentTestCases = []; + this._done = false; + this._emitScheduled = false; + this._estimatedTime = 0; + this._showStatus = false; + } + + onChange(callback) { + this._callback = callback; + } + + runStarted(aggregatedResults, options) { + this._estimatedTime = (options && options.estimatedTime) || 0; + this._showStatus = options && options.showStatus; + this._interval = setInterval(() => this._tick(), 1000); + this._aggregatedResults = aggregatedResults; + + this._debouncedEmit(); + } + + runFinished() { + this._done = true; + if (this._interval) clearInterval(this._interval); + + this._emit(); + } + + addTestCaseResult(test, testCaseResult) { + this._currentTestCases.push({ + test, + testCaseResult + }); + + if (!this._showStatus) { + this._emit(); + } else { + this._debouncedEmit(); + } + } + + testStarted(testPath, config) { + this._currentTests.add(testPath, config); + + if (!this._showStatus) { + this._emit(); + } else { + this._debouncedEmit(); + } + } + + testFinished(_config, testResult, aggregatedResults) { + const {testFilePath} = testResult; + this._aggregatedResults = aggregatedResults; + + this._currentTests.delete(testFilePath); + + this._currentTestCases = this._currentTestCases.filter(({test}) => { + if (_config !== test.context.config) { + return true; + } + + return test.path !== testFilePath; + }); + + this._debouncedEmit(); + } + + get() { + if (this._cache) { + return this._cache; + } + + if (this._done) { + return { + clear: '', + content: '' + }; + } + + const width = process.stdout.columns; + let content = '\n'; + + this._currentTests.get().forEach(record => { + if (record) { + const {config, testPath} = record; + const projectDisplayName = config.displayName + ? (0, _utils.printDisplayName)(config) + ' ' + : ''; + const prefix = RUNNING + projectDisplayName; + content += + (0, _utils.wrapAnsiString)( + prefix + + (0, _utils.trimAndFormatPath)( + (0, _stringLength().default)(prefix), + config, + testPath, + width + ), + width + ) + '\n'; + } + }); + + if (this._showStatus && this._aggregatedResults) { + content += + '\n' + + (0, _utils.getSummary)(this._aggregatedResults, { + currentTestCases: this._currentTestCases, + estimatedTime: this._estimatedTime, + roundTime: true, + width + }); + } + + let height = 0; + + for (let i = 0; i < content.length; i++) { + if (content[i] === '\n') { + height++; + } + } + + const clear = '\r\x1B[K\r\x1B[1A'.repeat(height); + return (this._cache = { + clear, + content + }); + } + + _emit() { + this._cache = null; + if (this._callback) this._callback(); + } + + _debouncedEmit() { + if (!this._emitScheduled) { + // Perf optimization to avoid two separate renders When + // one test finishes and another test starts executing. + this._emitScheduled = true; + setTimeout(() => { + this._emit(); + + this._emitScheduled = false; + }, 100); + } + } + + _tick() { + this._debouncedEmit(); + } +} + +exports.default = Status; diff --git a/node_modules/@jest/reporters/build/SummaryReporter.d.ts b/node_modules/@jest/reporters/build/SummaryReporter.d.ts new file mode 100644 index 0000000..3d7570d --- /dev/null +++ b/node_modules/@jest/reporters/build/SummaryReporter.d.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import BaseReporter from './BaseReporter'; +import type { Context, ReporterOnStartOptions } from './types'; +export default class SummaryReporter extends BaseReporter { + private _estimatedTime; + private _globalConfig; + static readonly filename: string; + constructor(globalConfig: Config.GlobalConfig); + private _write; + onRunStart(aggregatedResults: AggregatedResult, options: ReporterOnStartOptions): void; + onRunComplete(contexts: Set<Context>, aggregatedResults: AggregatedResult): void; + private _printSnapshotSummary; + private _printSummary; + private _getTestSummary; +} diff --git a/node_modules/@jest/reporters/build/SummaryReporter.js b/node_modules/@jest/reporters/build/SummaryReporter.js new file mode 100644 index 0000000..5696da1 --- /dev/null +++ b/node_modules/@jest/reporters/build/SummaryReporter.js @@ -0,0 +1,271 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); + +var _getResultHeader = _interopRequireDefault(require('./getResultHeader')); + +var _getSnapshotSummary = _interopRequireDefault( + require('./getSnapshotSummary') +); + +var _utils = require('./utils'); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const TEST_SUMMARY_THRESHOLD = 20; +const NPM_EVENTS = new Set([ + 'prepublish', + 'publish', + 'postpublish', + 'preinstall', + 'install', + 'postinstall', + 'preuninstall', + 'uninstall', + 'postuninstall', + 'preversion', + 'version', + 'postversion', + 'pretest', + 'test', + 'posttest', + 'prestop', + 'stop', + 'poststop', + 'prestart', + 'start', + 'poststart', + 'prerestart', + 'restart', + 'postrestart' +]); +const {npm_config_user_agent, npm_lifecycle_event, npm_lifecycle_script} = + process.env; + +class SummaryReporter extends _BaseReporter.default { + constructor(globalConfig) { + super(); + + _defineProperty(this, '_estimatedTime', void 0); + + _defineProperty(this, '_globalConfig', void 0); + + this._globalConfig = globalConfig; + this._estimatedTime = 0; + } // If we write more than one character at a time it is possible that + // Node.js exits in the middle of printing the result. This was first observed + // in Node.js 0.10 and still persists in Node.js 6.7+. + // Let's print the test failure summary character by character which is safer + // when hundreds of tests are failing. + + _write(string) { + for (let i = 0; i < string.length; i++) { + process.stderr.write(string.charAt(i)); + } + } + + onRunStart(aggregatedResults, options) { + super.onRunStart(aggregatedResults, options); + this._estimatedTime = options.estimatedTime; + } + + onRunComplete(contexts, aggregatedResults) { + const {numTotalTestSuites, testResults, wasInterrupted} = aggregatedResults; + + if (numTotalTestSuites) { + const lastResult = testResults[testResults.length - 1]; // Print a newline if the last test did not fail to line up newlines + // similar to when an error would have been thrown in the test. + + if ( + !this._globalConfig.verbose && + lastResult && + !lastResult.numFailingTests && + !lastResult.testExecError + ) { + this.log(''); + } + + this._printSummary(aggregatedResults, this._globalConfig); + + this._printSnapshotSummary( + aggregatedResults.snapshot, + this._globalConfig + ); + + if (numTotalTestSuites) { + let message = (0, _utils.getSummary)(aggregatedResults, { + estimatedTime: this._estimatedTime + }); + + if (!this._globalConfig.silent) { + message += + '\n' + + (wasInterrupted + ? _chalk().default.bold.red('Test run was interrupted.') + : this._getTestSummary(contexts, this._globalConfig)); + } + + this.log(message); + } + } + } + + _printSnapshotSummary(snapshots, globalConfig) { + if ( + snapshots.added || + snapshots.filesRemoved || + snapshots.unchecked || + snapshots.unmatched || + snapshots.updated + ) { + let updateCommand; + const event = npm_lifecycle_event || ''; + const prefix = NPM_EVENTS.has(event) ? '' : 'run '; + const isYarn = + typeof npm_config_user_agent === 'string' && + npm_config_user_agent.includes('yarn'); + const client = isYarn ? 'yarn' : 'npm'; + const scriptUsesJest = + typeof npm_lifecycle_script === 'string' && + npm_lifecycle_script.includes('jest'); + + if (globalConfig.watch || globalConfig.watchAll) { + updateCommand = 'press `u`'; + } else if (event && scriptUsesJest) { + updateCommand = `run \`${ + client + ' ' + prefix + event + (isYarn ? '' : ' --') + } -u\``; + } else { + updateCommand = 're-run jest with `-u`'; + } + + const snapshotSummary = (0, _getSnapshotSummary.default)( + snapshots, + globalConfig, + updateCommand + ); + snapshotSummary.forEach(this.log); + this.log(''); // print empty line + } + } + + _printSummary(aggregatedResults, globalConfig) { + // If there were any failing tests and there was a large number of tests + // executed, re-print the failing results at the end of execution output. + const failedTests = aggregatedResults.numFailedTests; + const runtimeErrors = aggregatedResults.numRuntimeErrorTestSuites; + + if ( + failedTests + runtimeErrors > 0 && + aggregatedResults.numTotalTestSuites > TEST_SUMMARY_THRESHOLD + ) { + this.log(_chalk().default.bold('Summary of all failing tests')); + aggregatedResults.testResults.forEach(testResult => { + const {failureMessage} = testResult; + + if (failureMessage) { + this._write( + (0, _getResultHeader.default)(testResult, globalConfig) + + '\n' + + failureMessage + + '\n' + ); + } + }); + this.log(''); // print empty line + } + } + + _getTestSummary(contexts, globalConfig) { + const getMatchingTestsInfo = () => { + const prefix = globalConfig.findRelatedTests + ? ' related to files matching ' + : ' matching '; + return ( + _chalk().default.dim(prefix) + + (0, _jestUtil().testPathPatternToRegExp)( + globalConfig.testPathPattern + ).toString() + ); + }; + + let testInfo = ''; + + if (globalConfig.runTestsByPath) { + testInfo = _chalk().default.dim(' within paths'); + } else if (globalConfig.onlyChanged) { + testInfo = _chalk().default.dim(' related to changed files'); + } else if (globalConfig.testPathPattern) { + testInfo = getMatchingTestsInfo(); + } + + let nameInfo = ''; + + if (globalConfig.runTestsByPath) { + nameInfo = ' ' + globalConfig.nonFlagArgs.map(p => `"${p}"`).join(', '); + } else if (globalConfig.testNamePattern) { + nameInfo = + _chalk().default.dim(' with tests matching ') + + `"${globalConfig.testNamePattern}"`; + } + + const contextInfo = + contexts.size > 1 + ? _chalk().default.dim(' in ') + + contexts.size + + _chalk().default.dim(' projects') + : ''; + return ( + _chalk().default.dim('Ran all test suites') + + testInfo + + nameInfo + + contextInfo + + _chalk().default.dim('.') + ); + } +} + +exports.default = SummaryReporter; + +_defineProperty(SummaryReporter, 'filename', __filename); diff --git a/node_modules/@jest/reporters/build/VerboseReporter.d.ts b/node_modules/@jest/reporters/build/VerboseReporter.d.ts new file mode 100644 index 0000000..1ab4ffc --- /dev/null +++ b/node_modules/@jest/reporters/build/VerboseReporter.d.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +/// <reference types="node" /> +import type { AggregatedResult, AssertionResult, Suite, TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import DefaultReporter from './DefaultReporter'; +import type { Test } from './types'; +export default class VerboseReporter extends DefaultReporter { + protected _globalConfig: Config.GlobalConfig; + static readonly filename: string; + constructor(globalConfig: Config.GlobalConfig); + protected __wrapStdio(stream: NodeJS.WritableStream | NodeJS.WriteStream): void; + static filterTestResults(testResults: Array<AssertionResult>): Array<AssertionResult>; + static groupTestsBySuites(testResults: Array<AssertionResult>): Suite; + onTestResult(test: Test, result: TestResult, aggregatedResults: AggregatedResult): void; + private _logTestResults; + private _logSuite; + private _getIcon; + private _logTest; + private _logTests; + private _logTodoOrPendingTest; + private _logLine; +} diff --git a/node_modules/@jest/reporters/build/VerboseReporter.js b/node_modules/@jest/reporters/build/VerboseReporter.js new file mode 100644 index 0000000..57758ed --- /dev/null +++ b/node_modules/@jest/reporters/build/VerboseReporter.js @@ -0,0 +1,226 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _DefaultReporter = _interopRequireDefault(require('./DefaultReporter')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} + +const {ICONS} = _jestUtil().specialChars; + +class VerboseReporter extends _DefaultReporter.default { + constructor(globalConfig) { + super(globalConfig); + + _defineProperty(this, '_globalConfig', void 0); + + this._globalConfig = globalConfig; + } // Verbose mode is for debugging. Buffering of output is undesirable. + // See https://github.com/facebook/jest/issues/8208 + + __wrapStdio(stream) { + const write = stream.write.bind(stream); + + stream.write = chunk => { + this.__clearStatus(); + + write(chunk); + + this.__printStatus(); + + return true; + }; + } + + static filterTestResults(testResults) { + return testResults.filter(({status}) => status !== 'pending'); + } + + static groupTestsBySuites(testResults) { + const root = { + suites: [], + tests: [], + title: '' + }; + testResults.forEach(testResult => { + let targetSuite = root; // Find the target suite for this test, + // creating nested suites as necessary. + + for (const title of testResult.ancestorTitles) { + let matchingSuite = targetSuite.suites.find(s => s.title === title); + + if (!matchingSuite) { + matchingSuite = { + suites: [], + tests: [], + title + }; + targetSuite.suites.push(matchingSuite); + } + + targetSuite = matchingSuite; + } + + targetSuite.tests.push(testResult); + }); + return root; + } + + onTestResult(test, result, aggregatedResults) { + super.testFinished(test.context.config, result, aggregatedResults); + + if (!result.skipped) { + this.printTestFileHeader( + result.testFilePath, + test.context.config, + result + ); + + if (!result.testExecError && !result.skipped) { + this._logTestResults(result.testResults); + } + + this.printTestFileFailureMessage( + result.testFilePath, + test.context.config, + result + ); + } + + super.forceFlushBufferedOutput(); + } + + _logTestResults(testResults) { + this._logSuite(VerboseReporter.groupTestsBySuites(testResults), 0); + + this._logLine(); + } + + _logSuite(suite, indentLevel) { + if (suite.title) { + this._logLine(suite.title, indentLevel); + } + + this._logTests(suite.tests, indentLevel + 1); + + suite.suites.forEach(suite => this._logSuite(suite, indentLevel + 1)); + } + + _getIcon(status) { + if (status === 'failed') { + return _chalk().default.red(ICONS.failed); + } else if (status === 'pending') { + return _chalk().default.yellow(ICONS.pending); + } else if (status === 'todo') { + return _chalk().default.magenta(ICONS.todo); + } else { + return _chalk().default.green(ICONS.success); + } + } + + _logTest(test, indentLevel) { + const status = this._getIcon(test.status); + + const time = test.duration + ? ` (${(0, _jestUtil().formatTime)(Math.round(test.duration))})` + : ''; + + this._logLine( + status + ' ' + _chalk().default.dim(test.title + time), + indentLevel + ); + } + + _logTests(tests, indentLevel) { + if (this._globalConfig.expand) { + tests.forEach(test => this._logTest(test, indentLevel)); + } else { + const summedTests = tests.reduce( + (result, test) => { + if (test.status === 'pending') { + result.pending.push(test); + } else if (test.status === 'todo') { + result.todo.push(test); + } else { + this._logTest(test, indentLevel); + } + + return result; + }, + { + pending: [], + todo: [] + } + ); + + if (summedTests.pending.length > 0) { + summedTests.pending.forEach(this._logTodoOrPendingTest(indentLevel)); + } + + if (summedTests.todo.length > 0) { + summedTests.todo.forEach(this._logTodoOrPendingTest(indentLevel)); + } + } + } + + _logTodoOrPendingTest(indentLevel) { + return test => { + const printedTestStatus = + test.status === 'pending' ? 'skipped' : test.status; + + const icon = this._getIcon(test.status); + + const text = _chalk().default.dim(`${printedTestStatus} ${test.title}`); + + this._logLine(`${icon} ${text}`, indentLevel); + }; + } + + _logLine(str, indentLevel) { + const indentation = ' '.repeat(indentLevel || 0); + this.log(indentation + (str || '')); + } +} + +exports.default = VerboseReporter; + +_defineProperty(VerboseReporter, 'filename', __filename); diff --git a/node_modules/@jest/reporters/build/generateEmptyCoverage.d.ts b/node_modules/@jest/reporters/build/generateEmptyCoverage.d.ts new file mode 100644 index 0000000..fdeecdb --- /dev/null +++ b/node_modules/@jest/reporters/build/generateEmptyCoverage.d.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { V8Coverage } from 'collect-v8-coverage'; +import { FileCoverage } from 'istanbul-lib-coverage'; +import type { Config } from '@jest/types'; +declare type SingleV8Coverage = V8Coverage[number]; +export declare type CoverageWorkerResult = { + kind: 'BabelCoverage'; + coverage: FileCoverage; +} | { + kind: 'V8Coverage'; + result: SingleV8Coverage; +}; +export default function generateEmptyCoverage(source: string, filename: Config.Path, globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, changedFiles?: Set<Config.Path>, sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>): Promise<CoverageWorkerResult | null>; +export {}; diff --git a/node_modules/@jest/reporters/build/generateEmptyCoverage.js b/node_modules/@jest/reporters/build/generateEmptyCoverage.js new file mode 100644 index 0000000..f8490f9 --- /dev/null +++ b/node_modules/@jest/reporters/build/generateEmptyCoverage.js @@ -0,0 +1,168 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = generateEmptyCoverage; + +function fs() { + const data = _interopRequireWildcard(require('graceful-fs')); + + fs = function () { + return data; + }; + + return data; +} + +function _istanbulLibCoverage() { + const data = require('istanbul-lib-coverage'); + + _istanbulLibCoverage = function () { + return data; + }; + + return data; +} + +function _istanbulLibInstrument() { + const data = require('istanbul-lib-instrument'); + + _istanbulLibInstrument = function () { + return data; + }; + + return data; +} + +function _transform() { + const data = require('@jest/transform'); + + _transform = function () { + return data; + }; + + return data; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +async function generateEmptyCoverage( + source, + filename, + globalConfig, + config, + changedFiles, + sourcesRelatedToTestsInChangedFiles +) { + const coverageOptions = { + changedFiles, + collectCoverage: globalConfig.collectCoverage, + collectCoverageFrom: globalConfig.collectCoverageFrom, + collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, + coverageProvider: globalConfig.coverageProvider, + sourcesRelatedToTestsInChangedFiles + }; + let coverageWorkerResult = null; + + if ((0, _transform().shouldInstrument)(filename, coverageOptions, config)) { + if (coverageOptions.coverageProvider === 'v8') { + const stat = fs().statSync(filename); + return { + kind: 'V8Coverage', + result: { + functions: [ + { + functionName: '(empty-report)', + isBlockCoverage: true, + ranges: [ + { + count: 0, + endOffset: stat.size, + startOffset: 0 + } + ] + } + ], + scriptId: '0', + url: filename + } + }; + } + + const scriptTransformer = await (0, _transform().createScriptTransformer)( + config + ); // Transform file with instrumentation to make sure initial coverage data is well mapped to original code. + + const {code} = await scriptTransformer.transformSourceAsync( + filename, + source, + { + instrument: true, + supportsDynamicImport: true, + supportsExportNamespaceFrom: true, + supportsStaticESM: true, + supportsTopLevelAwait: true + } + ); // TODO: consider passing AST + + const extracted = (0, _istanbulLibInstrument().readInitialCoverage)(code); // Check extracted initial coverage is not null, this can happen when using /* istanbul ignore file */ + + if (extracted) { + coverageWorkerResult = { + coverage: (0, _istanbulLibCoverage().createFileCoverage)( + extracted.coverageData + ), + kind: 'BabelCoverage' + }; + } + } + + return coverageWorkerResult; +} diff --git a/node_modules/@jest/reporters/build/getResultHeader.d.ts b/node_modules/@jest/reporters/build/getResultHeader.d.ts new file mode 100644 index 0000000..b9cb738 --- /dev/null +++ b/node_modules/@jest/reporters/build/getResultHeader.d.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +export default function getResultHeader(result: TestResult, globalConfig: Config.GlobalConfig, projectConfig?: Config.ProjectConfig): string; diff --git a/node_modules/@jest/reporters/build/getResultHeader.js b/node_modules/@jest/reporters/build/getResultHeader.js new file mode 100644 index 0000000..f497921 --- /dev/null +++ b/node_modules/@jest/reporters/build/getResultHeader.js @@ -0,0 +1,104 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = getResultHeader; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _terminalLink() { + const data = _interopRequireDefault(require('terminal-link')); + + _terminalLink = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _utils = require('./utils'); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +const LONG_TEST_COLOR = _chalk().default.reset.bold.bgRed; // Explicitly reset for these messages since they can get written out in the +// middle of error logging + +const FAIL_TEXT = 'FAIL'; +const PASS_TEXT = 'PASS'; +const FAIL = _chalk().default.supportsColor + ? _chalk().default.reset.inverse.bold.red(` ${FAIL_TEXT} `) + : FAIL_TEXT; +const PASS = _chalk().default.supportsColor + ? _chalk().default.reset.inverse.bold.green(` ${PASS_TEXT} `) + : PASS_TEXT; + +function getResultHeader(result, globalConfig, projectConfig) { + var _result$perfStats; + + const testPath = result.testFilePath; + const formattedTestPath = (0, _utils.formatTestPath)( + projectConfig ? projectConfig : globalConfig, + testPath + ); + const fileLink = (0, _terminalLink().default)( + formattedTestPath, + `file://${testPath}`, + { + fallback: () => formattedTestPath + } + ); + const status = + result.numFailingTests > 0 || result.testExecError ? FAIL : PASS; + const testDetail = []; + + if ( + (_result$perfStats = result.perfStats) !== null && + _result$perfStats !== void 0 && + _result$perfStats.slow + ) { + const runTime = result.perfStats.runtime / 1000; + testDetail.push(LONG_TEST_COLOR((0, _jestUtil().formatTime)(runTime, 0))); + } + + if (result.memoryUsage) { + const toMB = bytes => Math.floor(bytes / 1024 / 1024); + + testDetail.push(`${toMB(result.memoryUsage)} MB heap size`); + } + + const projectDisplayName = + projectConfig && projectConfig.displayName + ? (0, _utils.printDisplayName)(projectConfig) + ' ' + : ''; + return ( + `${status} ${projectDisplayName}${fileLink}` + + (testDetail.length ? ` (${testDetail.join(', ')})` : '') + ); +} diff --git a/node_modules/@jest/reporters/build/getSnapshotStatus.d.ts b/node_modules/@jest/reporters/build/getSnapshotStatus.d.ts new file mode 100644 index 0000000..573ea9a --- /dev/null +++ b/node_modules/@jest/reporters/build/getSnapshotStatus.d.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { TestResult } from '@jest/test-result'; +export default function getSnapshotStatus(snapshot: TestResult['snapshot'], afterUpdate: boolean): Array<string>; diff --git a/node_modules/@jest/reporters/build/getSnapshotStatus.js b/node_modules/@jest/reporters/build/getSnapshotStatus.js new file mode 100644 index 0000000..ddda3ab --- /dev/null +++ b/node_modules/@jest/reporters/build/getSnapshotStatus.js @@ -0,0 +1,111 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = getSnapshotStatus; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +const ARROW = ' \u203A '; +const DOT = ' \u2022 '; + +const FAIL_COLOR = _chalk().default.bold.red; + +const SNAPSHOT_ADDED = _chalk().default.bold.green; + +const SNAPSHOT_UPDATED = _chalk().default.bold.green; + +const SNAPSHOT_OUTDATED = _chalk().default.bold.yellow; + +function getSnapshotStatus(snapshot, afterUpdate) { + const statuses = []; + + if (snapshot.added) { + statuses.push( + SNAPSHOT_ADDED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshot.added) + + ' written.' + ) + ); + } + + if (snapshot.updated) { + statuses.push( + SNAPSHOT_UPDATED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshot.updated) + + ' updated.' + ) + ); + } + + if (snapshot.unmatched) { + statuses.push( + FAIL_COLOR( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshot.unmatched) + + ' failed.' + ) + ); + } + + if (snapshot.unchecked) { + if (afterUpdate) { + statuses.push( + SNAPSHOT_UPDATED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshot.unchecked) + + ' removed.' + ) + ); + } else { + statuses.push( + SNAPSHOT_OUTDATED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshot.unchecked) + + ' obsolete' + ) + '.' + ); + } + + snapshot.uncheckedKeys.forEach(key => { + statuses.push(` ${DOT}${key}`); + }); + } + + if (snapshot.fileDeleted) { + statuses.push(SNAPSHOT_UPDATED(ARROW + 'snapshot file removed.')); + } + + return statuses; +} diff --git a/node_modules/@jest/reporters/build/getSnapshotSummary.d.ts b/node_modules/@jest/reporters/build/getSnapshotSummary.d.ts new file mode 100644 index 0000000..8ccf669 --- /dev/null +++ b/node_modules/@jest/reporters/build/getSnapshotSummary.d.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { SnapshotSummary } from '@jest/test-result'; +import type { Config } from '@jest/types'; +export default function getSnapshotSummary(snapshots: SnapshotSummary, globalConfig: Config.GlobalConfig, updateCommand: string): Array<string>; diff --git a/node_modules/@jest/reporters/build/getSnapshotSummary.js b/node_modules/@jest/reporters/build/getSnapshotSummary.js new file mode 100644 index 0000000..1afce24 --- /dev/null +++ b/node_modules/@jest/reporters/build/getSnapshotSummary.js @@ -0,0 +1,203 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = getSnapshotSummary; + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _utils = require('./utils'); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +const ARROW = ' \u203A '; +const DOWN_ARROW = ' \u21B3 '; +const DOT = ' \u2022 '; + +const FAIL_COLOR = _chalk().default.bold.red; + +const OBSOLETE_COLOR = _chalk().default.bold.yellow; + +const SNAPSHOT_ADDED = _chalk().default.bold.green; + +const SNAPSHOT_NOTE = _chalk().default.dim; + +const SNAPSHOT_REMOVED = _chalk().default.bold.green; + +const SNAPSHOT_SUMMARY = _chalk().default.bold; + +const SNAPSHOT_UPDATED = _chalk().default.bold.green; + +function getSnapshotSummary(snapshots, globalConfig, updateCommand) { + const summary = []; + summary.push(SNAPSHOT_SUMMARY('Snapshot Summary')); + + if (snapshots.added) { + summary.push( + SNAPSHOT_ADDED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshots.added) + + ' written ' + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.filesAdded + )}.` + ); + } + + if (snapshots.unmatched) { + summary.push( + FAIL_COLOR( + `${ARROW}${(0, _jestUtil().pluralize)( + 'snapshot', + snapshots.unmatched + )} failed` + ) + + ` from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.filesUnmatched + )}. ` + + SNAPSHOT_NOTE( + 'Inspect your code changes or ' + updateCommand + ' to update them.' + ) + ); + } + + if (snapshots.updated) { + summary.push( + SNAPSHOT_UPDATED( + ARROW + + (0, _jestUtil().pluralize)('snapshot', snapshots.updated) + + ' updated ' + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.filesUpdated + )}.` + ); + } + + if (snapshots.filesRemoved) { + if (snapshots.didUpdate) { + summary.push( + SNAPSHOT_REMOVED( + `${ARROW}${(0, _jestUtil().pluralize)( + 'snapshot file', + snapshots.filesRemoved + )} removed ` + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.filesRemoved + )}.` + ); + } else { + summary.push( + OBSOLETE_COLOR( + `${ARROW}${(0, _jestUtil().pluralize)( + 'snapshot file', + snapshots.filesRemoved + )} obsolete ` + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.filesRemoved + )}. ` + + SNAPSHOT_NOTE( + `To remove ${ + snapshots.filesRemoved === 1 ? 'it' : 'them all' + }, ${updateCommand}.` + ) + ); + } + } + + if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) { + const [head, ...tail] = snapshots.filesRemovedList; + summary.push( + ` ${DOWN_ARROW} ${DOT}${(0, _utils.formatTestPath)(globalConfig, head)}` + ); + tail.forEach(key => { + summary.push( + ` ${DOT}${(0, _utils.formatTestPath)(globalConfig, key)}` + ); + }); + } + + if (snapshots.unchecked) { + if (snapshots.didUpdate) { + summary.push( + SNAPSHOT_REMOVED( + `${ARROW}${(0, _jestUtil().pluralize)( + 'snapshot', + snapshots.unchecked + )} removed ` + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.uncheckedKeysByFile.length + )}.` + ); + } else { + summary.push( + OBSOLETE_COLOR( + `${ARROW}${(0, _jestUtil().pluralize)( + 'snapshot', + snapshots.unchecked + )} obsolete ` + ) + + `from ${(0, _jestUtil().pluralize)( + 'test suite', + snapshots.uncheckedKeysByFile.length + )}. ` + + SNAPSHOT_NOTE( + `To remove ${ + snapshots.unchecked === 1 ? 'it' : 'them all' + }, ${updateCommand}.` + ) + ); + } + + snapshots.uncheckedKeysByFile.forEach(uncheckedFile => { + summary.push( + ` ${DOWN_ARROW}${(0, _utils.formatTestPath)( + globalConfig, + uncheckedFile.filePath + )}` + ); + uncheckedFile.keys.forEach(key => { + summary.push(` ${DOT}${key}`); + }); + }); + } + + return summary; +} diff --git a/node_modules/@jest/reporters/build/getWatermarks.d.ts b/node_modules/@jest/reporters/build/getWatermarks.d.ts new file mode 100644 index 0000000..a64751e --- /dev/null +++ b/node_modules/@jest/reporters/build/getWatermarks.d.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import istanbulReport = require('istanbul-lib-report'); +import type { Config } from '@jest/types'; +export default function getWatermarks(config: Config.GlobalConfig): istanbulReport.Watermarks; diff --git a/node_modules/@jest/reporters/build/getWatermarks.js b/node_modules/@jest/reporters/build/getWatermarks.js new file mode 100644 index 0000000..5e27e41 --- /dev/null +++ b/node_modules/@jest/reporters/build/getWatermarks.js @@ -0,0 +1,47 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = getWatermarks; + +function _istanbulLibReport() { + const data = _interopRequireDefault(require('istanbul-lib-report')); + + _istanbulLibReport = function () { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +function getWatermarks(config) { + const defaultWatermarks = _istanbulLibReport().default.getDefaultWatermarks(); + + const {coverageThreshold} = config; + + if (!coverageThreshold || !coverageThreshold.global) { + return defaultWatermarks; + } + + const keys = ['branches', 'functions', 'lines', 'statements']; + return keys.reduce((watermarks, key) => { + const value = coverageThreshold.global[key]; + + if (value !== undefined) { + watermarks[key][1] = value; + } + + return watermarks; + }, defaultWatermarks); +} diff --git a/node_modules/@jest/reporters/build/index.d.ts b/node_modules/@jest/reporters/build/index.d.ts new file mode 100644 index 0000000..96e583a --- /dev/null +++ b/node_modules/@jest/reporters/build/index.d.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import getResultHeader from './getResultHeader'; +export type { Config } from '@jest/types'; +export type { AggregatedResult, SnapshotSummary, TestResult, } from '@jest/test-result'; +export { default as BaseReporter } from './BaseReporter'; +export { default as CoverageReporter } from './CoverageReporter'; +export { default as DefaultReporter } from './DefaultReporter'; +export { default as NotifyReporter } from './NotifyReporter'; +export { default as SummaryReporter } from './SummaryReporter'; +export { default as VerboseReporter } from './VerboseReporter'; +export type { Context, Reporter, ReporterOnStartOptions, SummaryOptions, Test, } from './types'; +export declare const utils: { + formatTestPath: (config: import("@jest/types/build/Config").ProjectConfig | import("@jest/types/build/Config").GlobalConfig, testPath: string) => string; + getResultHeader: typeof getResultHeader; + getSummary: (aggregatedResults: import("@jest/test-result").AggregatedResult, options?: import("./types").SummaryOptions | undefined) => string; + printDisplayName: (config: import("@jest/types/build/Config").ProjectConfig) => string; + relativePath: (config: import("@jest/types/build/Config").ProjectConfig | import("@jest/types/build/Config").GlobalConfig, testPath: string) => { + basename: string; + dirname: string; + }; + trimAndFormatPath: (pad: number, config: import("@jest/types/build/Config").ProjectConfig | import("@jest/types/build/Config").GlobalConfig, testPath: string, columns: number) => string; +}; diff --git a/node_modules/@jest/reporters/build/index.js b/node_modules/@jest/reporters/build/index.js new file mode 100644 index 0000000..bafd8e9 --- /dev/null +++ b/node_modules/@jest/reporters/build/index.js @@ -0,0 +1,78 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +Object.defineProperty(exports, 'BaseReporter', { + enumerable: true, + get: function () { + return _BaseReporter.default; + } +}); +Object.defineProperty(exports, 'CoverageReporter', { + enumerable: true, + get: function () { + return _CoverageReporter.default; + } +}); +Object.defineProperty(exports, 'DefaultReporter', { + enumerable: true, + get: function () { + return _DefaultReporter.default; + } +}); +Object.defineProperty(exports, 'NotifyReporter', { + enumerable: true, + get: function () { + return _NotifyReporter.default; + } +}); +Object.defineProperty(exports, 'SummaryReporter', { + enumerable: true, + get: function () { + return _SummaryReporter.default; + } +}); +Object.defineProperty(exports, 'VerboseReporter', { + enumerable: true, + get: function () { + return _VerboseReporter.default; + } +}); +exports.utils = void 0; + +var _getResultHeader = _interopRequireDefault(require('./getResultHeader')); + +var _utils = require('./utils'); + +var _BaseReporter = _interopRequireDefault(require('./BaseReporter')); + +var _CoverageReporter = _interopRequireDefault(require('./CoverageReporter')); + +var _DefaultReporter = _interopRequireDefault(require('./DefaultReporter')); + +var _NotifyReporter = _interopRequireDefault(require('./NotifyReporter')); + +var _SummaryReporter = _interopRequireDefault(require('./SummaryReporter')); + +var _VerboseReporter = _interopRequireDefault(require('./VerboseReporter')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +const utils = { + formatTestPath: _utils.formatTestPath, + getResultHeader: _getResultHeader.default, + getSummary: _utils.getSummary, + printDisplayName: _utils.printDisplayName, + relativePath: _utils.relativePath, + trimAndFormatPath: _utils.trimAndFormatPath +}; +exports.utils = utils; diff --git a/node_modules/@jest/reporters/build/types.d.ts b/node_modules/@jest/reporters/build/types.d.ts new file mode 100644 index 0000000..0dcbe26 --- /dev/null +++ b/node_modules/@jest/reporters/build/types.d.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult, SerializableError, TestCaseResult, TestResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import type { FS as HasteFS, ModuleMap } from 'jest-haste-map'; +import type Resolver from 'jest-resolve'; +import type { worker } from './CoverageWorker'; +export declare type ReporterOnStartOptions = { + estimatedTime: number; + showStatus: boolean; +}; +export declare type Context = { + config: Config.ProjectConfig; + hasteFS: HasteFS; + moduleMap: ModuleMap; + resolver: Resolver; +}; +export declare type Test = { + context: Context; + duration?: number; + path: Config.Path; +}; +export declare type CoverageWorker = { + worker: typeof worker; +}; +export declare type CoverageReporterOptions = { + changedFiles?: Set<Config.Path>; + sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>; +}; +export declare type CoverageReporterSerializedOptions = { + changedFiles?: Array<Config.Path>; + sourcesRelatedToTestsInChangedFiles?: Array<Config.Path>; +}; +export declare type OnTestStart = (test: Test) => Promise<void>; +export declare type OnTestFailure = (test: Test, error: SerializableError) => Promise<unknown>; +export declare type OnTestSuccess = (test: Test, result: TestResult) => Promise<unknown>; +export interface Reporter { + readonly onTestResult?: (test: Test, testResult: TestResult, aggregatedResult: AggregatedResult) => Promise<void> | void; + readonly onTestFileResult?: (test: Test, testResult: TestResult, aggregatedResult: AggregatedResult) => Promise<void> | void; + readonly onTestCaseResult?: (test: Test, testCaseResult: TestCaseResult) => Promise<void> | void; + readonly onRunStart: (results: AggregatedResult, options: ReporterOnStartOptions) => Promise<void> | void; + readonly onTestStart?: (test: Test) => Promise<void> | void; + readonly onTestFileStart?: (test: Test) => Promise<void> | void; + readonly onRunComplete: (contexts: Set<Context>, results: AggregatedResult) => Promise<void> | void; + readonly getLastError: () => Error | void; +} +export declare type SummaryOptions = { + currentTestCases?: Array<{ + test: Test; + testCaseResult: TestCaseResult; + }>; + estimatedTime?: number; + roundTime?: boolean; + width?: number; +}; +export declare type TestRunnerOptions = { + serial: boolean; +}; +export declare type TestRunData = Array<{ + context: Context; + matches: { + allTests: number; + tests: Array<Test>; + total: number; + }; +}>; +export declare type TestSchedulerContext = { + firstRun: boolean; + previousSuccess: boolean; + changedFiles?: Set<Config.Path>; +}; diff --git a/node_modules/@jest/reporters/build/types.js b/node_modules/@jest/reporters/build/types.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/node_modules/@jest/reporters/build/types.js @@ -0,0 +1 @@ +'use strict'; diff --git a/node_modules/@jest/reporters/build/utils.d.ts b/node_modules/@jest/reporters/build/utils.d.ts new file mode 100644 index 0000000..ed676be --- /dev/null +++ b/node_modules/@jest/reporters/build/utils.d.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. 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. + */ +import type { AggregatedResult } from '@jest/test-result'; +import type { Config } from '@jest/types'; +import type { SummaryOptions } from './types'; +export declare const printDisplayName: (config: Config.ProjectConfig) => string; +export declare const trimAndFormatPath: (pad: number, config: Config.ProjectConfig | Config.GlobalConfig, testPath: Config.Path, columns: number) => string; +export declare const formatTestPath: (config: Config.GlobalConfig | Config.ProjectConfig, testPath: Config.Path) => string; +export declare const relativePath: (config: Config.GlobalConfig | Config.ProjectConfig, testPath: Config.Path) => { + basename: string; + dirname: string; +}; +export declare const getSummary: (aggregatedResults: AggregatedResult, options?: SummaryOptions | undefined) => string; +export declare const wrapAnsiString: (string: string, terminalWidth: number) => string; diff --git a/node_modules/@jest/reporters/build/utils.js b/node_modules/@jest/reporters/build/utils.js new file mode 100644 index 0000000..558ac92 --- /dev/null +++ b/node_modules/@jest/reporters/build/utils.js @@ -0,0 +1,435 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.wrapAnsiString = + exports.trimAndFormatPath = + exports.relativePath = + exports.printDisplayName = + exports.getSummary = + exports.formatTestPath = + void 0; + +function path() { + const data = _interopRequireWildcard(require('path')); + + path = function () { + return data; + }; + + return data; +} + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _slash() { + const data = _interopRequireDefault(require('slash')); + + _slash = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const PROGRESS_BAR_WIDTH = 40; + +const printDisplayName = config => { + const {displayName} = config; + + const white = _chalk().default.reset.inverse.white; + + if (!displayName) { + return ''; + } + + const {name, color} = displayName; + const chosenColor = _chalk().default.reset.inverse[color] + ? _chalk().default.reset.inverse[color] + : white; + return _chalk().default.supportsColor ? chosenColor(` ${name} `) : name; +}; + +exports.printDisplayName = printDisplayName; + +const trimAndFormatPath = (pad, config, testPath, columns) => { + const maxLength = columns - pad; + const relative = relativePath(config, testPath); + const {basename} = relative; + let {dirname} = relative; // length is ok + + if ((dirname + path().sep + basename).length <= maxLength) { + return (0, _slash().default)( + _chalk().default.dim(dirname + path().sep) + + _chalk().default.bold(basename) + ); + } // we can fit trimmed dirname and full basename + + const basenameLength = basename.length; + + if (basenameLength + 4 < maxLength) { + const dirnameLength = maxLength - 4 - basenameLength; + dirname = + '...' + dirname.slice(dirname.length - dirnameLength, dirname.length); + return (0, _slash().default)( + _chalk().default.dim(dirname + path().sep) + + _chalk().default.bold(basename) + ); + } + + if (basenameLength + 4 === maxLength) { + return (0, _slash().default)( + _chalk().default.dim('...' + path().sep) + _chalk().default.bold(basename) + ); + } // can't fit dirname, but can fit trimmed basename + + return (0, _slash().default)( + _chalk().default.bold( + '...' + basename.slice(basename.length - maxLength - 4, basename.length) + ) + ); +}; + +exports.trimAndFormatPath = trimAndFormatPath; + +const formatTestPath = (config, testPath) => { + const {dirname, basename} = relativePath(config, testPath); + return (0, _slash().default)( + _chalk().default.dim(dirname + path().sep) + _chalk().default.bold(basename) + ); +}; + +exports.formatTestPath = formatTestPath; + +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().relative(config.cwd || config.rootDir, testPath); + const dirname = path().dirname(testPath); + const basename = path().basename(testPath); + return { + basename, + dirname + }; +}; + +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; + + if (options && options.roundTime) { + 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; + const snapshotsFailed = snapshotResults.unmatched; + const snapshotsOutdated = snapshotResults.unchecked; + const snapshotsFilesRemoved = snapshotResults.filesRemoved; + const snapshotsDidUpdate = snapshotResults.didUpdate; + const snapshotsPassed = snapshotResults.matched; + const snapshotsTotal = snapshotResults.total; + const snapshotsUpdated = snapshotResults.updated; + const suitesFailed = aggregatedResults.numFailedTestSuites; + const suitesPassed = aggregatedResults.numPassedTestSuites; + const suitesPending = aggregatedResults.numPendingTestSuites; + const suitesRun = suitesFailed + suitesPassed; + const suitesTotal = aggregatedResults.numTotalTestSuites; + const testsFailed = aggregatedResults.numFailedTests; + const testsPassed = aggregatedResults.numPassedTests; + const testsPending = aggregatedResults.numPendingTests; + const testsTodo = aggregatedResults.numTodoTests; + const testsTotal = aggregatedResults.numTotalTests; + const width = (options && options.width) || 0; + const suites = + _chalk().default.bold('Test Suites: ') + + (suitesFailed + ? _chalk().default.bold.red(`${suitesFailed} failed`) + ', ' + : '') + + (suitesPending + ? _chalk().default.bold.yellow(`${suitesPending} skipped`) + ', ' + : '') + + (suitesPassed + ? _chalk().default.bold.green(`${suitesPassed} passed`) + ', ' + : '') + + (suitesRun !== suitesTotal + ? 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: ') + + (updatedTestsFailed > 0 + ? _chalk().default.bold.red(`${updatedTestsFailed} failed`) + ', ' + : '') + + (updatedTestsPending > 0 + ? _chalk().default.bold.yellow(`${updatedTestsPending} skipped`) + ', ' + : '') + + (updatedTestsTodo > 0 + ? _chalk().default.bold.magenta(`${updatedTestsTodo} todo`) + ', ' + : '') + + (updatedTestsPassed > 0 + ? _chalk().default.bold.green(`${updatedTestsPassed} passed`) + ', ' + : '') + + `${updatedTestsTotal} total`; + const snapshots = + _chalk().default.bold('Snapshots: ') + + (snapshotsFailed + ? _chalk().default.bold.red(`${snapshotsFailed} failed`) + ', ' + : '') + + (snapshotsOutdated && !snapshotsDidUpdate + ? _chalk().default.bold.yellow(`${snapshotsOutdated} obsolete`) + ', ' + : '') + + (snapshotsOutdated && snapshotsDidUpdate + ? _chalk().default.bold.green(`${snapshotsOutdated} removed`) + ', ' + : '') + + (snapshotsFilesRemoved && !snapshotsDidUpdate + ? _chalk().default.bold.yellow( + (0, _jestUtil().pluralize)('file', snapshotsFilesRemoved) + + ' obsolete' + ) + ', ' + : '') + + (snapshotsFilesRemoved && snapshotsDidUpdate + ? _chalk().default.bold.green( + (0, _jestUtil().pluralize)('file', snapshotsFilesRemoved) + ' removed' + ) + ', ' + : '') + + (snapshotsUpdated + ? _chalk().default.bold.green(`${snapshotsUpdated} updated`) + ', ' + : '') + + (snapshotsAdded + ? _chalk().default.bold.green(`${snapshotsAdded} written`) + ', ' + : '') + + (snapshotsPassed + ? _chalk().default.bold.green(`${snapshotsPassed} passed`) + ', ' + : '') + + `${snapshotsTotal} total`; + const time = renderTime(runTime, estimatedTime, width); + return [suites, tests, snapshots, time].join('\n'); +}; + +exports.getSummary = getSummary; + +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((0, _jestUtil().formatTime)(runTime, 0)) + : (0, _jestUtil().formatTime)(runTime, 0); + let time = _chalk().default.bold('Time:') + ` ${renderedTime}`; + + if (runTime < estimatedTime) { + time += `, estimated ${(0, _jestUtil().formatTime)(estimatedTime, 0)}`; + } // Only show a progress bar if the test run is actually going to take + // some time. + + if (estimatedTime > 2 && runTime < estimatedTime && width) { + const availableWidth = Math.min(PROGRESS_BAR_WIDTH, width); + const length = Math.min( + Math.floor((runTime / estimatedTime) * availableWidth), + availableWidth + ); + + if (availableWidth >= 2) { + time += + '\n' + + _chalk().default.green('█').repeat(length) + + _chalk() + .default.white('█') + .repeat(availableWidth - length); + } + } + + return time; +}; // word-wrap a string that contains ANSI escape sequences. +// ANSI escape sequences do not add to the string length. + +const wrapAnsiString = (string, terminalWidth) => { + if (terminalWidth === 0) { + // if the terminal width is zero, don't bother word-wrapping + return string; + } + + const ANSI_REGEXP = /[\u001b\u009b]\[\d{1,2}m/gu; + const tokens = []; + let lastIndex = 0; + let match; + + while ((match = ANSI_REGEXP.exec(string))) { + const ansi = match[0]; + const index = match['index']; + + if (index != lastIndex) { + tokens.push(['string', string.slice(lastIndex, index)]); + } + + tokens.push(['ansi', ansi]); + lastIndex = index + ansi.length; + } + + if (lastIndex != string.length - 1) { + tokens.push(['string', string.slice(lastIndex, string.length)]); + } + + let lastLineLength = 0; + return tokens + .reduce( + (lines, [kind, token]) => { + if (kind === 'string') { + if (lastLineLength + token.length > terminalWidth) { + while (token.length) { + const chunk = token.slice(0, terminalWidth - lastLineLength); + const remaining = token.slice( + terminalWidth - lastLineLength, + token.length + ); + lines[lines.length - 1] += chunk; + lastLineLength += chunk.length; + token = remaining; + + if (token.length) { + lines.push(''); + lastLineLength = 0; + } + } + } else { + lines[lines.length - 1] += token; + lastLineLength += token.length; + } + } else { + lines[lines.length - 1] += token; + } + + return lines; + }, + [''] + ) + .join('\n'); +}; + +exports.wrapAnsiString = wrapAnsiString; |