0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

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

@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus } from '@jest/types';
declare const eventHandler: Circus.EventHandler;
export default eventHandler;

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

@ -0,0 +1,286 @@
'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;
// 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': {
state.includeTestLocationInResult = true;
break;
}
case 'hook_start': {
break;
}
case 'start_describe_definition': {
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,
mode
);
currentDescribeBlock.children.push(describeBlock);
state.currentDescribeBlock = describeBlock;
break;
}
case 'finish_describe_definition': {
const {currentDescribeBlock} = state;
(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);
});
} // pass mode of currentDescribeBlock to tests
// but do not when there is already a single test with "only" mode
const shouldPassMode = !(
currentDescribeBlock.mode === 'only' &&
currentDescribeBlock.children.some(
child => child.type === 'test' && child.mode === 'only'
)
);
if (shouldPassMode) {
currentDescribeBlock.children.forEach(child => {
if (child.type === 'test' && !child.mode) {
child.mode = currentDescribeBlock.mode;
}
});
}
if (
!state.hasFocusedTests &&
currentDescribeBlock.children.some(
child => child.type === 'test' && child.mode === 'only'
)
) {
state.hasFocusedTests = true;
}
if (currentDescribeBlock.parent) {
state.currentDescribeBlock = currentDescribeBlock.parent;
}
break;
}
case 'add_hook': {
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,
fn,
parent,
timeout,
type
});
break;
}
case 'add_test': {
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,
name,
currentDescribeBlock,
timeout,
asyncError
);
if (test.mode === 'only') {
state.hasFocusedTests = true;
}
currentDescribeBlock.children.push(test);
currentDescribeBlock.tests.push(test);
break;
}
case 'hook_failure': {
const {test, describeBlock, error, hook} = event;
const {asyncError, type} = hook;
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,
test: {asyncError}
} = event;
event.test.errors.push([error, asyncError]);
break;
}
case 'test_retry': {
event.test.errors = [];
break;
}
case 'run_start': {
state.hasStarted = true;
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,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus } from '@jest/types';
declare const formatNodeAssertErrors: (event: Circus.Event, state: Circus.State) => void;
export default formatNodeAssertErrors;

View file

