Updating NPM dependencies
This commit is contained in:
365
node_modules/@jest/core/build/watch.js
generated
vendored
365
node_modules/@jest/core/build/watch.js
generated
vendored
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.default = watch;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ function _path() {
|
||||
function _ansiEscapes() {
|
||||
const data = _interopRequireDefault(require('ansi-escapes'));
|
||||
|
||||
_ansiEscapes = function _ansiEscapes() {
|
||||
_ansiEscapes = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ function _ansiEscapes() {
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function _chalk() {
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ function _chalk() {
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
|
||||
_exit = function _exit() {
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,17 @@ function _exit() {
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
|
||||
_slash = function _slash() {
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestHasteMap() {
|
||||
const data = _interopRequireDefault(require('jest-haste-map'));
|
||||
|
||||
_jestHasteMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -58,27 +68,7 @@ function _slash() {
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
|
||||
_jestMessageUtil = function _jestMessageUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestValidate() {
|
||||
const data = require('jest-validate');
|
||||
|
||||
_jestValidate = function _jestValidate() {
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -88,7 +78,27 @@ function _jestValidate() {
|
||||
function _jestResolve() {
|
||||
const data = _interopRequireDefault(require('jest-resolve'));
|
||||
|
||||
_jestResolve = function _jestResolve() {
|
||||
_jestResolve = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestValidate() {
|
||||
const data = require('jest-validate');
|
||||
|
||||
_jestValidate = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -98,94 +108,136 @@ function _jestResolve() {
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
|
||||
_jestWatcher = function _jestWatcher() {
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _getChangedFilesPromise = _interopRequireDefault(
|
||||
require('./getChangedFilesPromise')
|
||||
);
|
||||
|
||||
var _is_valid_path = _interopRequireDefault(require('./lib/is_valid_path'));
|
||||
|
||||
var _create_context = _interopRequireDefault(require('./lib/create_context'));
|
||||
|
||||
var _runJest = _interopRequireDefault(require('./runJest'));
|
||||
|
||||
var _update_global_config = _interopRequireDefault(
|
||||
require('./lib/update_global_config')
|
||||
);
|
||||
var _FailedTestsCache = _interopRequireDefault(require('./FailedTestsCache'));
|
||||
|
||||
var _SearchSource = _interopRequireDefault(require('./SearchSource'));
|
||||
|
||||
var _TestWatcher = _interopRequireDefault(require('./TestWatcher'));
|
||||
|
||||
var _FailedTestsCache = _interopRequireDefault(require('./FailedTestsCache'));
|
||||
|
||||
var _test_path_pattern = _interopRequireDefault(
|
||||
require('./plugins/test_path_pattern')
|
||||
var _getChangedFilesPromise = _interopRequireDefault(
|
||||
require('./getChangedFilesPromise')
|
||||
);
|
||||
|
||||
var _test_name_pattern = _interopRequireDefault(
|
||||
require('./plugins/test_name_pattern')
|
||||
var _activeFiltersMessage = _interopRequireDefault(
|
||||
require('./lib/activeFiltersMessage')
|
||||
);
|
||||
|
||||
var _update_snapshots = _interopRequireDefault(
|
||||
require('./plugins/update_snapshots')
|
||||
var _createContext = _interopRequireDefault(require('./lib/createContext'));
|
||||
|
||||
var _isValidPath = _interopRequireDefault(require('./lib/isValidPath'));
|
||||
|
||||
var _updateGlobalConfig = _interopRequireDefault(
|
||||
require('./lib/updateGlobalConfig')
|
||||
);
|
||||
|
||||
var _update_snapshots_interactive = _interopRequireDefault(
|
||||
require('./plugins/update_snapshots_interactive')
|
||||
var _watchPluginsHelpers = require('./lib/watchPluginsHelpers');
|
||||
|
||||
var _Quit = _interopRequireDefault(require('./plugins/Quit'));
|
||||
|
||||
var _TestNamePattern = _interopRequireDefault(
|
||||
require('./plugins/TestNamePattern')
|
||||
);
|
||||
|
||||
var _quit = _interopRequireDefault(require('./plugins/quit'));
|
||||
|
||||
var _watch_plugins_helpers = require('./lib/watch_plugins_helpers');
|
||||
|
||||
var _active_filters_message = _interopRequireDefault(
|
||||
require('./lib/active_filters_message')
|
||||
var _TestPathPattern = _interopRequireDefault(
|
||||
require('./plugins/TestPathPattern')
|
||||
);
|
||||
|
||||
var _UpdateSnapshots = _interopRequireDefault(
|
||||
require('./plugins/UpdateSnapshots')
|
||||
);
|
||||
|
||||
var _UpdateSnapshotsInteractive = _interopRequireDefault(
|
||||
require('./plugins/UpdateSnapshotsInteractive')
|
||||
);
|
||||
|
||||
var _runJest = _interopRequireDefault(require('./runJest'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const preRunMessagePrint = _jestUtil().preRunMessage.print;
|
||||
const {print: preRunMessagePrint} = _jestUtil().preRunMessage;
|
||||
|
||||
let hasExitListener = false;
|
||||
const INTERNAL_PLUGINS = [
|
||||
_test_path_pattern.default,
|
||||
_test_name_pattern.default,
|
||||
_update_snapshots.default,
|
||||
_update_snapshots_interactive.default,
|
||||
_quit.default
|
||||
_TestPathPattern.default,
|
||||
_TestNamePattern.default,
|
||||
_UpdateSnapshots.default,
|
||||
_UpdateSnapshotsInteractive.default,
|
||||
_Quit.default
|
||||
];
|
||||
const RESERVED_KEY_PLUGINS = new Map([
|
||||
[
|
||||
_update_snapshots.default,
|
||||
_UpdateSnapshots.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'updating snapshots',
|
||||
key: 'u'
|
||||
}
|
||||
],
|
||||
[
|
||||
_update_snapshots_interactive.default,
|
||||
_UpdateSnapshotsInteractive.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'updating snapshots interactively',
|
||||
key: 'i'
|
||||
}
|
||||
],
|
||||
[
|
||||
_quit.default,
|
||||
_Quit.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'quitting watch mode'
|
||||
}
|
||||
@@ -198,14 +250,14 @@ function watch(
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
stdin = process.stdin,
|
||||
hooks = new (_jestWatcher()).JestHook(),
|
||||
hooks = new (_jestWatcher().JestHook)(),
|
||||
filter
|
||||
) {
|
||||
// `globalConfig` will be constantly updated and reassigned as a result of
|
||||
// watch mode interactions.
|
||||
let globalConfig = initialGlobalConfig;
|
||||
let activePlugin;
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: globalConfig.watch ? 'watch' : 'watchAll',
|
||||
passWithNoTests: true
|
||||
});
|
||||
@@ -218,7 +270,9 @@ function watch(
|
||||
collectCoverageOnlyFrom,
|
||||
coverageDirectory,
|
||||
coverageReporters,
|
||||
findRelatedTests,
|
||||
mode,
|
||||
nonFlagArgs,
|
||||
notify,
|
||||
notifyMode,
|
||||
onlyFailures,
|
||||
@@ -229,7 +283,7 @@ function watch(
|
||||
verbose
|
||||
} = {}) => {
|
||||
const previousUpdateSnapshot = globalConfig.updateSnapshot;
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
bail,
|
||||
changedSince,
|
||||
collectCoverage,
|
||||
@@ -237,7 +291,9 @@ function watch(
|
||||
collectCoverageOnlyFrom,
|
||||
coverageDirectory,
|
||||
coverageReporters,
|
||||
findRelatedTests,
|
||||
mode,
|
||||
nonFlagArgs,
|
||||
notify,
|
||||
notifyMode,
|
||||
onlyFailures,
|
||||
@@ -248,7 +304,7 @@ function watch(
|
||||
verbose
|
||||
});
|
||||
startRun(globalConfig);
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
// updateSnapshot is not sticky after a run.
|
||||
updateSnapshot:
|
||||
previousUpdateSnapshot === 'all' ? 'none' : previousUpdateSnapshot
|
||||
@@ -272,108 +328,60 @@ function watch(
|
||||
|
||||
if (globalConfig.watchPlugins != null) {
|
||||
const watchPluginKeys = new Map();
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = watchPlugins[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const plugin = _step.value;
|
||||
const reservedInfo = RESERVED_KEY_PLUGINS.get(plugin.constructor) || {};
|
||||
const key = reservedInfo.key || getPluginKey(plugin, globalConfig);
|
||||
for (const plugin of watchPlugins) {
|
||||
const reservedInfo = RESERVED_KEY_PLUGINS.get(plugin.constructor) || {};
|
||||
const key = reservedInfo.key || getPluginKey(plugin, globalConfig);
|
||||
|
||||
if (!key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const forbiddenOverwriteMessage =
|
||||
reservedInfo.forbiddenOverwriteMessage;
|
||||
watchPluginKeys.set(key, {
|
||||
forbiddenOverwriteMessage,
|
||||
overwritable: forbiddenOverwriteMessage == null,
|
||||
plugin
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
if (!key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const {forbiddenOverwriteMessage} = reservedInfo;
|
||||
watchPluginKeys.set(key, {
|
||||
forbiddenOverwriteMessage,
|
||||
overwritable: forbiddenOverwriteMessage == null,
|
||||
plugin
|
||||
});
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
for (const pluginWithConfig of globalConfig.watchPlugins) {
|
||||
let plugin;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = globalConfig.watchPlugins[Symbol.iterator](), _step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
) {
|
||||
const pluginWithConfig = _step2.value;
|
||||
let plugin;
|
||||
|
||||
try {
|
||||
const ThirdPartyPlugin = require(pluginWithConfig.path);
|
||||
|
||||
plugin = new ThirdPartyPlugin({
|
||||
config: pluginWithConfig.config,
|
||||
stdin,
|
||||
stdout: outputStream
|
||||
});
|
||||
} catch (error) {
|
||||
const errorWithContext = new Error(
|
||||
`Failed to initialize watch plugin "${_chalk().default.bold(
|
||||
(0, _slash().default)(
|
||||
_path().default.relative(process.cwd(), pluginWithConfig.path)
|
||||
)
|
||||
)}":\n\n${(0, _jestMessageUtil().formatExecError)(
|
||||
error,
|
||||
contexts[0].config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
);
|
||||
delete errorWithContext.stack;
|
||||
return Promise.reject(errorWithContext);
|
||||
}
|
||||
|
||||
checkForConflicts(watchPluginKeys, plugin, globalConfig);
|
||||
const hookSubscriber = hooks.getSubscriber();
|
||||
|
||||
if (plugin.apply) {
|
||||
plugin.apply(hookSubscriber);
|
||||
}
|
||||
|
||||
watchPlugins.push(plugin);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
const ThirdPartyPlugin = require(pluginWithConfig.path);
|
||||
|
||||
plugin = new ThirdPartyPlugin({
|
||||
config: pluginWithConfig.config,
|
||||
stdin,
|
||||
stdout: outputStream
|
||||
});
|
||||
} catch (error) {
|
||||
const errorWithContext = new Error(
|
||||
`Failed to initialize watch plugin "${_chalk().default.bold(
|
||||
(0, _slash().default)(
|
||||
path().relative(process.cwd(), pluginWithConfig.path)
|
||||
)
|
||||
)}":\n\n${(0, _jestMessageUtil().formatExecError)(
|
||||
error,
|
||||
contexts[0].config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
);
|
||||
delete errorWithContext.stack;
|
||||
return Promise.reject(errorWithContext);
|
||||
}
|
||||
|
||||
checkForConflicts(watchPluginKeys, plugin, globalConfig);
|
||||
const hookSubscriber = hooks.getSubscriber();
|
||||
|
||||
if (plugin.apply) {
|
||||
plugin.apply(hookSubscriber);
|
||||
}
|
||||
|
||||
watchPlugins.push(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,11 +411,11 @@ function watch(
|
||||
hasteMapInstances.forEach((hasteMapInstance, index) => {
|
||||
hasteMapInstance.on('change', ({eventsQueue, hasteFS, moduleMap}) => {
|
||||
const validPaths = eventsQueue.filter(({filePath}) =>
|
||||
(0, _is_valid_path.default)(globalConfig, filePath)
|
||||
(0, _isValidPath.default)(globalConfig, filePath)
|
||||
);
|
||||
|
||||
if (validPaths.length) {
|
||||
const context = (contexts[index] = (0, _create_context.default)(
|
||||
const context = (contexts[index] = (0, _createContext.default)(
|
||||
contexts[index].config,
|
||||
{
|
||||
hasteFS,
|
||||
@@ -530,7 +538,7 @@ function watch(
|
||||
return;
|
||||
} // Abort test run
|
||||
|
||||
const pluginKeys = (0, _watch_plugins_helpers.getSortedUsageRows)(
|
||||
const pluginKeys = (0, _watchPluginsHelpers.getSortedUsageRows)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).map(usage => Number(usage.key).toString(16));
|
||||
@@ -549,7 +557,7 @@ function watch(
|
||||
}
|
||||
|
||||
const matchingWatchPlugin = (0,
|
||||
_watch_plugins_helpers.filterInteractivePlugins)(
|
||||
_watchPluginsHelpers.filterInteractivePlugins)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).find(plugin => getPluginKey(plugin, globalConfig) === key);
|
||||
@@ -590,7 +598,7 @@ function watch(
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: 'watchAll',
|
||||
testNamePattern: '',
|
||||
testPathPattern: ''
|
||||
@@ -607,14 +615,14 @@ function watch(
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
onlyFailures: !globalConfig.onlyFailures
|
||||
});
|
||||
startRun(globalConfig);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
globalConfig = (0, _update_global_config.default)(globalConfig, {
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: 'watch',
|
||||
testNamePattern: '',
|
||||
testPathPattern: ''
|
||||
@@ -695,7 +703,7 @@ const checkForConflicts = (watchPluginKeys, plugin, globalConfig) => {
|
||||
Please change the key configuration for one of the conflicting plugins to avoid overlap.`.trim();
|
||||
}
|
||||
|
||||
throw new (_jestValidate()).ValidationError(
|
||||
throw new (_jestValidate().ValidationError)(
|
||||
'Watch plugin configuration error',
|
||||
error
|
||||
);
|
||||
@@ -703,11 +711,12 @@ const checkForConflicts = (watchPluginKeys, plugin, globalConfig) => {
|
||||
|
||||
const getPluginIdentifier = (
|
||||
plugin // This breaks as `displayName` is not defined as a static, but since
|
||||
) =>
|
||||
// WatchPlugin is an interface, and it is my understanding interface
|
||||
// static fields are not definable anymore, no idea how to circumvent
|
||||
// this :-(
|
||||
// @ts-ignore: leave `displayName` be.
|
||||
) => plugin.constructor.displayName || plugin.constructor.name;
|
||||
// @ts-expect-error: leave `displayName` be.
|
||||
plugin.constructor.displayName || plugin.constructor.name;
|
||||
|
||||
const getPluginKey = (plugin, globalConfig) => {
|
||||
if (typeof plugin.getUsageInfo === 'function') {
|
||||
@@ -723,7 +732,7 @@ const getPluginKey = (plugin, globalConfig) => {
|
||||
|
||||
const usage = (globalConfig, watchPlugins, delimiter = '\n') => {
|
||||
const messages = [
|
||||
(0, _active_filters_message.default)(globalConfig),
|
||||
(0, _activeFiltersMessage.default)(globalConfig),
|
||||
globalConfig.testPathPattern || globalConfig.testNamePattern
|
||||
? _chalk().default.dim(' \u203A Press ') +
|
||||
'c' +
|
||||
@@ -750,7 +759,7 @@ const usage = (globalConfig, watchPlugins, delimiter = '\n') => {
|
||||
'o' +
|
||||
_chalk().default.dim(' to only run tests related to changed files.')
|
||||
: null,
|
||||
...(0, _watch_plugins_helpers.getSortedUsageRows)(
|
||||
...(0, _watchPluginsHelpers.getSortedUsageRows)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).map(
|
||||
|
||||
Reference in New Issue
Block a user