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

@@ -5,16 +5,17 @@ Object.defineProperty(exports, '__esModule', {
});
exports.default = void 0;
var _globalErrorHandlers = require('./globalErrorHandlers');
var _types = require('./types');
var _utils = require('./utils');
var _globalErrorHandlers = require('./globalErrorHandlers');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var jestNow = global[Symbol.for('jest-native-now')] || global.Date.now;
// TODO: investigate why a shorter (event, state) signature results into TS7006 compiler error
const eventHandler = (event, state) => {
switch (event.name) {
case 'include_test_location_in_result': {
@@ -27,9 +28,18 @@ const eventHandler = (event, state) => {
}
case 'start_describe_definition': {
const blockName = event.blockName,
mode = event.mode;
const currentDescribeBlock = state.currentDescribeBlock;
const {blockName, mode} = event;
const {currentDescribeBlock, currentlyRunningTest} = state;
if (currentlyRunningTest) {
currentlyRunningTest.errors.push(
new Error(
`Cannot nest a describe inside a test. Describe block "${blockName}" cannot run because it is nested within "${currentlyRunningTest.name}".`
)
);
break;
}
const describeBlock = (0, _utils.makeDescribe)(
blockName,
currentDescribeBlock,
@@ -41,7 +51,7 @@ const eventHandler = (event, state) => {
}
case 'finish_describe_definition': {
const currentDescribeBlock = state.currentDescribeBlock;
const {currentDescribeBlock} = state;
(0, _utils.invariant)(
currentDescribeBlock,
`currentDescribeBlock must be there`
@@ -52,25 +62,29 @@ const eventHandler = (event, state) => {
hook.asyncError.message = `Invalid: ${hook.type}() may not be used in a describe block containing no tests.`;
state.unhandledErrors.push(hook.asyncError);
});
} // inherit mode from its parent describe but
// do not inherit "only" mode when there is already tests with "only" mode
} // pass mode of currentDescribeBlock to tests
// but do not when there is already a single test with "only" mode
const shouldInheritMode = !(
const shouldPassMode = !(
currentDescribeBlock.mode === 'only' &&
currentDescribeBlock.tests.find(test => test.mode === 'only')
currentDescribeBlock.children.some(
child => child.type === 'test' && child.mode === 'only'
)
);
if (shouldInheritMode) {
currentDescribeBlock.tests.forEach(test => {
if (!test.mode) {
test.mode = currentDescribeBlock.mode;
if (shouldPassMode) {
currentDescribeBlock.children.forEach(child => {
if (child.type === 'test' && !child.mode) {
child.mode = currentDescribeBlock.mode;
}
});
}
if (
!state.hasFocusedTests &&
currentDescribeBlock.tests.some(test => test.mode === 'only')
currentDescribeBlock.children.some(
child => child.type === 'test' && child.mode === 'only'
)
) {
state.hasFocusedTests = true;
}
@@ -83,11 +97,25 @@ const eventHandler = (event, state) => {
}
case 'add_hook': {
const currentDescribeBlock = state.currentDescribeBlock;
const asyncError = event.asyncError,
fn = event.fn,
type = event.hookType,
timeout = event.timeout;
const {currentDescribeBlock, currentlyRunningTest, hasStarted} = state;
const {asyncError, fn, hookType: type, timeout} = event;
if (currentlyRunningTest) {
currentlyRunningTest.errors.push(
new Error(
`Hooks cannot be defined inside tests. Hook of type "${type}" is nested within "${currentlyRunningTest.name}".`
)
);
break;
} else if (hasStarted) {
state.unhandledErrors.push(
new Error(
'Cannot add a hook after tests have started running. Hooks must be defined synchronously.'
)
);
break;
}
const parent = currentDescribeBlock;
currentDescribeBlock.hooks.push({
asyncError,
@@ -100,12 +128,25 @@ const eventHandler = (event, state) => {
}
case 'add_test': {
const currentDescribeBlock = state.currentDescribeBlock;
const asyncError = event.asyncError,
fn = event.fn,
mode = event.mode,
name = event.testName,
timeout = event.timeout;
const {currentDescribeBlock, currentlyRunningTest, hasStarted} = state;
const {asyncError, fn, mode, testName: name, timeout} = event;
if (currentlyRunningTest) {
currentlyRunningTest.errors.push(
new Error(
`Tests cannot be nested. Test "${name}" cannot run because it is nested within "${currentlyRunningTest.name}".`
)
);
break;
} else if (hasStarted) {
state.unhandledErrors.push(
new Error(
'Cannot add a test after tests have started running. Tests must be defined synchronously.'
)
);
break;
}
const test = (0, _utils.makeTest)(
fn,
mode,
@@ -119,17 +160,14 @@ const eventHandler = (event, state) => {
state.hasFocusedTests = true;
}
currentDescribeBlock.children.push(test);
currentDescribeBlock.tests.push(test);
break;
}
case 'hook_failure': {
const test = event.test,
describeBlock = event.describeBlock,
error = event.error,
hook = event.hook;
const asyncError = hook.asyncError,
type = hook.type;
const {test, describeBlock, error, hook} = event;
const {asyncError, type} = hook;
if (type === 'beforeAll') {
(0, _utils.invariant)(describeBlock, 'always present for `*All` hooks');
@@ -175,8 +213,10 @@ const eventHandler = (event, state) => {
}
case 'test_fn_failure': {
const error = event.error,
asyncError = event.test.asyncError;
const {
error,
test: {asyncError}
} = event;
event.test.errors.push([error, asyncError]);
break;
}
@@ -187,6 +227,7 @@ const eventHandler = (event, state) => {
}
case 'run_start': {
state.hasStarted = true;
global[_types.TEST_TIMEOUT_SYMBOL] &&
(state.testTimeout = global[_types.TEST_TIMEOUT_SYMBOL]);
break;