@ -0,0 +1,204 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _assert = require('assert');
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};
}
/**
* 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 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) => {
if (event.name === 'test_done') {
event.test.errors = event.test.errors.map(errors => {
let error;
if (Array.isArray(errors)) {
const [originalError, asyncError] = errors;
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 isAssertionError(error)
? {
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';
} // this fallback is only needed for versions older than node 10
if (stack.match('.fail')) {
return 'fail';
}
return '';
};
const operatorMessage = operator => {
const niceOperatorName = getOperatorName(operator, '');
const humanReadableOperator = humanReadableOperators[niceOperatorName];
return typeof operator === 'string'
? `${humanReadableOperator || niceOperatorName} to:\n`
: '';
};
const assertThrowingMatcherHint = operatorName =>
operatorName
? _chalk.default.dim('assert') +
_chalk.default.dim('.' + operatorName + '(') +
_chalk.default.red('function') +
_chalk.default.dim(')')
: '';
const assertMatcherHint = (operator, operatorName, expected) => {
let message = '';
if (operator === '==' && expected === true) {
message =
_chalk.default.dim('assert') +
_chalk.default.dim('(') +
_chalk.default.red('received') +
_chalk.default.dim(')');
} else if (operatorName) {
message =
_chalk.default.dim('assert') +
_chalk.default.dim('.' + operatorName + '(') +
_chalk.default.red('received') +
_chalk.default.dim(', ') +
_chalk.default.green('expected') +
_chalk.default.dim(')');
}
return message;
};
function assertionErrorMessage(error, options) {
const {expected, actual, generatedMessage, message, operator, stack} = error;
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 (
buildHintString(assertThrowingMatcherHint(operatorName)) +
_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 (
buildHintString(assertThrowingMatcherHint(operatorName)) +
_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
);
}
if (operatorName === 'fail') {
return (
buildHintString(assertMatcherHint(operator, operatorName, expected)) +
_chalk.default.reset(hasCustomMessage ? 'Message:\n ' + message : '') +
trimmedStack
);
}
return (
buildHintString(assertMatcherHint(operator, operatorName, expected)) +
_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
);
}
function isAssertionError(error) {
return (
error &&
(error instanceof _assert.AssertionError ||
error.name === _assert.AssertionError.name ||
error.code === 'ERR_ASSERTION')
);
}
function buildHintString(hint) {
return hint ? hint + '\n\n' : '';
}
var _default = formatNodeAssertErrors;
exports.default = _default;

View file

@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus } from '@jest/types';
export declare const injectGlobalErrorHandlers: (parentProcess: NodeJS.Process) => Circus.GlobalErrorHandlers;
export declare const restoreGlobalErrorHandlers: (parentProcess: NodeJS.Process, originalErrorHandlers: Circus.GlobalErrorHandlers) => void;

View file

@ -0,0 +1,51 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.restoreGlobalErrorHandlers = exports.injectGlobalErrorHandlers = void 0;
var _state = require('./state');
/**
* 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 uncaught = error => {
(0, _state.dispatchSync)({
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);
for (const listener of originalErrorHandlers.uncaughtException) {
parentProcess.on('uncaughtException', listener);
}
for (const listener of originalErrorHandlers.unhandledRejection) {
parentProcess.on('unhandledRejection', listener);
}
};
exports.restoreGlobalErrorHandlers = restoreGlobalErrorHandlers;

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

@ -0,0 +1,50 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus, Global } from '@jest/types';
declare type THook = (fn: Circus.HookFn, timeout?: number) => void;
declare const describe: {
(blockName: Circus.BlockName, blockFn: Circus.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, timeout?: number | undefined) => void;
only: {
(blockName: Circus.BlockName, blockFn: Circus.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, timeout?: number | undefined) => void;
};
skip: {
(blockName: Circus.BlockName, blockFn: Circus.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, 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: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, timeout?: number | undefined) => void;
only: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, timeout?: number | undefined) => void;
};
skip: {
(blockName: string, blockFn: Global.BlockFn): void;
each: (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => (title: string, test: Global.EachTestFn<Global.TestCallback>, timeout?: number | undefined) => void;
};
};
it: Global.It;
test: Global.It;
};
export default _default;

223
web/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.dispatchSync)({
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.dispatchSync)({
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.dispatchSync)({
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.dispatchSync)({
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,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
import type { JestEnvironment } from '@jest/environment';
import type { TestResult } from '@jest/test-result';
import type { RuntimeType as Runtime } from 'jest-runtime';
declare const jestAdapter: (globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string, sendMessageToJest?: import("jest-runner/build/types").TestFileEvent<"test-file-start" | "test-file-success" | "test-file-failure" | "test-case-result"> | undefined) => Promise<TestResult>;
export = jestAdapter;

View file

@ -0,0 +1,150 @@
'use strict';
var _jestUtil = require('jest-util');
/**
* 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 FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
const jestAdapter = async (
globalConfig,
config,
environment,
runtime,
testPath,
sendMessageToJest
) => {
var _runtime$setGlobalsFo, _runtime$unstable_sho2;
const {
initialize,
runAndTransformResultsToJestFormat
} = runtime.requireInternalModule(FRAMEWORK_INITIALIZER);
const getPrettier = () =>
config.prettierPath ? require(config.prettierPath) : null;
const getBabelTraverse = () => require('@babel/traverse').default;
const {globals, snapshotState} = await initialize({
config,
environment,
getBabelTraverse,
getPrettier,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
parentProcess: process,
sendMessageToJest,
setGlobalsForRuntime:
(_runtime$setGlobalsFo = runtime.setGlobalsForRuntime) === null ||
_runtime$setGlobalsFo === void 0
? void 0
: _runtime$setGlobalsFo.bind(runtime),
testPath
});
if (config.timers === 'fake' || config.timers === 'legacy') {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers.useFakeTimers();
} else if (config.timers === 'modern') {
environment.fakeTimersModern.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();
}
});
for (const path of config.setupFilesAfterEnv) {
var _runtime$unstable_sho;
// TODO: remove ? in Jest 26
const esm =
(_runtime$unstable_sho = runtime.unstable_shouldLoadAsEsm) === null ||
_runtime$unstable_sho === void 0
? void 0
: _runtime$unstable_sho.call(runtime, path);
if (esm) {
await runtime.unstable_importModule(path);
} else {
runtime.requireModule(path);
}
} // TODO: remove ? in Jest 26
const esm =
(_runtime$unstable_sho2 = runtime.unstable_shouldLoadAsEsm) === null ||
_runtime$unstable_sho2 === void 0
? void 0
: _runtime$unstable_sho2.call(runtime, testPath);
if (esm) {
await runtime.unstable_importModule(testPath);
} else {
runtime.requireModule(testPath);
}
const results = await runAndTransformResultsToJestFormat({
config,
globalConfig,
testPath
});
_addSnapshotData(results, snapshotState); // We need to copy the results object to ensure we don't leaks the prototypes
// from the VM. Jasmine creates the result objects in the parent process, we
// should consider doing that for circus as well.
return (0, _jestUtil.deepCyclicCopy)(results, {
keepPrototype: false
});
};
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);
};
module.exports = jestAdapter;

View file

@ -0,0 +1,40 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/// <reference types="node" />
import type BabelTraverse from '@babel/traverse';
import type { Config, Global } from '@jest/types';
import type { JestEnvironment } from '@jest/environment';
import { TestResult } from '@jest/test-result';
import type { TestFileEvent } from 'jest-runner';
import { SnapshotStateType } from 'jest-snapshot';
import globals from '..';
import { Expect } from './jestExpect';
declare type Process = NodeJS.Process;
interface JestGlobals extends Global.TestFrameworkGlobals {
expect: Expect;
}
export declare const initialize: ({ config, environment, getPrettier, getBabelTraverse, globalConfig, localRequire, parentProcess, sendMessageToJest, setGlobalsForRuntime, testPath, }: {
config: Config.ProjectConfig;
environment: JestEnvironment;
getPrettier: () => null | any;
getBabelTraverse: () => typeof BabelTraverse;
globalConfig: Config.GlobalConfig;
localRequire: <T = unknown>(path: Config.Path) => T;
testPath: Config.Path;
parentProcess: Process;
sendMessageToJest?: import("jest-runner/build/types").TestFileEvent<"test-file-start" | "test-file-success" | "test-file-failure" | "test-case-result"> | undefined;
setGlobalsForRuntime?: ((globals: JestGlobals) => void) | undefined;
}) => Promise<{
globals: Global.TestFrameworkGlobals;
snapshotState: SnapshotStateType;
}>;
export declare const runAndTransformResultsToJestFormat: ({ config, globalConfig, testPath, }: {
config: Config.ProjectConfig;
globalConfig: Config.GlobalConfig;
testPath: string;
}) => Promise<TestResult>;
export {};

View file

@ -0,0 +1,306 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.runAndTransformResultsToJestFormat = exports.initialize = void 0;
var _testResult = require('@jest/test-result');
var _expect = require('expect');
var _jestMessageUtil = require('jest-message-util');
var _jestSnapshot = require('jest-snapshot');
var _jestEach = require('jest-each');
var _throat = _interopRequireDefault(require('throat'));
var _state = require('../state');
var _utils = require('../utils');
var _run = _interopRequireDefault(require('../run'));
var _testCaseReportHandler = _interopRequireDefault(
require('../testCaseReportHandler')
);
var _ = _interopRequireDefault(require('..'));
var _jestExpect = _interopRequireDefault(require('./jestExpect'));
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 initialize = async ({
config,
environment,
getPrettier,
getBabelTraverse,
globalConfig,
localRequire,
parentProcess,
sendMessageToJest,
setGlobalsForRuntime,
testPath
}) => {
var _config$injectGlobals;
if (globalConfig.testTimeout) {
(0, _state.getState)().testTimeout = globalConfig.testTimeout;
}
const mutex = (0, _throat.default)(globalConfig.maxConcurrency); // @ts-expect-error
const globalsObject = {
..._.default,
fdescribe: _.default.describe.only,
fit: _.default.it.only,
xdescribe: _.default.describe.skip,
xit: _.default.it.skip,
xtest: _.default.it.skip
};
globalsObject.test.concurrent = (test => {
const concurrent = (testName, testFn, timeout) => {
// For concurrent tests we first run the function that returns promise, and then register a
// normal 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());
globalsObject.test(testName, () => promise, timeout);
};
const only = (testName, testFn, timeout) => {
const promise = mutex(() => testFn()); // eslint-disable-next-line jest/no-focused-tests
test.only(testName, () => promise, timeout);
};
concurrent.only = only;
concurrent.skip = test.skip;
concurrent.each = (0, _jestEach.bind)(test, false);
concurrent.skip.each = (0, _jestEach.bind)(test.skip, false);
only.each = (0, _jestEach.bind)(test.only, false);
return concurrent;
})(globalsObject.test);
(0, _state.addEventHandler)(eventHandler);
if (environment.handleTestEvent) {
(0, _state.addEventHandler)(environment.handleTestEvent.bind(environment));
}
const runtimeGlobals = {
...globalsObject,
expect: (0, _jestExpect.default)(globalConfig)
}; // TODO: `jest-circus` might be newer than `jest-runtime` - remove `?.` for Jest 27
setGlobalsForRuntime === null || setGlobalsForRuntime === void 0
? void 0
: setGlobalsForRuntime(runtimeGlobals); // TODO: `jest-circus` might be newer than `jest-config` - remove `??` for Jest 27
if (
(_config$injectGlobals = config.injectGlobals) !== null &&
_config$injectGlobals !== void 0
? _config$injectGlobals
: true
) {
Object.assign(environment.global, runtimeGlobals);
}
await (0, _state.dispatch)({
name: 'setup',
parentProcess,
runtimeGlobals,
testNamePattern: globalConfig.testNamePattern
});
if (config.testLocationInResults) {
await (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, updateSnapshot} = globalConfig;
const snapshotResolver = (0, _jestSnapshot.buildSnapshotResolver)(config);
const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath);
const snapshotState = new _jestSnapshot.SnapshotState(snapshotPath, {
expand,
getBabelTraverse,
getPrettier,
updateSnapshot
}); // @ts-expect-error: snapshotState is a jest extension of `expect`
(0, _expect.setState)({
snapshotState,
testPath
});
(0, _state.addEventHandler)(handleSnapshotStateAfterRetry(snapshotState));
if (sendMessageToJest) {
(0, _state.addEventHandler)(
(0, _testCaseReportHandler.default)(testPath, sendMessageToJest)
);
} // Return it back to the outer scope (test runner outside the VM).
return {
globals: globalsObject,
snapshotState
};
};
exports.initialize = initialize;
const runAndTransformResultsToJestFormat = async ({
config,
globalConfig,
testPath
}) => {
const runResult = await (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,
failureDetails: testResult.errorsDetailed,
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');
}
await (0, _state.dispatch)({
name: 'teardown'
});
return {
...(0, _testResult.createEmptyTestResult)(),
console: undefined,
displayName: config.displayName,
failureMessage,
numFailingTests,
numPassingTests,
numPendingTests,
numTodoTests,
sourceMaps: {},
testExecError,
testFilePath: testPath,
testResults: assertionResults
};
};
exports.runAndTransformResultsToJestFormat = runAndTransformResultsToJestFormat;
const handleSnapshotStateAfterRetry = snapshotState => event => {
switch (event.name) {
case 'test_retry': {
// Clear any snapshot data that occurred in previous test run
snapshotState.clear();
}
}
};
const eventHandler = async 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 {suppressedErrors} = (0, _expect.getState)();
(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.
*/
import type { Config } from '@jest/types';
import expect = require('expect');
export declare type Expect = typeof expect;
declare const _default: (config: Pick<Config.GlobalConfig, 'expand'>) => Expect;
export default _default;

