Updating NPM dependencies

This commit is contained in:
Drew Heavner
2020-11-11 13:30:52 +00:00
committed by GitHub
parent 7a6fb66c63
commit bd487ef324
9068 changed files with 1400893 additions and 587661 deletions

View File

@@ -8,47 +8,7 @@ exports.default = void 0;
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function _chalk() {
return data;
};
return data;
}
function _jestMessageUtil() {
const data = require('jest-message-util');
_jestMessageUtil = function _jestMessageUtil() {
return data;
};
return data;
}
function _jestSnapshot() {
const data = _interopRequireDefault(require('jest-snapshot'));
_jestSnapshot = function _jestSnapshot() {
return data;
};
return data;
}
function _jestRunner() {
const data = _interopRequireDefault(require('jest-runner'));
_jestRunner = function _jestRunner() {
return data;
};
return data;
}
function _reporters() {
const data = require('@jest/reporters');
_reporters = function _reporters() {
_chalk = function () {
return data;
};
@@ -58,7 +18,17 @@ function _reporters() {
function _exit() {
const data = _interopRequireDefault(require('exit'));
_exit = function _exit() {
_exit = function () {
return data;
};
return data;
}
function _reporters() {
const data = require('@jest/reporters');
_reporters = function () {
return data;
};
@@ -68,7 +38,47 @@ function _exit() {
function _testResult() {
const data = require('@jest/test-result');
_testResult = function _testResult() {
_testResult = function () {
return data;
};
return data;
}
function _jestMessageUtil() {
const data = require('jest-message-util');
_jestMessageUtil = function () {
return data;
};
return data;
}
function _jestRunner() {
const data = _interopRequireDefault(require('jest-runner'));
_jestRunner = function () {
return data;
};
return data;
}
function _jestSnapshot() {
const data = _interopRequireDefault(require('jest-snapshot'));
_jestSnapshot = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
@@ -85,79 +95,6 @@ function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _nonIterableRest() {
throw new TypeError('Invalid attempt to destructure non-iterable instance');
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (
var _i = arr[Symbol.iterator](), _s;
!(_n = (_s = _i.next()).done);
_n = true
) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i['return'] != null) _i['return']();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this,
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
}
_next(undefined);
});
};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
@@ -202,189 +139,228 @@ class TestScheduler {
this._dispatcher.unregister(ReporterClass);
}
scheduleTests(tests, watcher) {
var _this = this;
async scheduleTests(tests, watcher) {
const onTestFileStart = this._dispatcher.onTestFileStart.bind(
this._dispatcher
);
return _asyncToGenerator(function*() {
const onStart = _this._dispatcher.onTestStart.bind(_this._dispatcher);
const timings = [];
const contexts = new Set();
tests.forEach(test => {
contexts.add(test.context);
const timings = [];
const contexts = new Set();
tests.forEach(test => {
contexts.add(test.context);
if (test.duration) {
timings.push(test.duration);
}
});
const aggregatedResults = createAggregatedResults(tests.length);
const estimatedTime = Math.ceil(
getEstimatedTime(timings, this._globalConfig.maxWorkers) / 1000
);
const runInBand = (0, _testSchedulerHelper.shouldRunInBand)(
tests,
timings,
this._globalConfig
);
if (test.duration) {
timings.push(test.duration);
}
});
const aggregatedResults = createAggregatedResults(tests.length);
const estimatedTime = Math.ceil(
getEstimatedTime(timings, _this._globalConfig.maxWorkers) / 1000
);
const runInBand = (0, _testSchedulerHelper.shouldRunInBand)(
tests,
timings,
_this._globalConfig
);
const onResult =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*(test, testResult) {
if (watcher.isInterrupted()) {
return Promise.resolve();
}
if (testResult.testResults.length === 0) {
const message = 'Your test suite must contain at least one test.';
return onFailure(test, {
message,
stack: new Error(message).stack
});
} // Throws when the context is leaked after executing a test.
if (testResult.leaks) {
const message =
_chalk().default.red.bold('EXPERIMENTAL FEATURE!\n') +
'Your test suite is leaking memory. Please ensure all references are cleaned.\n' +
'\n' +
'There is a number of things that can leak memory:\n' +
' - Async operations that have not finished (e.g. fs.readFile).\n' +
' - Timers not properly mocked (e.g. setInterval, setTimeout).\n' +
' - Keeping references to the global scope.';
return onFailure(test, {
message,
stack: new Error(message).stack
});
}
(0, _testResult().addResult)(aggregatedResults, testResult);
yield _this._dispatcher.onTestResult(
test,
testResult,
aggregatedResults
);
return _this._bailIfNeeded(contexts, aggregatedResults, watcher);
});
return function onResult(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
const onFailure =
/*#__PURE__*/
(function() {
var _ref2 = _asyncToGenerator(function*(test, error) {
if (watcher.isInterrupted()) {
return;
}
const testResult = (0, _testResult().buildFailureTestResult)(
test.path,
error
);
testResult.failureMessage = (0, _jestMessageUtil().formatExecError)(
testResult.testExecError,
test.context.config,
_this._globalConfig,
test.path
);
(0, _testResult().addResult)(aggregatedResults, testResult);
yield _this._dispatcher.onTestResult(
test,
testResult,
aggregatedResults
);
});
return function onFailure(_x3, _x4) {
return _ref2.apply(this, arguments);
};
})();
const updateSnapshotState = () => {
contexts.forEach(context => {
const status = _jestSnapshot().default.cleanup(
context.hasteFS,
_this._globalConfig.updateSnapshot,
_jestSnapshot().default.buildSnapshotResolver(context.config),
context.config.testPathIgnorePatterns
);
aggregatedResults.snapshot.filesRemoved += status.filesRemoved;
aggregatedResults.snapshot.filesRemovedList = (
aggregatedResults.snapshot.filesRemovedList || []
).concat(status.filesRemovedList);
});
const updateAll = _this._globalConfig.updateSnapshot === 'all';
aggregatedResults.snapshot.didUpdate = updateAll;
aggregatedResults.snapshot.failure = !!(
!updateAll &&
(aggregatedResults.snapshot.unchecked ||
aggregatedResults.snapshot.unmatched ||
aggregatedResults.snapshot.filesRemoved)
);
};
yield _this._dispatcher.onRunStart(aggregatedResults, {
estimatedTime,
showStatus: !runInBand
});
const testRunners = Object.create(null);
contexts.forEach(({config}) => {
if (!testRunners[config.runner]) {
const Runner = require(config.runner);
testRunners[config.runner] = new Runner(_this._globalConfig, {
changedFiles: _this._context && _this._context.changedFiles
});
}
});
const testsByRunner = _this._partitionTests(testRunners, tests);
if (testsByRunner) {
try {
var _arr = Object.keys(testRunners);
for (var _i = 0; _i < _arr.length; _i++) {
const runner = _arr[_i];
yield testRunners[runner].runTests(
testsByRunner[runner],
watcher,
onStart,
onResult,
onFailure,
{
serial: runInBand || Boolean(testRunners[runner].isSerial)
}
);
}
} catch (error) {
if (!watcher.isInterrupted()) {
throw error;
}
}
const onResult = async (test, testResult) => {
if (watcher.isInterrupted()) {
return Promise.resolve();
}
updateSnapshotState();
aggregatedResults.wasInterrupted = watcher.isInterrupted();
yield _this._dispatcher.onRunComplete(contexts, aggregatedResults);
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
if (testResult.testResults.length === 0) {
const message = 'Your test suite must contain at least one test.';
return onFailure(test, {
message,
stack: new Error(message).stack
});
} // Throws when the context is leaked after executing a test.
const anyReporterErrors = _this._dispatcher.hasErrors();
if (testResult.leaks) {
const message =
_chalk().default.red.bold('EXPERIMENTAL FEATURE!\n') +
'Your test suite is leaking memory. Please ensure all references are cleaned.\n' +
'\n' +
'There is a number of things that can leak memory:\n' +
' - Async operations that have not finished (e.g. fs.readFile).\n' +
' - Timers not properly mocked (e.g. setInterval, setTimeout).\n' +
' - Keeping references to the global scope.';
return onFailure(test, {
message,
stack: new Error(message).stack
});
}
aggregatedResults.success = !(
anyTestFailures ||
aggregatedResults.snapshot.failure ||
anyReporterErrors
(0, _testResult().addResult)(aggregatedResults, testResult);
await this._dispatcher.onTestFileResult(
test,
testResult,
aggregatedResults
);
return aggregatedResults;
})();
return this._bailIfNeeded(contexts, aggregatedResults, watcher);
};
const onFailure = async (test, error) => {
if (watcher.isInterrupted()) {
return;
}
const testResult = (0, _testResult().buildFailureTestResult)(
test.path,
error
);
testResult.failureMessage = (0, _jestMessageUtil().formatExecError)(
testResult.testExecError,
test.context.config,
this._globalConfig,
test.path
);
(0, _testResult().addResult)(aggregatedResults, testResult);
await this._dispatcher.onTestFileResult(
test,
testResult,
aggregatedResults
);
};
const updateSnapshotState = () => {
contexts.forEach(context => {
const status = _jestSnapshot().default.cleanup(
context.hasteFS,
this._globalConfig.updateSnapshot,
_jestSnapshot().default.buildSnapshotResolver(context.config),
context.config.testPathIgnorePatterns
);
aggregatedResults.snapshot.filesRemoved += status.filesRemoved;
aggregatedResults.snapshot.filesRemovedList = (
aggregatedResults.snapshot.filesRemovedList || []
).concat(status.filesRemovedList);
});
const updateAll = this._globalConfig.updateSnapshot === 'all';
aggregatedResults.snapshot.didUpdate = updateAll;
aggregatedResults.snapshot.failure = !!(
!updateAll &&
(aggregatedResults.snapshot.unchecked ||
aggregatedResults.snapshot.unmatched ||
aggregatedResults.snapshot.filesRemoved)
);
};
await this._dispatcher.onRunStart(aggregatedResults, {
estimatedTime,
showStatus: !runInBand
});
const testRunners = Object.create(null);
const contextsByTestRunner = new WeakMap();
contexts.forEach(context => {
const {config} = context;
if (!testRunners[config.runner]) {
var _this$_context, _this$_context2;
const Runner = require(config.runner);
const runner = new Runner(this._globalConfig, {
changedFiles:
(_this$_context = this._context) === null ||
_this$_context === void 0
? void 0
: _this$_context.changedFiles,
sourcesRelatedToTestsInChangedFiles:
(_this$_context2 = this._context) === null ||
_this$_context2 === void 0
? void 0
: _this$_context2.sourcesRelatedToTestsInChangedFiles
});
testRunners[config.runner] = runner;
contextsByTestRunner.set(runner, context);
}
});
const testsByRunner = this._partitionTests(testRunners, tests);
if (testsByRunner) {
try {
for (const runner of Object.keys(testRunners)) {
const testRunner = testRunners[runner];
const context = contextsByTestRunner.get(testRunner);
invariant(context);
const tests = testsByRunner[runner];
const testRunnerOptions = {
serial: runInBand || Boolean(testRunner.isSerial)
};
/**
* Test runners with event emitters are still not supported
* for third party test runners.
*/
if (testRunner.__PRIVATE_UNSTABLE_API_supportsEventEmitters__) {
const unsubscribes = [
testRunner.on('test-file-start', ([test]) =>
onTestFileStart(test)
),
testRunner.on('test-file-success', ([test, testResult]) =>
onResult(test, testResult)
),
testRunner.on('test-file-failure', ([test, error]) =>
onFailure(test, error)
),
testRunner.on(
'test-case-result',
([testPath, testCaseResult]) => {
const test = {
context,
path: testPath
};
this._dispatcher.onTestCaseResult(test, testCaseResult);
}
)
];
await testRunner.runTests(
tests,
watcher,
undefined,
undefined,
undefined,
testRunnerOptions
);
unsubscribes.forEach(sub => sub());
} else {
await testRunner.runTests(
tests,
watcher,
onTestFileStart,
onResult,
onFailure,
testRunnerOptions
);
}
}
} catch (error) {
if (!watcher.isInterrupted()) {
throw error;
}
}
}
updateSnapshotState();
aggregatedResults.wasInterrupted = watcher.isInterrupted();
await this._dispatcher.onRunComplete(contexts, aggregatedResults);
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
const anyReporterErrors = this._dispatcher.hasErrors();
aggregatedResults.success = !(
anyTestFailures ||
aggregatedResults.snapshot.failure ||
anyReporterErrors
);
return aggregatedResults;
}
_partitionTests(testRunners, tests) {
@@ -419,10 +395,7 @@ class TestScheduler {
}
_setupReporters() {
const _this$_globalConfig = this._globalConfig,
collectCoverage = _this$_globalConfig.collectCoverage,
notify = _this$_globalConfig.notify,
reporters = _this$_globalConfig.reporters;
const {collectCoverage, notify, reporters} = this._globalConfig;
const isDefault = this._shouldAddDefaultReporters(reporters);
@@ -431,16 +404,27 @@ class TestScheduler {
}
if (!isDefault && collectCoverage) {
var _this$_context3, _this$_context4;
this.addReporter(
new (_reporters()).CoverageReporter(this._globalConfig, {
changedFiles: this._context && this._context.changedFiles
new (_reporters().CoverageReporter)(this._globalConfig, {
changedFiles:
(_this$_context3 = this._context) === null ||
_this$_context3 === void 0
? void 0
: _this$_context3.changedFiles,
sourcesRelatedToTestsInChangedFiles:
(_this$_context4 = this._context) === null ||
_this$_context4 === void 0
? void 0
: _this$_context4.sourcesRelatedToTestsInChangedFiles
})
);
}
if (notify) {
this.addReporter(
new (_reporters()).NotifyReporter(
new (_reporters().NotifyReporter)(
this._globalConfig,
this._options.startRun,
this._context
@@ -456,40 +440,50 @@ class TestScheduler {
_setupDefaultReporters(collectCoverage) {
this.addReporter(
this._globalConfig.verbose
? new (_reporters()).VerboseReporter(this._globalConfig)
: new (_reporters()).DefaultReporter(this._globalConfig)
? new (_reporters().VerboseReporter)(this._globalConfig)
: new (_reporters().DefaultReporter)(this._globalConfig)
);
if (collectCoverage) {
var _this$_context5, _this$_context6;
this.addReporter(
new (_reporters()).CoverageReporter(this._globalConfig, {
changedFiles: this._context && this._context.changedFiles
new (_reporters().CoverageReporter)(this._globalConfig, {
changedFiles:
(_this$_context5 = this._context) === null ||
_this$_context5 === void 0
? void 0
: _this$_context5.changedFiles,
sourcesRelatedToTestsInChangedFiles:
(_this$_context6 = this._context) === null ||
_this$_context6 === void 0
? void 0
: _this$_context6.sourcesRelatedToTestsInChangedFiles
})
);
}
this.addReporter(new (_reporters()).SummaryReporter(this._globalConfig));
this.addReporter(new (_reporters().SummaryReporter)(this._globalConfig));
}
_addCustomReporters(reporters) {
reporters.forEach(reporter => {
const _this$_getReporterPro = this._getReporterProps(reporter),
options = _this$_getReporterPro.options,
path = _this$_getReporterPro.path;
const {options, path} = this._getReporterProps(reporter);
if (path === 'default') return;
try {
const Reporter = require(path);
// TODO: Use `requireAndTranspileModule` for Jest 26
const Reporter = (0, _jestUtil().interopRequireDefault)(require(path))
.default;
this.addReporter(new Reporter(this._globalConfig, options));
} catch (error) {
throw new Error(
error.message =
'An error occurred while adding the reporter at path "' +
path +
'".' +
error.message
);
_chalk().default.bold(path) +
'".' +
error.message;
throw error;
}
});
}
@@ -505,10 +499,7 @@ class TestScheduler {
path: reporter
};
} else if (Array.isArray(reporter)) {
const _reporter = _slicedToArray(reporter, 2),
path = _reporter[0],
options = _reporter[1];
const [path, options] = reporter;
return {
options,
path
@@ -543,6 +534,12 @@ class TestScheduler {
exports.default = TestScheduler;
function invariant(condition, message) {
if (!condition) {
throw new Error(message);
}
}
const createAggregatedResults = numTotalTestSuites => {
const result = (0, _testResult().makeEmptyAggregatedTestResult)();
result.numTotalTestSuites = numTotalTestSuites;