This commit is contained in:
eric sciple 2020-01-24 12:20:19 -05:00
parent beb1329f9f
commit 2b95e76931
7736 changed files with 1874747 additions and 51184 deletions

10
node_modules/jest-circus/build/eventHandler.d.ts generated vendored Normal file
View file

@ -0,0 +1,10 @@
/**
* 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 { Circus } from '@jest/types';
declare const eventHandler: Circus.EventHandler;
export default eventHandler;
//# sourceMappingURL=eventHandler.d.ts.map

1
node_modules/jest-circus/build/eventHandler.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"eventHandler.d.ts","sourceRoot":"","sources":["../src/eventHandler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAgBnC,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,YAkL1B,CAAC;AAEF,eAAe,YAAY,CAAC"}

247
node_modules/jest-circus/build/eventHandler.js generated vendored Normal file
View file

@ -0,0 +1,247 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
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;
const eventHandler = (event, state) => {
switch (event.name) {
case 'include_test_location_in_result': {
state.includeTestLocationInResult = true;
break;
}
case 'hook_start': {
break;
}
case 'start_describe_definition': {
const blockName = event.blockName,
mode = event.mode;
const currentDescribeBlock = state.currentDescribeBlock;
const describeBlock = (0, _utils.makeDescribe)(
blockName,
currentDescribeBlock,
mode
);
currentDescribeBlock.children.push(describeBlock);
state.currentDescribeBlock = describeBlock;
break;
}
case 'finish_describe_definition': {
const currentDescribeBlock = state.currentDescribeBlock;
(0, _utils.invariant)(
currentDescribeBlock,
`currentDescribeBlock must be there`
);
if (!(0, _utils.describeBlockHasTests)(currentDescribeBlock)) {
currentDescribeBlock.hooks.forEach(hook => {
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
const shouldInheritMode = !(
currentDescribeBlock.mode === 'only' &&
currentDescribeBlock.tests.find(test => test.mode === 'only')
);
if (shouldInheritMode) {
currentDescribeBlock.tests.forEach(test => {
if (!test.mode) {
test.mode = currentDescribeBlock.mode;
}
});
}
if (
!state.hasFocusedTests &&
currentDescribeBlock.tests.some(test => test.mode === 'only')
) {
state.hasFocusedTests = true;
}
if (currentDescribeBlock.parent) {
state.currentDescribeBlock = currentDescribeBlock.parent;
}
break;
}
case 'add_hook': {
const currentDescribeBlock = state.currentDescribeBlock;
const asyncError = event.asyncError,
fn = event.fn,
type = event.hookType,
timeout = event.timeout;
const parent = currentDescribeBlock;
currentDescribeBlock.hooks.push({
asyncError,
fn,
parent,
timeout,
type
});
break;
}
case 'add_test': {
const currentDescribeBlock = state.currentDescribeBlock;
const asyncError = event.asyncError,
fn = event.fn,
mode = event.mode,
name = event.testName,
timeout = event.timeout;
const test = (0, _utils.makeTest)(
fn,
mode,
name,
currentDescribeBlock,
timeout,
asyncError
);
if (test.mode === 'only') {
state.hasFocusedTests = true;
}
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;
if (type === 'beforeAll') {
(0, _utils.invariant)(describeBlock, 'always present for `*All` hooks');
(0, _utils.addErrorToEachTestUnderDescribe)(
describeBlock,
error,
asyncError
);
} else if (type === 'afterAll') {
// Attaching `afterAll` errors to each test makes execution flow
// too complicated, so we'll consider them to be global.
state.unhandledErrors.push([error, asyncError]);
} else {
(0, _utils.invariant)(test, 'always present for `*Each` hooks');
test.errors.push([error, asyncError]);
}
break;
}
case 'test_skip': {
event.test.status = 'skip';
break;
}
case 'test_todo': {
event.test.status = 'todo';
break;
}
case 'test_done': {
event.test.duration = (0, _utils.getTestDuration)(event.test);
event.test.status = 'done';
state.currentlyRunningTest = null;
break;
}
case 'test_start': {
state.currentlyRunningTest = event.test;
event.test.startedAt = jestNow();
event.test.invocations += 1;
break;
}
case 'test_fn_failure': {
const error = event.error,
asyncError = event.test.asyncError;
event.test.errors.push([error, asyncError]);
break;
}
case 'test_retry': {
event.test.errors = [];
break;
}
case 'run_start': {
global[_types.TEST_TIMEOUT_SYMBOL] &&
(state.testTimeout = global[_types.TEST_TIMEOUT_SYMBOL]);
break;
}
case 'run_finish': {
break;
}
case 'setup': {
// Uncaught exception handlers should be defined on the parent process
// object. If defined on the VM's process object they just no op and let
// the parent process crash. It might make sense to return a `dispatch`
// function to the parent process and register handlers there instead, but
// i'm not sure if this is works. For now i just replicated whatever
// jasmine was doing -- dabramov
state.parentProcess = event.parentProcess;
(0, _utils.invariant)(state.parentProcess);
state.originalGlobalErrorHandlers = (0,
_globalErrorHandlers.injectGlobalErrorHandlers)(state.parentProcess);
if (event.testNamePattern) {
state.testNamePattern = new RegExp(event.testNamePattern, 'i');
}
break;
}
case 'teardown': {
(0, _utils.invariant)(state.originalGlobalErrorHandlers);
(0, _utils.invariant)(state.parentProcess);
(0, _globalErrorHandlers.restoreGlobalErrorHandlers)(
state.parentProcess,
state.originalGlobalErrorHandlers
);
break;
}
case 'error': {
// It's very likely for long-running async tests to throw errors. In this
// case we want to catch them and fail the current test. At the same time
// there's a possibility that one test sets a long timeout, that will
// eventually throw after this test finishes but during some other test
// execution, which will result in one test's error failing another test.
// In any way, it should be possible to track where the error was thrown
// from.
state.currentlyRunningTest
? state.currentlyRunningTest.errors.push(event.error)
: state.unhandledErrors.push(event.error);
break;
}
}
};
var _default = eventHandler;
exports.default = _default;

View file

@ -0,0 +1,10 @@
/**
* 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 { Circus } from '@jest/types';
declare const formatNodeAssertErrors: (event: Circus.Event, state: Circus.State) => void;
export default formatNodeAssertErrors;
//# sourceMappingURL=formatNodeAssertErrors.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"formatNodeAssertErrors.d.ts","sourceRoot":"","sources":["../src/formatNodeAssertErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAgCnC,QAAA,MAAM,sBAAsB,oDA4B3B,CAAC;AAsGF,eAAe,sBAAsB,CAAC"}

View file

@ -0,0 +1,223 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _jestMatcherUtils = require('jest-matcher-utils');
var _chalk = _interopRequireDefault(require('chalk'));
var _prettyFormat = _interopRequireDefault(require('pretty-format'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
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;
}
const assertOperatorsMap = {
'!=': 'notEqual',
'!==': 'notStrictEqual',
'==': 'equal',
'===': 'strictEqual'
};
const humanReadableOperators = {
deepEqual: 'to deeply equal',
deepStrictEqual: 'to deeply and strictly equal',
equal: 'to be equal',
notDeepEqual: 'not to deeply equal',
notDeepStrictEqual: 'not to deeply and strictly equal',
notEqual: 'to not be equal',
notStrictEqual: 'not be strictly equal',
strictEqual: 'to strictly be equal'
};
const formatNodeAssertErrors = (event, state) => {
switch (event.name) {
case 'test_done': {
event.test.errors = event.test.errors.map(errors => {
let error;
if (Array.isArray(errors)) {
const _errors = _slicedToArray(errors, 2),
originalError = _errors[0],
asyncError = _errors[1];
if (originalError == null) {
error = asyncError;
} else if (!originalError.stack) {
error = asyncError;
error.message = originalError.message
? originalError.message
: `thrown: ${(0, _prettyFormat.default)(originalError, {
maxDepth: 3
})}`;
} else {
error = originalError;
}
} else {
error = errors;
}
return error.code === 'ERR_ASSERTION'
? {
message: assertionErrorMessage(error, {
expand: state.expand
})
}
: errors;
});
}
}
};
const getOperatorName = (operator, stack) => {
if (typeof operator === 'string') {
return assertOperatorsMap[operator] || operator;
}
if (stack.match('.doesNotThrow')) {
return 'doesNotThrow';
}
if (stack.match('.throws')) {
return 'throws';
}
return '';
};
const operatorMessage = operator => {
const niceOperatorName = getOperatorName(operator, '');
const humanReadableOperator = humanReadableOperators[niceOperatorName];
return typeof operator === 'string'
? `${humanReadableOperator || niceOperatorName} to:\n`
: '';
};
const assertThrowingMatcherHint = operatorName =>
_chalk.default.dim('assert') +
_chalk.default.dim('.' + operatorName + '(') +
_chalk.default.red('function') +
_chalk.default.dim(')');
const assertMatcherHint = (operator, operatorName) => {
let message =
_chalk.default.dim('assert') +
_chalk.default.dim('.' + operatorName + '(') +
_chalk.default.red('received') +
_chalk.default.dim(', ') +
_chalk.default.green('expected') +
_chalk.default.dim(')');
if (operator === '==') {
message +=
' or ' +
_chalk.default.dim('assert') +
_chalk.default.dim('(') +
_chalk.default.red('received') +
_chalk.default.dim(') ');
}
return message;
};
function assertionErrorMessage(error, options) {
const expected = error.expected,
actual = error.actual,
generatedMessage = error.generatedMessage,
message = error.message,
operator = error.operator,
stack = error.stack;
const diffString = (0, _jestMatcherUtils.diff)(expected, actual, options);
const hasCustomMessage = !generatedMessage;
const operatorName = getOperatorName(operator, stack);
const trimmedStack = stack
.replace(message, '')
.replace(/AssertionError(.*)/g, '');
if (operatorName === 'doesNotThrow') {
return (
assertThrowingMatcherHint(operatorName) +
'\n\n' +
_chalk.default.reset(`Expected the function not to throw an error.\n`) +
_chalk.default.reset(`Instead, it threw:\n`) +
` ${(0, _jestMatcherUtils.printReceived)(actual)}` +
_chalk.default.reset(
hasCustomMessage ? '\n\nMessage:\n ' + message : ''
) +
trimmedStack
);
}
if (operatorName === 'throws') {
return (
assertThrowingMatcherHint(operatorName) +
'\n\n' +
_chalk.default.reset(`Expected the function to throw an error.\n`) +
_chalk.default.reset(`But it didn't throw anything.`) +
_chalk.default.reset(
hasCustomMessage ? '\n\nMessage:\n ' + message : ''
) +
trimmedStack
);
}
return (
assertMatcherHint(operator, operatorName) +
'\n\n' +
_chalk.default.reset(`Expected value ${operatorMessage(operator)}`) +
` ${(0, _jestMatcherUtils.printExpected)(expected)}\n` +
_chalk.default.reset(`Received:\n`) +
` ${(0, _jestMatcherUtils.printReceived)(actual)}` +
_chalk.default.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') +
(diffString ? `\n\nDifference:\n\n${diffString}` : '') +
trimmedStack
);
}
var _default = formatNodeAssertErrors;
exports.default = _default;

View file

@ -0,0 +1,11 @@
/**
* 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 { Circus } from '@jest/types';
export declare const injectGlobalErrorHandlers: (parentProcess: NodeJS.Process) => Circus.GlobalErrorHandlers;
export declare const restoreGlobalErrorHandlers: (parentProcess: NodeJS.Process, originalErrorHandlers: Circus.GlobalErrorHandlers) => void;
//# sourceMappingURL=globalErrorHandlers.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"globalErrorHandlers.d.ts","sourceRoot":"","sources":["../src/globalErrorHandlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAQnC,eAAO,MAAM,yBAAyB,+DAUrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,4FAatC,CAAC"}

100
node_modules/jest-circus/build/globalErrorHandlers.js generated vendored Normal file
View file

@ -0,0 +1,100 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.restoreGlobalErrorHandlers = exports.injectGlobalErrorHandlers = void 0;
var _state = require('./state');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const uncaught = error => {
(0, _state.dispatch)({
error,
name: 'error'
});
};
const injectGlobalErrorHandlers = parentProcess => {
const uncaughtException = process.listeners('uncaughtException').slice();
const unhandledRejection = process.listeners('unhandledRejection').slice();
parentProcess.removeAllListeners('uncaughtException');
parentProcess.removeAllListeners('unhandledRejection');
parentProcess.on('uncaughtException', uncaught);
parentProcess.on('unhandledRejection', uncaught);
return {
uncaughtException,
unhandledRejection
};
};
exports.injectGlobalErrorHandlers = injectGlobalErrorHandlers;
const restoreGlobalErrorHandlers = (parentProcess, originalErrorHandlers) => {
parentProcess.removeListener('uncaughtException', uncaught);
parentProcess.removeListener('unhandledRejection', uncaught);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (
var _iterator = originalErrorHandlers.uncaughtException[
Symbol.iterator
](),
_step;
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
_iteratorNormalCompletion = true
) {
const listener = _step.value;
parentProcess.on('uncaughtException', listener);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (
var _iterator2 = originalErrorHandlers.unhandledRejection[
Symbol.iterator
](),
_step2;
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
_iteratorNormalCompletion2 = true
) {
const listener = _step2.value;
parentProcess.on('unhandledRejection', listener);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
};
exports.restoreGlobalErrorHandlers = restoreGlobalErrorHandlers;

51
node_modules/jest-circus/build/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,51 @@
/**
* 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 { Circus, Global } from '@jest/types';
declare type THook = (fn: Circus.HookFn, timeout?: number) => void;
declare const describe: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
only: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
};
skip: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
};
};
declare const beforeEach: THook;
declare const beforeAll: THook;
declare const afterEach: THook;
declare const afterAll: THook;
declare const test: Global.It;
declare const it: Global.It;
export declare type Event = Circus.Event;
export declare type State = Circus.State;
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, test };
declare const _default: {
afterAll: THook;
afterEach: THook;
beforeAll: THook;
beforeEach: THook;
describe: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
only: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
};
skip: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: Global.EachTestFn, timeout?: number | undefined) => void;
};
};
it: Global.It;
test: Global.It;
};
export default _default;
//# sourceMappingURL=index.d.ts.map

1
node_modules/jest-circus/build/index.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAG3C,aAAK,KAAK,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAM3D,QAAA,MAAM,QAAQ;;;;;;;;;;;CAiBV,CAAC;AA8EL,QAAA,MAAM,UAAU,EAAE,KAC+B,CAAC;AAClD,QAAA,MAAM,SAAS,EAAE,KAC8B,CAAC;AAChD,QAAA,MAAM,SAAS,EAAE,KAC8B,CAAC;AAChD,QAAA,MAAM,QAAQ,EAAE,KAC6B,CAAC;AAE9C,QAAA,MAAM,IAAI,EAAE,MAAM,CAAC,EA2Ef,CAAC;AAEL,QAAA,MAAM,EAAE,EAAE,MAAM,CAAC,EAAS,CAAC;AAE3B,oBAAY,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACjC,oBAAY,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACjC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAC,CAAC;;;;;;;;;;;;;;;;;;;;;AACxE,wBAQE"}

223
node_modules/jest-circus/build/index.js generated vendored Normal file
View file

@ -0,0 +1,223 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.it = exports.describe = exports.beforeEach = exports.beforeAll = exports.afterEach = exports.afterAll = void 0;
var _chalk = _interopRequireDefault(require('chalk'));
var _jestEach = require('jest-each');
var _jestMessageUtil = require('jest-message-util');
var _jestUtil = require('jest-util');
var _state = require('./state');
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 describe = (() => {
const describe = (blockName, blockFn) =>
_dispatchDescribe(blockFn, blockName, describe);
const only = (blockName, blockFn) =>
_dispatchDescribe(blockFn, blockName, only, 'only');
const skip = (blockName, blockFn) =>
_dispatchDescribe(blockFn, blockName, skip, 'skip');
describe.each = (0, _jestEach.bind)(describe, false);
only.each = (0, _jestEach.bind)(only, false);
skip.each = (0, _jestEach.bind)(skip, false);
describe.only = only;
describe.skip = skip;
return describe;
})();
exports.describe = describe;
const _dispatchDescribe = (blockFn, blockName, describeFn, mode) => {
const asyncError = new _jestUtil.ErrorWithStack(undefined, describeFn);
if (blockFn === undefined) {
asyncError.message = `Missing second argument. It must be a callback function.`;
throw asyncError;
}
if (typeof blockFn !== 'function') {
asyncError.message = `Invalid second argument, ${blockFn}. It must be a callback function.`;
throw asyncError;
}
(0, _state.dispatch)({
asyncError,
blockName,
mode,
name: 'start_describe_definition'
});
const describeReturn = blockFn(); // TODO throw in Jest 25
if ((0, _jestUtil.isPromise)(describeReturn)) {
console.log(
(0, _jestMessageUtil.formatExecError)(
new _jestUtil.ErrorWithStack(
_chalk.default.yellow(
'Returning a Promise from "describe" is not supported. Tests must be defined synchronously.\n' +
'Returning a value from "describe" will fail the test in a future version of Jest.'
),
describeFn
),
{
rootDir: '',
testMatch: []
},
{
noStackTrace: false
}
)
);
} else if (describeReturn !== undefined) {
console.log(
(0, _jestMessageUtil.formatExecError)(
new _jestUtil.ErrorWithStack(
_chalk.default.yellow(
'A "describe" callback must not return a value.\n' +
'Returning a value from "describe" will fail the test in a future version of Jest.'
),
describeFn
),
{
rootDir: '',
testMatch: []
},
{
noStackTrace: false
}
)
);
}
(0, _state.dispatch)({
blockName,
mode,
name: 'finish_describe_definition'
});
};
const _addHook = (fn, hookType, hookFn, timeout) => {
const asyncError = new _jestUtil.ErrorWithStack(undefined, hookFn);
if (typeof fn !== 'function') {
asyncError.message =
'Invalid first argument. It must be a callback function.';
throw asyncError;
}
(0, _state.dispatch)({
asyncError,
fn,
hookType,
name: 'add_hook',
timeout
});
}; // Hooks have to pass themselves to the HOF in order for us to trim stack traces.
const beforeEach = (fn, timeout) =>
_addHook(fn, 'beforeEach', beforeEach, timeout);
exports.beforeEach = beforeEach;
const beforeAll = (fn, timeout) =>
_addHook(fn, 'beforeAll', beforeAll, timeout);
exports.beforeAll = beforeAll;
const afterEach = (fn, timeout) =>
_addHook(fn, 'afterEach', afterEach, timeout);
exports.afterEach = afterEach;
const afterAll = (fn, timeout) => _addHook(fn, 'afterAll', afterAll, timeout);
exports.afterAll = afterAll;
const test = (() => {
const test = (testName, fn, timeout) =>
_addTest(testName, undefined, fn, test, timeout);
const skip = (testName, fn, timeout) =>
_addTest(testName, 'skip', fn, skip, timeout);
const only = (testName, fn, timeout) =>
_addTest(testName, 'only', fn, test.only, timeout);
test.todo = (testName, ...rest) => {
if (rest.length > 0 || typeof testName !== 'string') {
throw new _jestUtil.ErrorWithStack(
'Todo must be called with only a description.',
test.todo
);
}
return _addTest(testName, 'todo', () => {}, test.todo);
};
const _addTest = (testName, mode, fn, testFn, timeout) => {
const asyncError = new _jestUtil.ErrorWithStack(undefined, testFn);
if (typeof testName !== 'string') {
asyncError.message = `Invalid first argument, ${testName}. It must be a string.`;
throw asyncError;
}
if (fn === undefined) {
asyncError.message =
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.';
throw asyncError;
}
if (typeof fn !== 'function') {
asyncError.message = `Invalid second argument, ${fn}. It must be a callback function.`;
throw asyncError;
}
return (0, _state.dispatch)({
asyncError,
fn,
mode,
name: 'add_test',
testName,
timeout
});
};
test.each = (0, _jestEach.bind)(test);
only.each = (0, _jestEach.bind)(only);
skip.each = (0, _jestEach.bind)(skip);
test.only = only;
test.skip = skip;
return test;
})();
exports.test = test;
const it = test;
exports.it = it;
var _default = {
afterAll,
afterEach,
beforeAll,
beforeEach,
describe,
it,
test
};
exports.default = _default;

View file

@ -0,0 +1,13 @@
/**
* 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 { Config } from '@jest/types';
import { JestEnvironment } from '@jest/environment';
import { TestResult } from '@jest/test-result';
import Runtime from 'jest-runtime';
declare const jestAdapter: (globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string) => Promise<TestResult>;
export = jestAdapter;
//# sourceMappingURL=jestAdapter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"jestAdapter.d.ts","sourceRoot":"","sources":["../../src/legacy-code-todo-rewrite/jestAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAE7C,OAAO,OAAO,MAAM,cAAc,CAAC;AAKnC,QAAA,MAAM,WAAW,4JAsEhB,CAAC;AAgCF,SAAS,WAAW,CAAC"}

View file

@ -0,0 +1,159 @@
'use strict';
var _path = _interopRequireDefault(require('path'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
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);
});
};
}
const FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
const jestAdapter =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*(
globalConfig,
config,
environment,
runtime,
testPath
) {
const _runtime$requireInter = runtime.requireInternalModule(
FRAMEWORK_INITIALIZER
),
initialize = _runtime$requireInter.initialize,
runAndTransformResultsToJestFormat =
_runtime$requireInter.runAndTransformResultsToJestFormat;
runtime
.requireInternalModule(
_path.default.resolve(__dirname, './jestExpect.js')
)
.default({
expand: globalConfig.expand
});
const getPrettier = () =>
config.prettierPath ? require(config.prettierPath) : null;
const getBabelTraverse = () => require('@babel/traverse').default;
const _initialize = initialize({
config,
environment,
getBabelTraverse,
getPrettier,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
parentProcess: process,
testPath
}),
globals = _initialize.globals,
snapshotState = _initialize.snapshotState;
if (config.timers === 'fake') {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers.useFakeTimers();
}
globals.beforeEach(() => {
if (config.resetModules) {
runtime.resetModules();
}
if (config.clearMocks) {
runtime.clearAllMocks();
}
if (config.resetMocks) {
runtime.resetAllMocks();
if (config.timers === 'fake') {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers.useFakeTimers();
}
}
if (config.restoreMocks) {
runtime.restoreAllMocks();
}
});
config.setupFilesAfterEnv.forEach(path => runtime.requireModule(path));
runtime.requireModule(testPath);
const results = yield runAndTransformResultsToJestFormat({
config,
globalConfig,
testPath
});
return _addSnapshotData(results, snapshotState);
});
return function jestAdapter(_x, _x2, _x3, _x4, _x5) {
return _ref.apply(this, arguments);
};
})();
const _addSnapshotData = (results, snapshotState) => {
results.testResults.forEach(({fullName, status}) => {
if (status === 'pending' || status === 'failed') {
// if test is skipped or failed, we don't want to mark
// its snapshots as obsolete.
snapshotState.markSnapshotsAsCheckedForTest(fullName);
}
});
const uncheckedCount = snapshotState.getUncheckedCount();
const uncheckedKeys = snapshotState.getUncheckedKeys();
if (uncheckedCount) {
snapshotState.removeUncheckedKeys();
}
const status = snapshotState.save();
results.snapshot.fileDeleted = status.deleted;
results.snapshot.added = snapshotState.added;
results.snapshot.matched = snapshotState.matched;
results.snapshot.unmatched = snapshotState.unmatched;
results.snapshot.updated = snapshotState.updated;
results.snapshot.unchecked = !status.deleted ? uncheckedCount : 0; // Copy the array to prevent memory leaks
results.snapshot.uncheckedKeys = Array.from(uncheckedKeys);
return results;
};
module.exports = jestAdapter;

View file

@ -0,0 +1,48 @@
/**
* 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 { Circus, Config } from '@jest/types';
import { JestEnvironment } from '@jest/environment';
import { TestResult } from '@jest/test-result';
export declare const initialize: ({ config, environment, getPrettier, getBabelTraverse, globalConfig, localRequire, parentProcess, testPath, }: {
config: Config.ProjectConfig;
environment: JestEnvironment;
getPrettier: () => any;
getBabelTraverse: () => Function;
globalConfig: Config.GlobalConfig;
localRequire: (path: string) => any;
testPath: string;
parentProcess: NodeJS.Process;
}) => {
globals: {
afterAll: (fn: Circus.HookFn, timeout?: number | undefined) => void;
afterEach: (fn: Circus.HookFn, timeout?: number | undefined) => void;
beforeAll: (fn: Circus.HookFn, timeout?: number | undefined) => void;
beforeEach: (fn: Circus.HookFn, timeout?: number | undefined) => void;
describe: {
(blockName: string, blockFn: import("@jest/types/build/Global").BlockFn): void;
each: (table: import("@jest/types/build/Global").EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: import("@jest/types/build/Global").EachTestFn, timeout?: number | undefined) => void;
only: {
(blockName: string, blockFn: import("@jest/types/build/Global").BlockFn): void;
each: (table: import("@jest/types/build/Global").EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: import("@jest/types/build/Global").EachTestFn, timeout?: number | undefined) => void;
};
skip: {
(blockName: string, blockFn: import("@jest/types/build/Global").BlockFn): void;
each: (table: import("@jest/types/build/Global").EachTable, ...taggedTemplateData: unknown[]) => (title: string, test: import("@jest/types/build/Global").EachTestFn, timeout?: number | undefined) => void;
};
};
it: import("@jest/types/build/Global").It;
test: import("@jest/types/build/Global").It;
};
snapshotState: import("../../../jest-snapshot/build/State").default;
};
export declare const runAndTransformResultsToJestFormat: ({ config, globalConfig, testPath, }: {
config: Config.ProjectConfig;
globalConfig: Config.GlobalConfig;
testPath: string;
}) => Promise<TestResult>;
//# sourceMappingURL=jestAdapterInit.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"jestAdapterInit.d.ts","sourceRoot":"","sources":["../../src/legacy-code-todo-rewrite/jestAdapterInit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAA0B,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAgBtE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGtB,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;yBA0G9C,CAAC"}

View file

@ -0,0 +1,300 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.runAndTransformResultsToJestFormat = exports.initialize = void 0;
var _expect = require('expect');
var _jestMessageUtil = require('jest-message-util');
var _jestSnapshot = require('jest-snapshot');
var _throat = _interopRequireDefault(require('throat'));
var _state = require('../state');
var _utils = require('../utils');
var _run = _interopRequireDefault(require('../run'));
var _ = _interopRequireDefault(require('..'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
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);
});
};
}
const initialize = ({
config,
environment,
getPrettier,
getBabelTraverse,
globalConfig,
localRequire,
parentProcess,
testPath
}) => {
const mutex = (0, _throat.default)(globalConfig.maxConcurrency);
Object.assign(global, _.default);
global.xit = global.it.skip;
global.xtest = global.it.skip;
global.xdescribe = global.describe.skip;
global.fit = global.it.only;
global.fdescribe = global.describe.only;
global.test.concurrent = (test => {
const concurrent = (testName, testFn, timeout) => {
// For concurrent tests we first run the function that returns promise, and then register a
// nomral test that will be waiting on the returned promise (when we start the test, the promise
// will already be in the process of execution).
// Unfortunately at this stage there's no way to know if there are any `.only` tests in the suite
// that will result in this test to be skipped, so we'll be executing the promise function anyway,
// even if it ends up being skipped.
const promise = mutex(() => testFn());
global.test(testName, () => promise, timeout);
};
concurrent.only = (testName, testFn, timeout) => {
const promise = mutex(() => testFn()); // eslint-disable-next-line jest/no-focused-tests
test.only(testName, () => promise, timeout);
};
concurrent.skip = test.skip;
return concurrent;
})(global.test);
(0, _state.addEventHandler)(eventHandler);
if (environment.handleTestEvent) {
(0, _state.addEventHandler)(environment.handleTestEvent.bind(environment));
}
(0, _state.dispatch)({
name: 'setup',
parentProcess,
testNamePattern: globalConfig.testNamePattern
});
if (config.testLocationInResults) {
(0, _state.dispatch)({
name: 'include_test_location_in_result'
});
} // Jest tests snapshotSerializers in order preceding built-in serializers.
// Therefore, add in reverse because the last added is the first tested.
config.snapshotSerializers
.concat()
.reverse()
.forEach(path => {
(0, _jestSnapshot.addSerializer)(localRequire(path));
});
const expand = globalConfig.expand,
updateSnapshot = globalConfig.updateSnapshot;
const snapshotResolver = (0, _jestSnapshot.buildSnapshotResolver)(config);
const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath);
const snapshotState = new _jestSnapshot.SnapshotState(snapshotPath, {
expand,
getBabelTraverse,
getPrettier,
updateSnapshot
});
(0, _expect.setState)({
snapshotState,
testPath
}); // Return it back to the outer scope (test runner outside the VM).
return {
globals: _.default,
snapshotState
};
};
exports.initialize = initialize;
const runAndTransformResultsToJestFormat =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*({config, globalConfig, testPath}) {
const runResult = yield (0, _run.default)();
let numFailingTests = 0;
let numPassingTests = 0;
let numPendingTests = 0;
let numTodoTests = 0;
const assertionResults = runResult.testResults.map(testResult => {
let status;
if (testResult.status === 'skip') {
status = 'pending';
numPendingTests += 1;
} else if (testResult.status === 'todo') {
status = 'todo';
numTodoTests += 1;
} else if (testResult.errors.length) {
status = 'failed';
numFailingTests += 1;
} else {
status = 'passed';
numPassingTests += 1;
}
const ancestorTitles = testResult.testPath.filter(
name => name !== _state.ROOT_DESCRIBE_BLOCK_NAME
);
const title = ancestorTitles.pop();
return {
ancestorTitles,
duration: testResult.duration,
failureMessages: testResult.errors,
fullName: title
? ancestorTitles.concat(title).join(' ')
: ancestorTitles.join(' '),
invocations: testResult.invocations,
location: testResult.location,
numPassingAsserts: 0,
status,
title: testResult.testPath[testResult.testPath.length - 1]
};
});
let failureMessage = (0, _jestMessageUtil.formatResultsErrors)(
assertionResults,
config,
globalConfig,
testPath
);
let testExecError;
if (runResult.unhandledErrors.length) {
testExecError = {
message: '',
stack: runResult.unhandledErrors.join('\n')
};
failureMessage =
(failureMessage || '') +
'\n\n' +
runResult.unhandledErrors
.map(err =>
(0, _jestMessageUtil.formatExecError)(err, config, globalConfig)
)
.join('\n');
}
(0, _state.dispatch)({
name: 'teardown'
});
return {
console: undefined,
displayName: config.displayName,
failureMessage,
leaks: false,
// That's legacy code, just adding it so Flow is happy.
numFailingTests,
numPassingTests,
numPendingTests,
numTodoTests,
openHandles: [],
perfStats: {
// populated outside
end: 0,
start: 0
},
skipped: false,
snapshot: {
added: 0,
fileDeleted: false,
matched: 0,
unchecked: 0,
uncheckedKeys: [],
unmatched: 0,
updated: 0
},
sourceMaps: {},
testExecError,
testFilePath: testPath,
testResults: assertionResults
};
});
return function runAndTransformResultsToJestFormat(_x) {
return _ref.apply(this, arguments);
};
})();
exports.runAndTransformResultsToJestFormat = runAndTransformResultsToJestFormat;
const eventHandler = event => {
switch (event.name) {
case 'test_start': {
(0, _expect.setState)({
currentTestName: (0, _utils.getTestID)(event.test)
});
break;
}
case 'test_done': {
_addSuppressedErrors(event.test);
_addExpectedAssertionErrors(event.test);
break;
}
}
};
const _addExpectedAssertionErrors = test => {
const failures = (0, _expect.extractExpectedAssertionsErrors)();
const errors = failures.map(failure => failure.error);
test.errors = test.errors.concat(errors);
}; // Get suppressed errors from ``jest-matchers`` that weren't throw during
// test execution and add them to the test result, potentially failing
// a passing test.
const _addSuppressedErrors = test => {
const _getState = (0, _expect.getState)(),
suppressedErrors = _getState.suppressedErrors;
(0, _expect.setState)({
suppressedErrors: []
});
if (suppressedErrors.length) {
test.errors = test.errors.concat(suppressedErrors);
}
};

View file

@ -0,0 +1,11 @@
/**
* 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.
*/
declare const _default: (config: {
expand: boolean;
}) => void;
export default _default;
//# sourceMappingURL=jestExpect.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"jestExpect.d.ts","sourceRoot":"","sources":["../../src/legacy-code-todo-rewrite/jestExpect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;AAYH,wBAaE"}