View file

@ -0,0 +1,39 @@
'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 => {
_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;
return _expect.default;
};
exports.default = _default;

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

@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus } from '@jest/types';
declare const run: () => Promise<Circus.RunResult>;
export default run;

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

@ -0,0 +1,230 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _types = require('./types');
var _state = require('./state');
var _utils = require('./utils');
/**
* 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 run = async () => {
const {rootDescribeBlock} = (0, _state.getState)();
await (0, _state.dispatch)({
name: 'run_start'
});
await _runTestsForDescribeBlock(rootDescribeBlock);
await (0, _state.dispatch)({
name: 'run_finish'
});
return (0, _utils.makeRunResult)(
(0, _state.getState)().rootDescribeBlock,
(0, _state.getState)().unhandledErrors
);
};
const _runTestsForDescribeBlock = async describeBlock => {
await (0, _state.dispatch)({
describeBlock,
name: 'run_describe_start'
});
const {beforeAll, afterAll} = (0, _utils.getAllHooksForDescribe)(
describeBlock
);
for (const hook of beforeAll) {
await _callCircusHook({
describeBlock,
hook
});
} // Tests that fail and are retried we run after other tests
const retryTimes = parseInt(global[_types.RETRY_TIMES], 10) || 0;
const deferredRetryTests = [];
for (const child of describeBlock.children) {
switch (child.type) {
case 'describeBlock': {
await _runTestsForDescribeBlock(child);
break;
}
case 'test': {
const hasErrorsBeforeTestRun = child.errors.length > 0;
await _runTest(child);
if (
hasErrorsBeforeTestRun === false &&
retryTimes > 0 &&
child.errors.length > 0
) {
deferredRetryTests.push(child);
}
break;
}
}
} // Re-run failed tests n-times if configured
for (const test of deferredRetryTests) {
let numRetriesAvailable = retryTimes;
while (numRetriesAvailable > 0 && test.errors.length > 0) {
// Clear errors so retries occur
await (0, _state.dispatch)({
name: 'test_retry',
test
});
await _runTest(test);
numRetriesAvailable--;
}
}
for (const hook of afterAll) {
await _callCircusHook({
describeBlock,
hook
});
}
await (0, _state.dispatch)({
describeBlock,
name: 'run_describe_finish'
});
};
const _runTest = async test => {
await (0, _state.dispatch)({
name: 'test_start',
test
});
const testContext = Object.create(null);
const {hasFocusedTests, testNamePattern} = (0, _state.getState)();
const isSkipped =
test.mode === 'skip' ||
(hasFocusedTests && test.mode !== 'only') ||
(testNamePattern && !testNamePattern.test((0, _utils.getTestID)(test)));
if (isSkipped) {
await (0, _state.dispatch)({
name: 'test_skip',
test
});
return;
}
if (test.mode === 'todo') {
await (0, _state.dispatch)({
name: 'test_todo',
test
});
return;
}
const {afterEach, beforeEach} = (0, _utils.getEachHooksForTest)(test);
for (const hook of beforeEach) {
if (test.errors.length) {
// If any of the before hooks failed already, we don't run any
// hooks after that.
break;
}
await _callCircusHook({
hook,
test,
testContext
});
}
await _callCircusTest(test, testContext);
for (const hook of afterEach) {
await _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.
await (0, _state.dispatch)({
name: 'test_done',
test
});
};
const _callCircusHook = async ({hook, test, describeBlock, testContext}) => {
await (0, _state.dispatch)({
hook,
name: 'hook_start'
});
const timeout = hook.timeout || (0, _state.getState)().testTimeout;
try {
await (0, _utils.callAsyncCircusFn)(hook, testContext, {
isHook: true,
timeout
});
await (0, _state.dispatch)({
describeBlock,
hook,
name: 'hook_success',
test
});
} catch (error) {
await (0, _state.dispatch)({
describeBlock,
error,
hook,
name: 'hook_failure',
test
});
}
};
const _callCircusTest = async (test, testContext) => {
await (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) {
return; // We don't run the test if there's already an error in before hooks.
}
try {
await (0, _utils.callAsyncCircusFn)(test, testContext, {
isHook: false,
timeout
});
await (0, _state.dispatch)({
name: 'test_fn_success',
test
});
} catch (error) {
await (0, _state.dispatch)({
error,
name: 'test_fn_failure',
test
});
}
};
var _default = run;
exports.default = _default;

13
web/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 type { 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.AsyncEvent) => Promise<void>;
export declare const dispatchSync: (event: Circus.SyncEvent) => void;
export declare const addEventHandler: (handler: Circus.EventHandler) => void;

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

@ -0,0 +1,75 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.addEventHandler = exports.dispatchSync = 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,
hasStarted: false,
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 = async event => {
for (const handler of eventHandlers) {
await handler(event, getState());
}
};
exports.dispatch = dispatch;
const dispatchSync = event => {
for (const handler of eventHandlers) {
handler(event, getState());
}
};
exports.dispatchSync = dispatchSync;
const addEventHandler = handler => {
eventHandlers.push(handler);
};
exports.addEventHandler = addEventHandler;

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 type { Circus } from '@jest/types';
import type { TestFileEvent } from 'jest-runner';
declare const testCaseReportHandler: (testPath: string, sendMessageToJest: TestFileEvent) => (event: Circus.Event) => void;
export default testCaseReportHandler;

View file

@ -0,0 +1,28 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _utils = require('./utils');
/**
* 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 testCaseReportHandler = (testPath, sendMessageToJest) => event => {
switch (event.name) {
case 'test_done': {
const testResult = (0, _utils.makeSingleTestResult)(event.test);
const testCaseResult = (0, _utils.parseSingleTestResult)(testResult);
sendMessageToJest('test-case-result', [testPath, testCaseResult]);
break;
}
}
};
var _default = testCaseReportHandler;
exports.default = _default;

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

@ -0,0 +1,21 @@
/**
* 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 = require('expect');
import type { 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;
}
}
}

21
web/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;

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

@ -0,0 +1,33 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Circus } from '@jest/types';
import type { AssertionResult } from '@jest/test-result';
export declare const makeDescribe: (name: Circus.BlockName, parent?: Circus.DescribeBlock | undefined, mode?: void | "skip" | "only" | "todo" | undefined) => Circus.DescribeBlock;
export declare const makeTest: (fn: Circus.TestFn, mode: Circus.TestMode, name: Circus.TestName, parent: Circus.DescribeBlock, timeout: number | undefined, asyncError: Circus.Exception) => Circus.TestEntry;
declare type DescribeHooks = {
beforeAll: Array<Circus.Hook>;
afterAll: Array<Circus.Hook>;
};
export declare const getAllHooksForDescribe: (describe: Circus.DescribeBlock) => DescribeHooks;
declare type TestHooks = {
beforeEach: Array<Circus.Hook>;
afterEach: Array<Circus.Hook>;
};
export declare const getEachHooksForTest: (test: Circus.TestEntry) => TestHooks;
export declare const describeBlockHasTests: (describe: Circus.DescribeBlock) => boolean;
export declare const callAsyncCircusFn: (testOrHook: Circus.TestEntry | Circus.Hook, testContext: Circus.TestContext | undefined, { isHook, timeout }: {
isHook: boolean;
timeout: number;
}) => Promise<unknown>;
export declare const getTestDuration: (test: Circus.TestEntry) => number | null;
export declare const makeRunResult: (describeBlock: Circus.DescribeBlock, unhandledErrors: Array<Error>) => Circus.RunResult;
export declare const makeSingleTestResult: (test: Circus.TestEntry) => Circus.TestResult;
export declare const getTestID: (test: Circus.TestEntry) => string;
export declare const addErrorToEachTestUnderDescribe: (describeBlock: Circus.DescribeBlock, error: Circus.Exception, asyncError: Circus.Exception) => void;
export declare function invariant(condition: unknown, message?: string): asserts condition;
export declare const parseSingleTestResult: (testResult: Circus.TestResult) => AssertionResult;
export {};

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

@ -0,0 +1,512 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.invariant = invariant;
exports.parseSingleTestResult = exports.addErrorToEachTestUnderDescribe = exports.getTestID = exports.makeSingleTestResult = exports.makeRunResult = exports.getTestDuration = exports.callAsyncCircusFn = exports.describeBlockHasTests = exports.getEachHooksForTest = exports.getAllHooksForDescribe = exports.makeTest = exports.makeDescribe = void 0;
var path = _interopRequireWildcard(require('path'));
var _jestUtil = require('jest-util');
var _isGeneratorFn = _interopRequireDefault(require('is-generator-fn'));
var _co = _interopRequireDefault(require('co'));
var _dedent = _interopRequireDefault(require('dedent'));
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};
}
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;
}
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;
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
const stackUtils = new _stackUtils.default({
cwd: 'A path that does not exist'
});
const jestEachBuildDir = path.dirname(require.resolve('jest-each'));
const makeDescribe = (name, parent, mode) => {
let _mode = mode;
if (parent && !mode) {
// If not set explicitly, inherit from the parent describe.
_mode = parent.mode;
}
return {
type: 'describeBlock',
// eslint-disable-next-line sort-keys
children: [],
hooks: [],
mode: _mode,
name: (0, _jestUtil.convertDescriptorToString)(name),
parent,
tests: []
};
};
exports.makeDescribe = makeDescribe;
const makeTest = (fn, mode, name, parent, timeout, asyncError) => ({
type: 'test',
// eslint-disable-next-line sort-keys
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 {hasFocusedTests, testNamePattern} = (0, _state.getState)();
return describeBlock.children.some(child =>
child.type === 'describeBlock'
? hasEnabledTest(child)
: !(
child.mode === 'skip' ||
(hasFocusedTests && child.mode !== 'only') ||
(testNamePattern && !testNamePattern.test(getTestID(child)))
)
);
};
const getAllHooksForDescribe = describe => {
const result = {
afterAll: [],
beforeAll: []
};
if (hasEnabledTest(describe)) {
for (const hook of describe.hooks) {
switch (hook.type) {
case 'beforeAll':
result.beforeAll.push(hook);
break;
case 'afterAll':
result.afterAll.push(hook);
break;
}
}
}
return result;
};
exports.getAllHooksForDescribe = getAllHooksForDescribe;
const getEachHooksForTest = test => {
const result = {
afterEach: [],
beforeEach: []
};
let block = test.parent;
do {
const beforeEachForCurrentBlock = []; // TODO: inline after https://github.com/microsoft/TypeScript/pull/34840 is released
let hook;
for (hook of block.hooks) {
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.
result.beforeEach = [...beforeEachForCurrentBlock, ...result.beforeEach];
} while ((block = block.parent));
return result;
};
exports.getEachHooksForTest = getEachHooksForTest;
const describeBlockHasTests = describe =>
describe.children.some(
child => child.type === 'test' || describeBlockHasTests(child)
);
exports.describeBlockHasTests = describeBlockHasTests;
const _makeTimeoutMessage = (timeout, isHook) =>
`Exceeded timeout of ${(0, _jestUtil.formatTime)(timeout)} 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 {setTimeout, clearTimeout} = global;
function checkIsError(error) {
return !!(error && error.message && error.stack);
}
const callAsyncCircusFn = (testOrHook, testContext, {isHook, timeout}) => {
let timeoutID;
let completed = false;
const {fn, asyncError} = testOrHook;
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) {
let returnedValue = undefined;
const done = reason => {
// We need to keep a stack here before the promise tick
const errorAtDone = new _jestUtil.ErrorWithStack(undefined, done); // Use `Promise.resolve` to allow the event loop to go a single tick in case `done` is called synchronously
Promise.resolve().then(() => {
if (returnedValue !== undefined) {
asyncError.message = (0, _dedent.default)`
Test functions cannot both take a 'done' callback and return something. Either use a 'done' callback, or return a promise.
Returned value: ${(0, _prettyFormat.default)(returnedValue, {
maxDepth: 3
})}
`;
return reject(asyncError);
}
let errorAsErrorObject;
if (checkIsError(reason)) {
errorAsErrorObject = reason;
} else {
errorAsErrorObject = errorAtDone;
errorAtDone.message = `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();
});
};
returnedValue = fn.call(testContext, done);
return;
}
let returnedValue;
if ((0, _isGeneratorFn.default)(fn)) {
returnedValue = _co.default.wrap(fn).call({});
} else {
try {
returnedValue = fn.call(testContext);
} catch (error) {
reject(error);
return;
}
} // 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'
) {
returnedValue.then(resolve, reject);
return;
}
if (!isHook && returnedValue !== undefined) {
reject(
new Error((0, _dedent.default)`
test functions can only return Promise or undefined.
Returned value: ${(0, _prettyFormat.default)(returnedValue, {
maxDepth: 3
})}
`)
);
return;
} // Otherwise this test is synchronous, and if it didn't throw it means
// it passed.
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;
return typeof startedAt === 'number' ? jestNow() - startedAt : null;
};
exports.getTestDuration = getTestDuration;
const makeRunResult = (describeBlock, unhandledErrors) => ({
testResults: makeTestResults(describeBlock),
unhandledErrors: unhandledErrors.map(_getError).map(getErrorStack)
});
exports.makeRunResult = makeRunResult;
const makeSingleTestResult = test => {
const {includeTestLocationInResult} = (0, _state.getState)();
const testPath = [];
let parent = test;
const {status} = test;
invariant(status, 'Status should be present after tests are run.');
do {
testPath.unshift(parent.name);
} while ((parent = parent.parent));
let location = null;
if (includeTestLocationInResult) {
var _parsedLine, _parsedLine$file;
const stackLines = test.asyncError.stack.split('\n');
const stackLine = stackLines[1];
let parsedLine = stackUtils.parseLine(stackLine);
if (
(_parsedLine = parsedLine) === null || _parsedLine === void 0
? void 0
: (_parsedLine$file = _parsedLine.file) === null ||
_parsedLine$file === void 0
? void 0
: _parsedLine$file.startsWith(jestEachBuildDir)
) {
const stackLine = stackLines[4];
parsedLine = stackUtils.parseLine(stackLine);
}
if (
parsedLine &&
typeof parsedLine.column === 'number' &&
typeof parsedLine.line === 'number'
) {
location = {
column: parsedLine.column,
line: parsedLine.line
};
}
}
const errorsDetailed = test.errors.map(_getError);
return {
duration: test.duration,
errors: errorsDetailed.map(getErrorStack),
errorsDetailed,
invocations: test.invocations,
location,
status,
testPath: Array.from(testPath)
};
};
exports.makeSingleTestResult = makeSingleTestResult;
const makeTestResults = describeBlock => {
const testResults = [];
for (const child of describeBlock.children) {
switch (child.type) {
case 'describeBlock': {
testResults.push(...makeTestResults(child));
break;
}
case 'test': {
testResults.push(makeSingleTestResult(child));
break;
}
}
}
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 _getError = errors => {
let error;
let asyncError;
if (Array.isArray(errors)) {
error = errors[0];
asyncError = errors[1];
} else {
error = errors;
asyncError = new Error();
}
if (error && (error.stack || error.message)) {
return error;
}
asyncError.message = `thrown: ${(0, _prettyFormat.default)(error, {
maxDepth: 3
})}`;
return asyncError;
};
const getErrorStack = error => error.stack || error.message;
const addErrorToEachTestUnderDescribe = (describeBlock, error, asyncError) => {
for (const child of describeBlock.children) {
switch (child.type) {
case 'describeBlock':
addErrorToEachTestUnderDescribe(child, error, asyncError);
break;
case 'test':
child.errors.push([error, asyncError]);
break;
}
}
};
exports.addErrorToEachTestUnderDescribe = addErrorToEachTestUnderDescribe;
function invariant(condition, message) {
if (!condition) {
throw new Error(message);
}
}
const parseSingleTestResult = testResult => {
let status;
if (testResult.status === 'skip') {
status = 'pending';
} else if (testResult.status === 'todo') {
status = 'todo';
} else if (testResult.errors.length > 0) {
status = 'failed';
} else {
status = 'passed';
}
const ancestorTitles = testResult.testPath.filter(
name => name !== _state.ROOT_DESCRIBE_BLOCK_NAME
);
const title = ancestorTitles.pop();
return {
ancestorTitles,
duration: testResult.duration,
failureDetails: testResult.errorsDetailed,
failureMessages: Array.from(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]
};
};
exports.parseSingleTestResult = parseSingleTestResult;