View file

@ -0,0 +1,40 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _expect = _interopRequireDefault(require('expect'));
var _jestSnapshot = require('jest-snapshot');
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.
*/
var _default = config => {
global.expect = _expect.default;
_expect.default.setState({
expand: config.expand
});
_expect.default.extend({
toMatchInlineSnapshot: _jestSnapshot.toMatchInlineSnapshot,
toMatchSnapshot: _jestSnapshot.toMatchSnapshot,
toThrowErrorMatchingInlineSnapshot:
_jestSnapshot.toThrowErrorMatchingInlineSnapshot,
toThrowErrorMatchingSnapshot: _jestSnapshot.toThrowErrorMatchingSnapshot
});
_expect.default.addSnapshotSerializer = _jestSnapshot.addSerializer;
};
exports.default = _default;

10
node_modules/jest-circus/build/run.d.ts generated vendored Normal file
View file

@ -0,0 +1,10 @@
/**
* 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 { Circus } from '@jest/types';
declare const run: () => Promise<Circus.RunResult>;
export default run;
//# sourceMappingURL=run.d.ts.map

1
node_modules/jest-circus/build/run.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAanC,QAAA,MAAM,GAAG,iCASR,CAAC;AAqIF,eAAe,GAAG,CAAC"}

432
node_modules/jest-circus/build/run.js generated vendored Normal file
View file

@ -0,0 +1,432 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _types = require('./types');
var _state = require('./state');
var _utils = require('./utils');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
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);
});
};
}
const run =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*() {
const _getState = (0, _state.getState)(),
rootDescribeBlock = _getState.rootDescribeBlock;
(0, _state.dispatch)({
name: 'run_start'
});
yield _runTestsForDescribeBlock(rootDescribeBlock);
(0, _state.dispatch)({
name: 'run_finish'
});
return (0,
_utils.makeRunResult)((0, _state.getState)().rootDescribeBlock, (0, _state.getState)().unhandledErrors);
});
return function run() {
return _ref.apply(this, arguments);
};
})();
const _runTestsForDescribeBlock =
/*#__PURE__*/
(function() {
var _ref2 = _asyncToGenerator(function*(describeBlock) {
(0, _state.dispatch)({
describeBlock,
name: 'run_describe_start'
});
const _getAllHooksForDescri = (0, _utils.getAllHooksForDescribe)(
describeBlock
),
beforeAll = _getAllHooksForDescri.beforeAll,
afterAll = _getAllHooksForDescri.afterAll;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (
var _iterator = beforeAll[Symbol.iterator](), _step;
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
_iteratorNormalCompletion = true
) {
const hook = _step.value;
yield _callCircusHook({
describeBlock,
hook
});
} // Tests that fail and are retried we run after other tests
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
const retryTimes = parseInt(global[_types.RETRY_TIMES], 10) || 0;
const deferredRetryTests = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (
var _iterator2 = describeBlock.tests[Symbol.iterator](), _step2;
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
_iteratorNormalCompletion2 = true
) {
const test = _step2.value;
const hasErrorsBeforeTestRun = test.errors.length > 0;
yield _runTest(test);
if (
hasErrorsBeforeTestRun === false &&
retryTimes > 0 &&
test.errors.length > 0
) {
deferredRetryTests.push(test);
}
} // Re-run failed tests n-times if configured
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
for (var _i = 0; _i < deferredRetryTests.length; _i++) {
const test = deferredRetryTests[_i];
let numRetriesAvailable = retryTimes;
while (numRetriesAvailable > 0 && test.errors.length > 0) {
// Clear errors so retries occur
(0, _state.dispatch)({
name: 'test_retry',
test
});
yield _runTest(test);
numRetriesAvailable--;
}
}
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (
var _iterator3 = describeBlock.children[Symbol.iterator](), _step3;
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done);
_iteratorNormalCompletion3 = true
) {
const child = _step3.value;
yield _runTestsForDescribeBlock(child);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (
var _iterator4 = afterAll[Symbol.iterator](), _step4;
!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done);
_iteratorNormalCompletion4 = true
) {
const hook = _step4.value;
yield _callCircusHook({
describeBlock,
hook
});
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
(0, _state.dispatch)({
describeBlock,
name: 'run_describe_finish'
});
});
return function _runTestsForDescribeBlock(_x) {
return _ref2.apply(this, arguments);
};
})();
const _runTest =
/*#__PURE__*/
(function() {
var _ref3 = _asyncToGenerator(function*(test) {
(0, _state.dispatch)({
name: 'test_start',
test
});
const testContext = Object.create(null);
const _getState2 = (0, _state.getState)(),
hasFocusedTests = _getState2.hasFocusedTests,
testNamePattern = _getState2.testNamePattern;
const isSkipped =
test.mode === 'skip' ||
(hasFocusedTests && test.mode !== 'only') ||
(testNamePattern && !testNamePattern.test((0, _utils.getTestID)(test)));
if (isSkipped) {
(0, _state.dispatch)({
name: 'test_skip',
test
});
return;
}
if (test.mode === 'todo') {
(0, _state.dispatch)({
name: 'test_todo',
test
});
return;
}
const _getEachHooksForTest = (0, _utils.getEachHooksForTest)(test),
afterEach = _getEachHooksForTest.afterEach,
beforeEach = _getEachHooksForTest.beforeEach;
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (
var _iterator5 = beforeEach[Symbol.iterator](), _step5;
!(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
_iteratorNormalCompletion5 = true
) {
const hook = _step5.value;
if (test.errors.length) {
// If any of the before hooks failed already, we don't run any
// hooks after that.
break;
}
yield _callCircusHook({
hook,
test,
testContext
});
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
yield _callCircusTest(test, testContext);
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (
var _iterator6 = afterEach[Symbol.iterator](), _step6;
!(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done);
_iteratorNormalCompletion6 = true
) {
const hook = _step6.value;
yield _callCircusHook({
hook,
test,
testContext
});
} // `afterAll` hooks should not affect test status (pass or fail), because if
// we had a global `afterAll` hook it would block all existing tests until
// this hook is executed. So we dispatch `test_done` right away.
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
(0, _state.dispatch)({
name: 'test_done',
test
});
});
return function _runTest(_x2) {
return _ref3.apply(this, arguments);
};
})();
const _callCircusHook = ({hook, test, describeBlock, testContext}) => {
(0, _state.dispatch)({
hook,
name: 'hook_start'
});
const timeout = hook.timeout || (0, _state.getState)().testTimeout;
return (0, _utils.callAsyncCircusFn)(hook.fn, testContext, {
isHook: true,
timeout
})
.then(() =>
(0, _state.dispatch)({
describeBlock,
hook,
name: 'hook_success',
test
})
)
.catch(error =>
(0, _state.dispatch)({
describeBlock,
error,
hook,
name: 'hook_failure',
test
})
);
};
const _callCircusTest = (test, testContext) => {
(0, _state.dispatch)({
name: 'test_fn_start',
test
});
const timeout = test.timeout || (0, _state.getState)().testTimeout;
(0, _utils.invariant)(
test.fn,
`Tests with no 'fn' should have 'mode' set to 'skipped'`
);
if (test.errors.length) {
// We don't run the test if there's already an error in before hooks.
return Promise.resolve();
}
return (0, _utils.callAsyncCircusFn)(test.fn, testContext, {
isHook: false,
timeout
})
.then(() =>
(0, _state.dispatch)({
name: 'test_fn_success',
test
})
)
.catch(error =>
(0, _state.dispatch)({
error,
name: 'test_fn_failure',
test
})
);
};
var _default = run;
exports.default = _default;

13
node_modules/jest-circus/build/state.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* 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 { Circus } from '@jest/types';
export declare const ROOT_DESCRIBE_BLOCK_NAME = "ROOT_DESCRIBE_BLOCK";
export declare const getState: () => Circus.State;
export declare const setState: (state: Circus.State) => Circus.State;
export declare const dispatch: (event: Circus.Event) => void;
export declare const addEventHandler: (handler: Circus.EventHandler) => void;
//# sourceMappingURL=state.d.ts.map

1
node_modules/jest-circus/build/state.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAYnC,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAkB9D,eAAO,MAAM,QAAQ,oBAAwC,CAAC;AAC9D,eAAO,MAAM,QAAQ,uCACQ,CAAC;AAE9B,eAAO,MAAM,QAAQ,+BAIpB,CAAC;AAEF,eAAO,MAAM,eAAe,wCAE3B,CAAC"}

68
node_modules/jest-circus/build/state.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.addEventHandler = exports.dispatch = exports.setState = exports.getState = exports.ROOT_DESCRIBE_BLOCK_NAME = void 0;
var _types = require('./types');
var _utils = require('./utils');
var _eventHandler = _interopRequireDefault(require('./eventHandler'));
var _formatNodeAssertErrors = _interopRequireDefault(
require('./formatNodeAssertErrors')
);
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 eventHandlers = [_eventHandler.default, _formatNodeAssertErrors.default];
const ROOT_DESCRIBE_BLOCK_NAME = 'ROOT_DESCRIBE_BLOCK';
exports.ROOT_DESCRIBE_BLOCK_NAME = ROOT_DESCRIBE_BLOCK_NAME;
const ROOT_DESCRIBE_BLOCK = (0, _utils.makeDescribe)(ROOT_DESCRIBE_BLOCK_NAME);
const INITIAL_STATE = {
currentDescribeBlock: ROOT_DESCRIBE_BLOCK,
currentlyRunningTest: null,
expand: undefined,
hasFocusedTests: false,
// whether .only has been used on any test/describe
includeTestLocationInResult: false,
parentProcess: null,
rootDescribeBlock: ROOT_DESCRIBE_BLOCK,
testNamePattern: null,
testTimeout: 5000,
unhandledErrors: []
};
global[_types.STATE_SYM] = INITIAL_STATE;
const getState = () => global[_types.STATE_SYM];
exports.getState = getState;
const setState = state => (global[_types.STATE_SYM] = state);
exports.setState = setState;
const dispatch = event => {
for (var _i = 0; _i < eventHandlers.length; _i++) {
const handler = eventHandlers[_i];
handler(event, getState());
}
};
exports.dispatch = dispatch;
const addEventHandler = handler => {
eventHandlers.push(handler);
};
exports.addEventHandler = addEventHandler;

22
node_modules/jest-circus/build/types.d.ts generated vendored Normal file
View file

@ -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 expect from 'expect';
import { Circus } from '@jest/types';
export declare const STATE_SYM: "STATE_SYM_SYMBOL";
export declare const RETRY_TIMES: "RETRY_TIMES_SYMBOL";
export declare const TEST_TIMEOUT_SYMBOL: "TEST_TIMEOUT_SYMBOL";
declare global {
module NodeJS {
interface Global {
STATE_SYM_SYMBOL: Circus.State;
RETRY_TIMES_SYMBOL: string;
TEST_TIMEOUT_SYMBOL: number;
expect: typeof expect;
}
}
}
//# sourceMappingURL=types.d.ts.map

1
node_modules/jest-circus/build/types.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,eAAO,MAAM,SAAS,oBAEa,CAAC;AACpC,eAAO,MAAM,WAAW,sBAEa,CAAC;AAEtC,eAAO,MAAM,mBAAmB,uBAEM,CAAC;AAEvC,OAAO,CAAC,MAAM,CAAC;IACb,OAAO,MAAM,CAAC;QACZ,UAAU,MAAM;YACd,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC;YAC/B,kBAAkB,EAAE,MAAM,CAAC;YAC3B,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,OAAO,MAAM,CAAC;SACvB;KACF;CACF"}

21
node_modules/jest-circus/build/types.js generated vendored Normal file
View file

@ -0,0 +1,21 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.TEST_TIMEOUT_SYMBOL = exports.RETRY_TIMES = exports.STATE_SYM = void 0;
var _expect = _interopRequireDefault(require('expect'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const STATE_SYM = Symbol('JEST_STATE_SYMBOL');
exports.STATE_SYM = STATE_SYM;
const RETRY_TIMES = Symbol.for('RETRY_TIMES'); // To pass this value from Runtime object to state we need to use global[sym]
exports.RETRY_TIMES = RETRY_TIMES;
const TEST_TIMEOUT_SYMBOL = Symbol.for('TEST_TIMEOUT_SYMBOL');
exports.TEST_TIMEOUT_SYMBOL = TEST_TIMEOUT_SYMBOL;

28
node_modules/jest-circus/build/utils.d.ts generated vendored Normal file
View file

@ -0,0 +1,28 @@
/**
* 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 { Circus } from '@jest/types';
export declare const makeDescribe: (name: string, parent?: Circus.DescribeBlock | undefined, mode?: void | "skip" | "only" | "todo" | undefined) => Circus.DescribeBlock;
export declare const makeTest: (fn: import("@jest/types/build/Global").TestFn | undefined, mode: Circus.BlockMode, name: string, parent: Circus.DescribeBlock, timeout: number | undefined, asyncError: any) => Circus.TestEntry;
export declare const getAllHooksForDescribe: (describe: Circus.DescribeBlock) => {
beforeAll: Circus.Hook[];
afterAll: Circus.Hook[];
};
export declare const getEachHooksForTest: (test: Circus.TestEntry) => {
beforeEach: Circus.Hook[];
afterEach: Circus.Hook[];
};
export declare const describeBlockHasTests: (describe: Circus.DescribeBlock) => boolean;
export declare const callAsyncCircusFn: (fn: Circus.AsyncFn, testContext: Record<string, any> | undefined, { isHook, timeout }: {
isHook?: boolean | null | undefined;
timeout: number;
}) => Promise<any>;
export declare const getTestDuration: (test: Circus.TestEntry) => number | null;
export declare const makeRunResult: (describeBlock: Circus.DescribeBlock, unhandledErrors: Error[]) => Circus.RunResult;
export declare const getTestID: (test: Circus.TestEntry) => string;
export declare const addErrorToEachTestUnderDescribe: (describeBlock: Circus.DescribeBlock, error: any, asyncError: any) => void;
export declare const invariant: (condition: unknown, message?: string | undefined) => void;
//# sourceMappingURL=utils.d.ts.map

1
node_modules/jest-circus/build/utils.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAUnC,eAAO,MAAM,YAAY,uIAmBxB,CAAC;AAEF,eAAO,MAAM,QAAQ,mMAmBnB,CAAC;AAkBH,eAAO,MAAM,sBAAsB;;;CAuBlC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;CAwB/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,6CAG0C,CAAC;AAe7E,eAAO,MAAM,iBAAiB;;;kBAsF7B,CAAC;AAEF,eAAO,MAAM,eAAe,2CAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,qFAMxB,CAAC;AAuDH,eAAO,MAAM,SAAS,oCASrB,CAAC;AA8BF,eAAO,MAAM,+BAA+B,4EAY3C,CAAC;AAEF,eAAO,MAAM,SAAS,4DAIrB,CAAC"}

519
node_modules/jest-circus/build/utils.js generated vendored Normal file
View file

@ -0,0 +1,519 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.invariant = exports.addErrorToEachTestUnderDescribe = exports.getTestID = exports.makeRunResult = exports.getTestDuration = exports.callAsyncCircusFn = exports.describeBlockHasTests = exports.getEachHooksForTest = exports.getAllHooksForDescribe = exports.makeTest = exports.makeDescribe = void 0;
var _jestUtil = require('jest-util');
var _isGeneratorFn = _interopRequireDefault(require('is-generator-fn'));
var _co = _interopRequireDefault(require('co'));
var _stackUtils = _interopRequireDefault(require('stack-utils'));
var _prettyFormat = _interopRequireDefault(require('pretty-format'));
var _state = require('./state');
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var jestNow = global[Symbol.for('jest-native-now')] || global.Date.now;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const stackUtils = new _stackUtils.default({
cwd: 'A path that does not exist'
});
const makeDescribe = (name, parent, mode) => {
let _mode = mode;
if (parent && !mode) {
// If not set explicitly, inherit from the parent describe.
_mode = parent.mode;
}
return {
children: [],
hooks: [],
mode: _mode,
name: (0, _jestUtil.convertDescriptorToString)(name),
parent,
tests: []
};
};
exports.makeDescribe = makeDescribe;
const makeTest = (fn, mode, name, parent, timeout, asyncError) => ({
asyncError,
duration: null,
errors: [],
fn,
invocations: 0,
mode,
name: (0, _jestUtil.convertDescriptorToString)(name),
parent,
startedAt: null,
status: null,
timeout
}); // Traverse the tree of describe blocks and return true if at least one describe
// block has an enabled test.
exports.makeTest = makeTest;
const hasEnabledTest = describeBlock => {
const _getState = (0, _state.getState)(),
hasFocusedTests = _getState.hasFocusedTests,
testNamePattern = _getState.testNamePattern;
const hasOwnEnabledTests = describeBlock.tests.some(
test =>
!(
test.mode === 'skip' ||
(hasFocusedTests && test.mode !== 'only') ||
(testNamePattern && !testNamePattern.test(getTestID(test)))
)
);
return hasOwnEnabledTests || describeBlock.children.some(hasEnabledTest);
};
const getAllHooksForDescribe = describe => {
const result = {
afterAll: [],
beforeAll: []
};
if (hasEnabledTest(describe)) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (
var _iterator = describe.hooks[Symbol.iterator](), _step;
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
_iteratorNormalCompletion = true
) {
const hook = _step.value;
switch (hook.type) {
case 'beforeAll':
result.beforeAll.push(hook);
break;
case 'afterAll':
result.afterAll.push(hook);
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return result;
};
exports.getAllHooksForDescribe = getAllHooksForDescribe;
const getEachHooksForTest = test => {
const result = {
afterEach: [],
beforeEach: []
};
let block = test.parent;
do {
const beforeEachForCurrentBlock = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (
var _iterator2 = block.hooks[Symbol.iterator](), _step2;
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
_iteratorNormalCompletion2 = true
) {
const hook = _step2.value;
switch (hook.type) {
case 'beforeEach':
beforeEachForCurrentBlock.push(hook);
break;
case 'afterEach':
result.afterEach.push(hook);
break;
}
} // 'beforeEach' hooks are executed from top to bottom, the opposite of the
// way we traversed it.
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
result.beforeEach = [...beforeEachForCurrentBlock, ...result.beforeEach];
} while ((block = block.parent));
return result;
};
exports.getEachHooksForTest = getEachHooksForTest;
const describeBlockHasTests = describe =>
describe.tests.length > 0 || describe.children.some(describeBlockHasTests);
exports.describeBlockHasTests = describeBlockHasTests;
const _makeTimeoutMessage = (timeout, isHook) =>
`Exceeded timeout of ${timeout}ms for a ${
isHook ? 'hook' : 'test'
}.\nUse jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.`; // Global values can be overwritten by mocks or tests. We'll capture
// the original values in the variables before we require any files.
const _global = global,
setTimeout = _global.setTimeout,
clearTimeout = _global.clearTimeout;
function checkIsError(error) {
return !!(error && error.message && error.stack);
}
const callAsyncCircusFn = (fn, testContext, {isHook, timeout}) => {
let timeoutID;
let completed = false;
return new Promise((resolve, reject) => {
timeoutID = setTimeout(
() => reject(_makeTimeoutMessage(timeout, !!isHook)),
timeout
); // If this fn accepts `done` callback we return a promise that fulfills as
// soon as `done` called.
if (fn.length) {
const done = reason => {
const errorAsErrorObject = checkIsError(reason)
? reason
: new Error(
`Failed: ${(0, _prettyFormat.default)(reason, {
maxDepth: 3
})}`
); // Consider always throwing, regardless if `reason` is set or not
if (completed && reason) {
errorAsErrorObject.message =
'Caught error after test environment was torn down\n\n' +
errorAsErrorObject.message;
throw errorAsErrorObject;
}
return reason ? reject(errorAsErrorObject) : resolve();
};
return fn.call(testContext, done);
}
let returnedValue;
if ((0, _isGeneratorFn.default)(fn)) {
returnedValue = _co.default.wrap(fn).call({});
} else {
try {
returnedValue = fn.call(testContext);
} catch (error) {
return reject(error);
}
} // If it's a Promise, return it. Test for an object with a `then` function
// to support custom Promise implementations.
if (
typeof returnedValue === 'object' &&
returnedValue !== null &&
typeof returnedValue.then === 'function'
) {
return returnedValue.then(resolve, reject);
}
if (!isHook && returnedValue !== void 0) {
return reject(
new Error(`
test functions can only return Promise or undefined.
Returned value: ${String(returnedValue)}
`)
);
} // Otherwise this test is synchronous, and if it didn't throw it means
// it passed.
return resolve();
})
.then(() => {
completed = true; // If timeout is not cleared/unrefed the node process won't exit until
// it's resolved.
timeoutID.unref && timeoutID.unref();
clearTimeout(timeoutID);
})
.catch(error => {
completed = true;
timeoutID.unref && timeoutID.unref();
clearTimeout(timeoutID);
throw error;
});
};
exports.callAsyncCircusFn = callAsyncCircusFn;
const getTestDuration = test => {
const startedAt = test.startedAt;
return typeof startedAt === 'number' ? jestNow() - startedAt : null;
};
exports.getTestDuration = getTestDuration;
const makeRunResult = (describeBlock, unhandledErrors) => ({
testResults: makeTestResults(describeBlock),
unhandledErrors: unhandledErrors.map(_formatError)
});
exports.makeRunResult = makeRunResult;
const makeTestResults = describeBlock => {
const _getState2 = (0, _state.getState)(),
includeTestLocationInResult = _getState2.includeTestLocationInResult;
let testResults = [];
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (
var _iterator3 = describeBlock.tests[Symbol.iterator](), _step3;
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done);
_iteratorNormalCompletion3 = true
) {
const test = _step3.value;
const testPath = [];
let parent = test;
do {
testPath.unshift(parent.name);
} while ((parent = parent.parent));
const status = test.status;
if (!status) {
throw new Error('Status should be present after tests are run.');
}
let location = null;
if (includeTestLocationInResult) {
const stackLine = test.asyncError.stack.split('\n')[1];
const parsedLine = stackUtils.parseLine(stackLine);
if (
parsedLine &&
typeof parsedLine.column === 'number' &&
typeof parsedLine.line === 'number'
) {
location = {
column: parsedLine.column,
line: parsedLine.line
};
}
}
testResults.push({
duration: test.duration,
errors: test.errors.map(_formatError),
invocations: test.invocations,
location,
status,
testPath
});
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (
var _iterator4 = describeBlock.children[Symbol.iterator](), _step4;
!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done);
_iteratorNormalCompletion4 = true
) {
const child = _step4.value;
testResults = testResults.concat(makeTestResults(child));
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
return testResults;
}; // Return a string that identifies the test (concat of parent describe block
// names + test title)
const getTestID = test => {
const titles = [];
let parent = test;
do {
titles.unshift(parent.name);
} while ((parent = parent.parent));
titles.shift(); // remove TOP_DESCRIBE_BLOCK_NAME
return titles.join(' ');
};
exports.getTestID = getTestID;
const _formatError = errors => {
let error;
let asyncError;
if (Array.isArray(errors)) {
error = errors[0];
asyncError = errors[1];
} else {
error = errors;
asyncError = new Error();
}
if (error) {
if (error.stack) {
return error.stack;
}
if (error.message) {
return error.message;
}
}
asyncError.message = `thrown: ${(0, _prettyFormat.default)(error, {
maxDepth: 3
})}`;
return asyncError.stack;
};
const addErrorToEachTestUnderDescribe = (describeBlock, error, asyncError) => {
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (
var _iterator5 = describeBlock.tests[Symbol.iterator](), _step5;
!(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
_iteratorNormalCompletion5 = true
) {
const test = _step5.value;
test.errors.push([error, asyncError]);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (
var _iterator6 = describeBlock.children[Symbol.iterator](), _step6;
!(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done);
_iteratorNormalCompletion6 = true
) {
const child = _step6.value;
addErrorToEachTestUnderDescribe(child, error, asyncError);
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
};
exports.addErrorToEachTestUnderDescribe = addErrorToEachTestUnderDescribe;
const invariant = (condition, message) => {
if (!condition) {
throw new Error(message);
}
};
exports.invariant = invariant;