Add node modules and new code for release (#57)

Co-authored-by: taakleton <taakleton@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2022-01-26 17:16:26 -05:00
committed by GitHub
parent da63a48ad7
commit a517f2ff65
8435 changed files with 1764387 additions and 7 deletions

21
node_modules/jest-jasmine2/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,8 @@
/**
* 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.
*/
export default class ExpectationFailed extends Error {
}

16
node_modules/jest-jasmine2/build/ExpectationFailed.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
/**
* 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.
*/
class ExpectationFailed extends Error {}
exports.default = ExpectationFailed;

17
node_modules/jest-jasmine2/build/PCancelable.d.ts generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* 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.
*/
export default class PCancelable<T> extends Promise<T> {
private _pending;
private _canceled;
private _promise;
private _cancel?;
private _reject;
constructor(executor: (onCancel: (cancelHandler: () => void) => void, resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void);
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
catch<TResult>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
cancel(): void;
}

97
node_modules/jest-jasmine2/build/PCancelable.js generated vendored Normal file
View File

@ -0,0 +1,97 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
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 _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*/
class CancelError extends Error {
constructor() {
super('Promise was canceled');
this.name = 'CancelError';
}
}
class PCancelable extends Promise {
constructor(executor) {
super(resolve => resolve());
_defineProperty(this, '_pending', true);
_defineProperty(this, '_canceled', false);
_defineProperty(this, '_promise', void 0);
_defineProperty(this, '_cancel', void 0);
_defineProperty(this, '_reject', () => {});
this._promise = new Promise((resolve, reject) => {
this._reject = reject;
return executor(
fn => {
this._cancel = fn;
},
val => {
this._pending = false;
resolve(val);
},
err => {
this._pending = false;
reject(err);
}
);
});
}
then(onFulfilled, onRejected) {
return this._promise.then(onFulfilled, onRejected);
}
catch(onRejected) {
return this._promise.catch(onRejected);
}
cancel() {
if (!this._pending || this._canceled) {
return;
}
if (typeof this._cancel === 'function') {
try {
this._cancel();
} catch (err) {
this._reject(err);
}
}
this._canceled = true;
this._reject(new CancelError());
}
}
exports.default = PCancelable;

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 { DiffOptions } from 'jest-matcher-utils';
import type { AssertionErrorWithStack } from './types';
declare function assertionErrorMessage(error: AssertionErrorWithStack, options: DiffOptions): string;
export default assertionErrorMessage;

View File

@ -0,0 +1,156 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _chalk = _interopRequireDefault(require('chalk'));
var _jestMatcherUtils = require('jest-matcher-utils');
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 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 buildHintString(hint) {
return hint ? hint + '\n\n' : '';
}
var _default = assertionErrorMessage;
exports.default = _default;

9
node_modules/jest-jasmine2/build/each.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 { JestEnvironment } from '@jest/environment';
declare const _default: (environment: JestEnvironment) => void;
export default _default;

46
node_modules/jest-jasmine2/build/each.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _jestEach = require('jest-each');
/**
* 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 = environment => {
environment.global.it.each = (0, _jestEach.bind)(environment.global.it);
environment.global.fit.each = (0, _jestEach.bind)(environment.global.fit);
environment.global.xit.each = (0, _jestEach.bind)(environment.global.xit);
environment.global.describe.each = (0, _jestEach.bind)(
environment.global.describe,
false
);
environment.global.xdescribe.each = (0, _jestEach.bind)(
environment.global.xdescribe,
false
);
environment.global.fdescribe.each = (0, _jestEach.bind)(
environment.global.fdescribe,
false
);
environment.global.it.concurrent.each = (0, _jestEach.bind)(
environment.global.it.concurrent,
false
);
environment.global.it.concurrent.only.each = (0, _jestEach.bind)(
environment.global.it.concurrent.only,
false
);
environment.global.it.concurrent.skip.each = (0, _jestEach.bind)(
environment.global.it.concurrent.skip,
false
);
};
exports.default = _default;

8
node_modules/jest-jasmine2/build/errorOnPrivate.d.ts generated vendored Normal file
View File

@ -0,0 +1,8 @@
/**
* 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 { Global } from '@jest/types';
export declare function installErrorOnPrivate(global: Global.Global): void;

66
node_modules/jest-jasmine2/build/errorOnPrivate.js generated vendored Normal file
View File

@ -0,0 +1,66 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.installErrorOnPrivate = installErrorOnPrivate;
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.
*/
// prettier-ignore
const disabledGlobals = {
fail: 'Illegal usage of global `fail`, prefer throwing an error, or the `done.fail` callback.',
pending: 'Illegal usage of global `pending`, prefer explicitly skipping a test using `test.skip`',
spyOn: 'Illegal usage of global `spyOn`, prefer `jest.spyOn`.',
spyOnProperty: 'Illegal usage of global `spyOnProperty`, prefer `jest.spyOn`.'
};
// prettier-ignore
const disabledJasmineMethods = {
addMatchers: 'Illegal usage of `jasmine.addMatchers`, prefer `expect.extends`.',
any: 'Illegal usage of `jasmine.any`, prefer `expect.any`.',
anything: 'Illegal usage of `jasmine.anything`, prefer `expect.anything`.',
arrayContaining: 'Illegal usage of `jasmine.arrayContaining`, prefer `expect.arrayContaining`.',
createSpy: 'Illegal usage of `jasmine.createSpy`, prefer `jest.fn`.',
objectContaining: 'Illegal usage of `jasmine.objectContaining`, prefer `expect.objectContaining`.',
stringMatching: 'Illegal usage of `jasmine.stringMatching`, prefer `expect.stringMatching`.'
};
function installErrorOnPrivate(global) {
const jasmine = global.jasmine;
Object.keys(disabledGlobals).forEach(functionName => {
global[functionName] = () => {
throwAtFunction(disabledGlobals[functionName], global[functionName]);
};
});
Object.keys(disabledJasmineMethods).forEach(methodName => {
// @ts-expect-error
jasmine[methodName] = () => {
throwAtFunction(disabledJasmineMethods[methodName], jasmine[methodName]);
};
});
function set() {
throwAtFunction(
'Illegal usage of `jasmine.DEFAULT_TIMEOUT_INTERVAL`, prefer `jest.setTimeout`.',
set
);
}
const original = jasmine.DEFAULT_TIMEOUT_INTERVAL;
Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
configurable: true,
enumerable: true,
get: () => original,
set
});
}
function throwAtFunction(message, fn) {
throw new _jestUtil.ErrorWithStack(message, fn);
}

View File

@ -0,0 +1,16 @@
/**
* 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 { FailedAssertion } from '@jest/test-result';
export declare type Options = {
matcherName: string;
passed: boolean;
actual?: any;
error?: any;
expected?: any;
message?: string | null;
};
export default function expectationResultFactory(options: Options, initError?: Error): FailedAssertion;

View File

@ -0,0 +1,97 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = expectationResultFactory;
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.
*/
function messageFormatter({error, message, passed}) {
if (passed) {
return 'Passed.';
}
if (message) {
return message;
}
if (typeof error === 'string') {
return error;
}
if (
// duck-type Error, see #2549
error &&
typeof error === 'object' &&
typeof error.message === 'string' &&
typeof error.name === 'string'
) {
if (error.message === '') {
return error.name;
}
return `${error.name}: ${error.message}`;
}
return `thrown: ${(0, _prettyFormat.default)(error, {
maxDepth: 3
})}`;
}
function stackFormatter(options, initError, errorMessage) {
if (options.passed) {
return '';
}
if (options.error) {
if (typeof options.error.stack === 'string') {
return options.error.stack;
}
if (options.error === errorMessage) {
return errorMessage;
}
}
if (initError) {
return errorMessage.trimRight() + '\n\n' + initError.stack;
}
return new Error(errorMessage).stack;
}
function expectationResultFactory(options, initError) {
const message = messageFormatter(options);
const stack = stackFormatter(options, initError, message);
if (options.passed) {
return {
error: options.error,
matcherName: options.matcherName,
message,
passed: options.passed,
stack
};
}
return {
actual: options.actual,
error: options.error,
expected: options.expected,
matcherName: options.matcherName,
message,
passed: options.passed,
stack
};
}

16
node_modules/jest-jasmine2/build/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,16 @@
/**
* 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 { JestEnvironment } from '@jest/environment';
import type { TestResult } from '@jest/test-result';
import type { Config } from '@jest/types';
import type { RuntimeType as Runtime } from 'jest-runtime';
import type { Jasmine as JestJasmine } from './types';
declare function jasmine2(globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string): Promise<TestResult>;
declare namespace jasmine2 {
type Jasmine = JestJasmine;
}
export = jasmine2;

265
node_modules/jest-jasmine2/build/index.js generated vendored Normal file
View File

@ -0,0 +1,265 @@
'use strict';
var path = _interopRequireWildcard(require('path'));
var _sourceMap = require('@jest/source-map');
var _each = _interopRequireDefault(require('./each'));
var _errorOnPrivate = require('./errorOnPrivate');
var _jasmineAsyncInstall = _interopRequireDefault(
require('./jasmineAsyncInstall')
);
var _reporter = _interopRequireDefault(require('./reporter'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const JASMINE = require.resolve('./jasmine/jasmineLight');
const jestEachBuildDir = path.dirname(require.resolve('jest-each'));
async function jasmine2(globalConfig, config, environment, runtime, testPath) {
var _runtime$unstable_sho2;
const reporter = new _reporter.default(globalConfig, config, testPath);
const jasmineFactory = runtime.requireInternalModule(JASMINE);
const jasmine = jasmineFactory.create({
process,
testPath,
testTimeout: globalConfig.testTimeout
});
const env = jasmine.getEnv();
const jasmineInterface = jasmineFactory._interface(jasmine, env);
Object.assign(environment.global, jasmineInterface);
env.addReporter(jasmineInterface.jsApiReporter); // TODO: Remove config option if V8 exposes some way of getting location of caller
// in a future version
if (config.testLocationInResults === true) {
function wrapIt(original) {
const wrapped = (testName, fn, timeout) => {
var _stack$getFileName;
const sourcemaps = runtime.getSourceMaps();
let stack = (0, _sourceMap.getCallsite)(1, sourcemaps);
const it = original(testName, fn, timeout);
if (
(_stack$getFileName = stack.getFileName()) === null ||
_stack$getFileName === void 0
? void 0
: _stack$getFileName.startsWith(jestEachBuildDir)
) {
stack = (0, _sourceMap.getCallsite)(4, sourcemaps);
} // @ts-expect-error
it.result.__callsite = stack;
return it;
};
return wrapped;
}
environment.global.it = wrapIt(environment.global.it);
environment.global.xit = wrapIt(environment.global.xit);
environment.global.fit = wrapIt(environment.global.fit);
}
(0, _jasmineAsyncInstall.default)(globalConfig, environment.global);
(0, _each.default)(environment);
environment.global.test = environment.global.it;
environment.global.it.only = environment.global.fit;
environment.global.it.todo = env.todo;
environment.global.it.skip = environment.global.xit;
environment.global.xtest = environment.global.xit;
environment.global.describe.skip = environment.global.xdescribe;
environment.global.describe.only = environment.global.fdescribe;
if (config.timers === 'fake' || config.timers === 'legacy') {
environment.fakeTimers.useFakeTimers();
} else if (config.timers === 'modern') {
environment.fakeTimersModern.useFakeTimers();
}
env.beforeEach(() => {
if (config.resetModules) {
runtime.resetModules();
}
if (config.clearMocks) {
runtime.clearAllMocks();
}
if (config.resetMocks) {
runtime.resetAllMocks();
if (config.timers === 'fake' || config.timers === 'legacy') {
environment.fakeTimers.useFakeTimers();
}
}
if (config.restoreMocks) {
runtime.restoreAllMocks();
}
});
env.addReporter(reporter);
runtime
.requireInternalModule(path.resolve(__dirname, './jestExpect.js'))
.default({
expand: globalConfig.expand
});
if (globalConfig.errorOnDeprecated) {
(0, _errorOnPrivate.installErrorOnPrivate)(environment.global);
} else {
Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
configurable: true,
enumerable: true,
get() {
return this._DEFAULT_TIMEOUT_INTERVAL;
},
set(value) {
this._DEFAULT_TIMEOUT_INTERVAL = value;
}
});
}
const snapshotState = runtime
.requireInternalModule(path.resolve(__dirname, './setup_jest_globals.js'))
.default({
config,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
testPath
});
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);
}
}
if (globalConfig.enabledTestsMap) {
env.specFilter = spec => {
const suiteMap =
globalConfig.enabledTestsMap &&
globalConfig.enabledTestsMap[spec.result.testPath];
return (suiteMap && suiteMap[spec.result.fullName]) || false;
};
} else if (globalConfig.testNamePattern) {
const testNameRegex = new RegExp(globalConfig.testNamePattern, 'i');
env.specFilter = spec => testNameRegex.test(spec.getFullName());
} // 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);
}
await env.execute();
const results = await reporter.getResults();
return addSnapshotData(results, snapshotState);
}
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 = jasmine2;

10
node_modules/jest-jasmine2/build/isError.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.
*/
export default function isError(potentialError: any): {
isError: boolean;
message: string | null;
};

36
node_modules/jest-jasmine2/build/isError.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = isError;
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.
*/
function isError(potentialError) { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
// duck-type Error, see #2549
const isError =
potentialError !== null &&
typeof potentialError === 'object' &&
typeof potentialError.message === 'string' &&
typeof potentialError.name === 'string';
const message = isError
? null
: `Failed: ${(0, _prettyFormat.default)(potentialError, {
maxDepth: 3
})}`;
return {
isError,
message
};
}

View File

@ -0,0 +1,25 @@
/**
* 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.
*
*/
export declare type Context = {
object: unknown;
args: Array<unknown>;
returnValue?: unknown;
};
declare class CallTracker {
track: (context: Context) => void;
any: () => boolean;
count: () => number;
argsFor: (index: number) => Array<unknown>;
all: () => Array<Context>;
allArgs: () => Array<unknown>;
first: () => Context;
mostRecent: () => Context;
reset: () => void;
constructor();
}
export default CallTracker;

121
node_modules/jest-jasmine2/build/jasmine/CallTracker.js generated vendored Normal file
View File

@ -0,0 +1,121 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
class CallTracker {
constructor() {
_defineProperty(this, 'track', void 0);
_defineProperty(this, 'any', void 0);
_defineProperty(this, 'count', void 0);
_defineProperty(this, 'argsFor', void 0);
_defineProperty(this, 'all', void 0);
_defineProperty(this, 'allArgs', void 0);
_defineProperty(this, 'first', void 0);
_defineProperty(this, 'mostRecent', void 0);
_defineProperty(this, 'reset', void 0);
let calls = [];
this.track = function (context) {
calls.push(context);
};
this.any = function () {
return !!calls.length;
};
this.count = function () {
return calls.length;
};
this.argsFor = function (index) {
const call = calls[index];
return call ? call.args : [];
};
this.all = function () {
return calls;
};
this.allArgs = function () {
const callArgs = [];
for (let i = 0; i < calls.length; i++) {
callArgs.push(calls[i].args);
}
return callArgs;
};
this.first = function () {
return calls[0];
};
this.mostRecent = function () {
return calls[calls.length - 1];
};
this.reset = function () {
calls = [];
};
}
}
var _default = CallTracker;
exports.default = _default;

43
node_modules/jest-jasmine2/build/jasmine/Env.d.ts generated vendored Normal file
View File

@ -0,0 +1,43 @@
/**
* 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 { QueueableFn } from '../queueRunner';
import type { AssertionErrorWithStack, Jasmine, Reporter, SpecDefinitionsFn, Spy } from '../types';
import type { default as Spec } from './Spec';
import type Suite from './Suite';
export default function (j$: Jasmine): {
new (_options?: Record<string, unknown> | undefined): {
specFilter: (spec: Spec) => boolean;
catchExceptions: (value: unknown) => boolean;
throwOnExpectationFailure: (value: unknown) => void;
catchingExceptions: () => boolean;
topSuite: () => Suite;
fail: (error: Error | AssertionErrorWithStack) => void;
pending: (message: string) => void;
afterAll: (afterAllFunction: QueueableFn['fn'], timeout?: number | undefined) => void;
fit: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec;
throwingExpectationFailures: () => boolean;
randomizeTests: (value: unknown) => void;
randomTests: () => boolean;
seed: (value: unknown) => unknown;
execute: (runnablesToRun?: string[] | undefined, suiteTree?: Suite | undefined) => Promise<void>;
fdescribe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite;
spyOn: (obj: Record<string, Spy>, methodName: string, accessType?: "configurable" | "enumerable" | "value" | "writable" | "get" | "set" | undefined) => Spy;
beforeEach: (beforeEachFunction: QueueableFn['fn'], timeout?: number | undefined) => void;
afterEach: (afterEachFunction: QueueableFn['fn'], timeout?: number | undefined) => void;
clearReporters: () => void;
addReporter: (reporterToAdd: Reporter) => void;
it: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec;
xdescribe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite;
xit: (description: string, fn: QueueableFn['fn'], timeout?: number | undefined) => Spec;
beforeAll: (beforeAllFunction: QueueableFn['fn'], timeout?: number | undefined) => void;
todo: () => Spec;
provideFallbackReporter: (reporterToAdd: Reporter) => void;
allowRespy: (allow: boolean) => void;
describe: (description: string, specDefinitions: SpecDefinitionsFn) => Suite;
};
};

745
node_modules/jest-jasmine2/build/jasmine/Env.js generated vendored Normal file
View File

@ -0,0 +1,745 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = _default;
var _assert = require('assert');
var _chalk = _interopRequireDefault(require('chalk'));
var _jestMessageUtil = require('jest-message-util');
var _jestUtil = require('jest-util');
var _assertionErrorMessage = _interopRequireDefault(
require('../assertionErrorMessage')
);
var _isError = _interopRequireDefault(require('../isError'));
var _queueRunner = _interopRequireDefault(require('../queueRunner'));
var _treeProcessor = _interopRequireDefault(require('../treeProcessor'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _default(j$) {
var _temp;
return (
(_temp = class Env {
constructor(_options) {
_defineProperty(this, 'specFilter', void 0);
_defineProperty(this, 'catchExceptions', void 0);
_defineProperty(this, 'throwOnExpectationFailure', void 0);
_defineProperty(this, 'catchingExceptions', void 0);
_defineProperty(this, 'topSuite', void 0);
_defineProperty(this, 'fail', void 0);
_defineProperty(this, 'pending', void 0);
_defineProperty(this, 'afterAll', void 0);
_defineProperty(this, 'fit', void 0);
_defineProperty(this, 'throwingExpectationFailures', void 0);
_defineProperty(this, 'randomizeTests', void 0);
_defineProperty(this, 'randomTests', void 0);
_defineProperty(this, 'seed', void 0);
_defineProperty(this, 'execute', void 0);
_defineProperty(this, 'fdescribe', void 0);
_defineProperty(this, 'spyOn', void 0);
_defineProperty(this, 'beforeEach', void 0);
_defineProperty(this, 'afterEach', void 0);
_defineProperty(this, 'clearReporters', void 0);
_defineProperty(this, 'addReporter', void 0);
_defineProperty(this, 'it', void 0);
_defineProperty(this, 'xdescribe', void 0);
_defineProperty(this, 'xit', void 0);
_defineProperty(this, 'beforeAll', void 0);
_defineProperty(this, 'todo', void 0);
_defineProperty(this, 'provideFallbackReporter', void 0);
_defineProperty(this, 'allowRespy', void 0);
_defineProperty(this, 'describe', void 0);
let totalSpecsDefined = 0;
let catchExceptions = true;
const realSetTimeout = global.setTimeout;
const realClearTimeout = global.clearTimeout;
const runnableResources = {};
const currentlyExecutingSuites = [];
let currentSpec = null;
let throwOnExpectationFailure = false;
let random = false;
let seed = null;
let nextSpecId = 0;
let nextSuiteId = 0;
const getNextSpecId = function () {
return 'spec' + nextSpecId++;
};
const getNextSuiteId = function () {
return 'suite' + nextSuiteId++;
};
const topSuite = new j$.Suite({
id: getNextSuiteId(),
description: '',
getTestPath() {
return j$.testPath;
}
});
let currentDeclarationSuite = topSuite;
const currentSuite = function () {
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
};
const currentRunnable = function () {
return currentSpec || currentSuite();
};
const reporter = new j$.ReportDispatcher([
'jasmineStarted',
'jasmineDone',
'suiteStarted',
'suiteDone',
'specStarted',
'specDone'
]);
this.specFilter = function () {
return true;
};
const defaultResourcesForRunnable = function (id, _parentRunnableId) {
const resources = {
spies: []
};
runnableResources[id] = resources;
};
const clearResourcesForRunnable = function (id) {
spyRegistry.clearSpies();
delete runnableResources[id];
};
const beforeAndAfterFns = function (suite) {
return function () {
let afters = [];
let befores = [];
while (suite) {
befores = befores.concat(suite.beforeFns);
afters = afters.concat(suite.afterFns);
suite = suite.parentSuite;
}
return {
befores: befores.reverse(),
afters
};
};
};
const getSpecName = function (spec, suite) {
const fullName = [spec.description];
const suiteFullName = suite.getFullName();
if (suiteFullName !== '') {
fullName.unshift(suiteFullName);
}
return fullName.join(' ');
};
this.catchExceptions = function (value) {
catchExceptions = !!value;
return catchExceptions;
};
this.catchingExceptions = function () {
return catchExceptions;
};
this.throwOnExpectationFailure = function (value) {
throwOnExpectationFailure = !!value;
};
this.throwingExpectationFailures = function () {
return throwOnExpectationFailure;
};
this.randomizeTests = function (value) {
random = !!value;
};
this.randomTests = function () {
return random;
};
this.seed = function (value) {
if (value) {
seed = value;
}
return seed;
};
const queueRunnerFactory = options => {
options.clearTimeout = realClearTimeout;
options.fail = this.fail;
options.setTimeout = realSetTimeout;
return (0, _queueRunner.default)(options);
};
this.topSuite = function () {
return topSuite;
};
const uncaught = err => {
if (currentSpec) {
currentSpec.onException(err);
currentSpec.cancel();
} else {
console.error('Unhandled error');
console.error(err.stack);
}
};
let oldListenersException;
let oldListenersRejection;
const executionSetup = function () {
// Need to ensure we are the only ones handling these exceptions.
oldListenersException = process
.listeners('uncaughtException')
.slice();
oldListenersRejection = process
.listeners('unhandledRejection')
.slice();
j$.process.removeAllListeners('uncaughtException');
j$.process.removeAllListeners('unhandledRejection');
j$.process.on('uncaughtException', uncaught);
j$.process.on('unhandledRejection', uncaught);
};
const executionTeardown = function () {
j$.process.removeListener('uncaughtException', uncaught);
j$.process.removeListener('unhandledRejection', uncaught); // restore previous exception handlers
oldListenersException.forEach(listener => {
j$.process.on('uncaughtException', listener);
});
oldListenersRejection.forEach(listener => {
j$.process.on('unhandledRejection', listener);
});
};
this.execute = async function (runnablesToRun, suiteTree = topSuite) {
if (!runnablesToRun) {
if (focusedRunnables.length) {
runnablesToRun = focusedRunnables;
} else {
runnablesToRun = [suiteTree.id];
}
}
if (currentlyExecutingSuites.length === 0) {
executionSetup();
}
const lastDeclarationSuite = currentDeclarationSuite;
await (0, _treeProcessor.default)({
nodeComplete(suite) {
if (!suite.disabled) {
clearResourcesForRunnable(suite.id);
}
currentlyExecutingSuites.pop();
if (suite === topSuite) {
reporter.jasmineDone({
failedExpectations: topSuite.result.failedExpectations
});
} else {
reporter.suiteDone(suite.getResult());
}
},
nodeStart(suite) {
currentlyExecutingSuites.push(suite);
defaultResourcesForRunnable(
suite.id,
suite.parentSuite && suite.parentSuite.id
);
if (suite === topSuite) {
reporter.jasmineStarted({
totalSpecsDefined
});
} else {
reporter.suiteStarted(suite.result);
}
},
queueRunnerFactory,
runnableIds: runnablesToRun,
tree: suiteTree
});
currentDeclarationSuite = lastDeclarationSuite;
if (currentlyExecutingSuites.length === 0) {
executionTeardown();
}
};
this.addReporter = function (reporterToAdd) {
reporter.addReporter(reporterToAdd);
};
this.provideFallbackReporter = function (reporterToAdd) {
reporter.provideFallbackReporter(reporterToAdd);
};
this.clearReporters = function () {
reporter.clearReporters();
};
const spyRegistry = new j$.SpyRegistry({
currentSpies() {
if (!currentRunnable()) {
throw new Error(
'Spies must be created in a before function or a spec'
);
}
return runnableResources[currentRunnable().id].spies;
}
});
this.allowRespy = function (allow) {
spyRegistry.allowRespy(allow);
};
this.spyOn = function (...args) {
return spyRegistry.spyOn.apply(spyRegistry, args);
};
const suiteFactory = function (description) {
const suite = new j$.Suite({
id: getNextSuiteId(),
description,
parentSuite: currentDeclarationSuite,
throwOnExpectationFailure,
getTestPath() {
return j$.testPath;
}
});
return suite;
};
this.describe = function (description, specDefinitions) {
const suite = suiteFactory(description);
if (specDefinitions === undefined) {
throw new Error(
`Missing second argument. It must be a callback function.`
);
}
if (typeof specDefinitions !== 'function') {
throw new Error(
`Invalid second argument, ${specDefinitions}. It must be a callback function.`
);
}
if (specDefinitions.length > 0) {
throw new Error('describe does not expect any arguments');
}
if (currentDeclarationSuite.markedPending) {
suite.pend();
}
if (currentDeclarationSuite.markedTodo) {
// @ts-expect-error TODO Possible error: Suite does not have todo method
suite.todo();
}
addSpecsToSuite(suite, specDefinitions);
return suite;
};
this.xdescribe = function (description, specDefinitions) {
const suite = suiteFactory(description);
suite.pend();
addSpecsToSuite(suite, specDefinitions);
return suite;
};
const focusedRunnables = [];
this.fdescribe = function (description, specDefinitions) {
const suite = suiteFactory(description);
suite.isFocused = true;
focusedRunnables.push(suite.id);
unfocusAncestor();
addSpecsToSuite(suite, specDefinitions);
return suite;
};
const addSpecsToSuite = (suite, specDefinitions) => {
const parentSuite = currentDeclarationSuite;
parentSuite.addChild(suite);
currentDeclarationSuite = suite;
let declarationError = undefined;
let describeReturnValue;
try {
describeReturnValue = specDefinitions.call(suite);
} catch (e) {
declarationError = e;
} // TODO throw in Jest 25: declarationError = new Error
if ((0, _jestUtil.isPromise)(describeReturnValue)) {
console.log(
(0, _jestMessageUtil.formatExecError)(
new Error(
_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.'
)
),
{
rootDir: '',
testMatch: []
},
{
noStackTrace: false
}
)
);
} else if (describeReturnValue !== undefined) {
console.log(
(0, _jestMessageUtil.formatExecError)(
new Error(
_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.'
)
),
{
rootDir: '',
testMatch: []
},
{
noStackTrace: false
}
)
);
}
if (declarationError) {
this.it('encountered a declaration exception', () => {
throw declarationError;
});
}
currentDeclarationSuite = parentSuite;
};
function findFocusedAncestor(suite) {
while (suite) {
if (suite.isFocused) {
return suite.id;
}
suite = suite.parentSuite;
}
return null;
}
function unfocusAncestor() {
const focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
if (focusedAncestor) {
for (let i = 0; i < focusedRunnables.length; i++) {
if (focusedRunnables[i] === focusedAncestor) {
focusedRunnables.splice(i, 1);
break;
}
}
}
}
const specFactory = (description, fn, suite, timeout) => {
totalSpecsDefined++;
const spec = new j$.Spec({
id: getNextSpecId(),
beforeAndAfterFns: beforeAndAfterFns(suite),
resultCallback: specResultCallback,
getSpecName(spec) {
return getSpecName(spec, suite);
},
getTestPath() {
return j$.testPath;
},
onStart: specStarted,
description,
queueRunnerFactory,
userContext() {
return suite.clonedSharedUserContext();
},
queueableFn: {
fn,
timeout() {
return timeout || j$._DEFAULT_TIMEOUT_INTERVAL;
}
},
throwOnExpectationFailure
});
if (!this.specFilter(spec)) {
spec.disable();
}
return spec;
function specResultCallback(result) {
clearResourcesForRunnable(spec.id);
currentSpec = null;
reporter.specDone(result);
}
function specStarted(spec) {
currentSpec = spec;
defaultResourcesForRunnable(spec.id, suite.id);
reporter.specStarted(spec.result);
}
};
this.it = function (description, fn, timeout) {
if (typeof description !== 'string') {
throw new Error(
`Invalid first argument, ${description}. It must be a string.`
);
}
if (fn === undefined) {
throw new Error(
'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.'
);
}
if (typeof fn !== 'function') {
throw new Error(
`Invalid second argument, ${fn}. It must be a callback function.`
);
}
const spec = specFactory(
description,
fn,
currentDeclarationSuite,
timeout
);
if (currentDeclarationSuite.markedPending) {
spec.pend();
} // When a test is defined inside another, jasmine will not run it.
// This check throws an error to warn the user about the edge-case.
if (currentSpec !== null) {
throw new Error(
`Tests cannot be nested. Test "${spec.description}" cannot run because it is nested within "${currentSpec.description}".`
);
}
currentDeclarationSuite.addChild(spec);
return spec;
};
this.xit = function (...args) {
const spec = this.it.apply(this, args);
spec.pend('Temporarily disabled with xit');
return spec;
};
this.todo = function () {
const description = arguments[0];
if (arguments.length !== 1 || typeof description !== 'string') {
throw new _jestUtil.ErrorWithStack(
'Todo must be called with only a description.',
this.todo
);
}
const spec = specFactory(
description,
() => {},
currentDeclarationSuite
);
spec.todo();
currentDeclarationSuite.addChild(spec);
return spec;
};
this.fit = function (description, fn, timeout) {
const spec = specFactory(
description,
fn,
currentDeclarationSuite,
timeout
);
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
unfocusAncestor();
return spec;
};
this.beforeEach = function (beforeEachFunction, timeout) {
currentDeclarationSuite.beforeEach({
fn: beforeEachFunction,
timeout() {
return timeout || j$._DEFAULT_TIMEOUT_INTERVAL;
}
});
};
this.beforeAll = function (beforeAllFunction, timeout) {
currentDeclarationSuite.beforeAll({
fn: beforeAllFunction,
timeout() {
return timeout || j$._DEFAULT_TIMEOUT_INTERVAL;
}
});
};
this.afterEach = function (afterEachFunction, timeout) {
currentDeclarationSuite.afterEach({
fn: afterEachFunction,
timeout() {
return timeout || j$._DEFAULT_TIMEOUT_INTERVAL;
}
});
};
this.afterAll = function (afterAllFunction, timeout) {
currentDeclarationSuite.afterAll({
fn: afterAllFunction,
timeout() {
return timeout || j$._DEFAULT_TIMEOUT_INTERVAL;
}
});
};
this.pending = function (message) {
let fullMessage = j$.Spec.pendingSpecExceptionMessage;
if (message) {
fullMessage += message;
}
throw fullMessage;
};
this.fail = function (error) {
let checkIsError;
let message;
if (
error instanceof _assert.AssertionError ||
(error && error.name === _assert.AssertionError.name)
) {
checkIsError = false; // @ts-expect-error TODO Possible error: j$.Spec does not have expand property
message = (0, _assertionErrorMessage.default)(error, {
expand: j$.Spec.expand
});
} else {
const check = (0, _isError.default)(error);
checkIsError = check.isError;
message = check.message;
}
const errorAsErrorObject = checkIsError ? error : new Error(message);
const runnable = currentRunnable();
if (!runnable) {
errorAsErrorObject.message =
'Caught error after test environment was torn down\n\n' +
errorAsErrorObject.message;
throw errorAsErrorObject;
}
runnable.addExpectationResult(false, {
matcherName: '',
passed: false,
expected: '',
actual: '',
message,
error: errorAsErrorObject
});
};
}
}),
_temp
);
}

View File

@ -0,0 +1,31 @@
/**
* 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 { Reporter, RunDetails } from '../types';
import type { SpecResult } from './Spec';
import type { SuiteResult } from './Suite';
import type Timer from './Timer';
export default class JsApiReporter implements Reporter {
started: boolean;
finished: boolean;
runDetails: RunDetails;
jasmineStarted: (runDetails: RunDetails) => void;
jasmineDone: (runDetails: RunDetails) => void;
status: () => unknown;
executionTime: () => unknown;
suiteStarted: (result: SuiteResult) => void;
suiteDone: (result: SuiteResult) => void;
suiteResults: (index: number, length: number) => Array<SuiteResult>;
suites: () => Record<string, SuiteResult>;
specResults: (index: number, length: number) => Array<SpecResult>;
specDone: (result: SpecResult) => void;
specs: () => Array<SpecResult>;
specStarted: (spec: SpecResult) => void;
constructor(options: {
timer?: Timer;
});
}

View File

@ -0,0 +1,173 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys */
const noopTimer = {
start() {},
elapsed() {
return 0;
}
};
class JsApiReporter {
constructor(options) {
_defineProperty(this, 'started', void 0);
_defineProperty(this, 'finished', void 0);
_defineProperty(this, 'runDetails', void 0);
_defineProperty(this, 'jasmineStarted', void 0);
_defineProperty(this, 'jasmineDone', void 0);
_defineProperty(this, 'status', void 0);
_defineProperty(this, 'executionTime', void 0);
_defineProperty(this, 'suiteStarted', void 0);
_defineProperty(this, 'suiteDone', void 0);
_defineProperty(this, 'suiteResults', void 0);
_defineProperty(this, 'suites', void 0);
_defineProperty(this, 'specResults', void 0);
_defineProperty(this, 'specDone', void 0);
_defineProperty(this, 'specs', void 0);
_defineProperty(this, 'specStarted', void 0);
const timer = options.timer || noopTimer;
let status = 'loaded';
this.started = false;
this.finished = false;
this.runDetails = {};
this.jasmineStarted = () => {
this.started = true;
status = 'started';
timer.start();
};
let executionTime;
function validateAfterAllExceptions({failedExpectations}) {
if (failedExpectations && failedExpectations.length > 0) {
throw failedExpectations[0];
}
}
this.jasmineDone = function (runDetails) {
validateAfterAllExceptions(runDetails);
this.finished = true;
this.runDetails = runDetails;
executionTime = timer.elapsed();
status = 'done';
};
this.status = function () {
return status;
};
const suites = [];
const suites_hash = {};
this.specStarted = function () {};
this.suiteStarted = function (result) {
suites_hash[result.id] = result;
};
this.suiteDone = function (result) {
storeSuite(result);
};
this.suiteResults = function (index, length) {
return suites.slice(index, index + length);
};
function storeSuite(result) {
suites.push(result);
suites_hash[result.id] = result;
}
this.suites = function () {
return suites_hash;
};
const specs = [];
this.specDone = function (result) {
specs.push(result);
};
this.specResults = function (index, length) {
return specs.slice(index, index + length);
};
this.specs = function () {
return specs;
};
this.executionTime = function () {
return executionTime;
};
}
}
exports.default = JsApiReporter;

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 type { Reporter, RunDetails } from '../types';
import type { SpecResult } from './Spec';
import type { SuiteResult } from './Suite';
export default class ReportDispatcher implements Reporter {
addReporter: (reporter: Reporter) => void;
provideFallbackReporter: (reporter: Reporter) => void;
clearReporters: () => void;
jasmineDone: (runDetails: RunDetails) => void;
jasmineStarted: (runDetails: RunDetails) => void;
specDone: (result: SpecResult) => void;
specStarted: (spec: SpecResult) => void;
suiteDone: (result: SuiteResult) => void;
suiteStarted: (result: SuiteResult) => void;
constructor(methods: Array<keyof Reporter>);
}

View File

@ -0,0 +1,127 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable local/prefer-spread-eventually, local/prefer-rest-params-eventually */
class ReportDispatcher {
// @ts-expect-error
// @ts-expect-error
// @ts-expect-error
// @ts-expect-error
// @ts-expect-error
// @ts-expect-error
constructor(methods) {
_defineProperty(this, 'addReporter', void 0);
_defineProperty(this, 'provideFallbackReporter', void 0);
_defineProperty(this, 'clearReporters', void 0);
_defineProperty(this, 'jasmineDone', void 0);
_defineProperty(this, 'jasmineStarted', void 0);
_defineProperty(this, 'specDone', void 0);
_defineProperty(this, 'specStarted', void 0);
_defineProperty(this, 'suiteDone', void 0);
_defineProperty(this, 'suiteStarted', void 0);
const dispatchedMethods = methods || [];
for (let i = 0; i < dispatchedMethods.length; i++) {
const method = dispatchedMethods[i];
this[method] = (function (m) {
return function () {
dispatch(m, arguments);
};
})(method);
}
let reporters = [];
let fallbackReporter = null;
this.addReporter = function (reporter) {
reporters.push(reporter);
};
this.provideFallbackReporter = function (reporter) {
fallbackReporter = reporter;
};
this.clearReporters = function () {
reporters = [];
};
return this;
function dispatch(method, args) {
if (reporters.length === 0 && fallbackReporter !== null) {
reporters.push(fallbackReporter);
}
for (let i = 0; i < reporters.length; i++) {
const reporter = reporters[i];
if (reporter[method]) {
// @ts-expect-error
reporter[method].apply(reporter, args);
}
}
}
}
}
exports.default = ReportDispatcher;

81
node_modules/jest-jasmine2/build/jasmine/Spec.d.ts generated vendored Normal file
View File

@ -0,0 +1,81 @@
/**
* 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 { FailedAssertion, Milliseconds, Status } from '@jest/test-result';
import type { Config } from '@jest/types';
import ExpectationFailed from '../ExpectationFailed';
import expectationResultFactory, { Options as ExpectationResultFactoryOptions } from '../expectationResultFactory';
import type { QueueableFn, default as queueRunner } from '../queueRunner';
import type { AssertionErrorWithStack } from '../types';
export declare type Attributes = {
id: string;
resultCallback: (result: Spec['result']) => void;
description: string;
throwOnExpectationFailure: unknown;
getTestPath: () => Config.Path;
queueableFn: QueueableFn;
beforeAndAfterFns: () => {
befores: Array<QueueableFn>;
afters: Array<QueueableFn>;
};
userContext: () => unknown;
onStart: (context: Spec) => void;
getSpecName: (spec: Spec) => string;
queueRunnerFactory: typeof queueRunner;
};
export declare type SpecResult = {
id: string;
description: string;
fullName: string;
duration?: Milliseconds;
failedExpectations: Array<FailedAssertion>;
testPath: Config.Path;
passedExpectations: Array<ReturnType<typeof expectationResultFactory>>;
pendingReason: string;
status: Status;
__callsite?: {
getColumnNumber: () => number;
getLineNumber: () => number;
};
};
export default class Spec {
id: string;
description: string;
resultCallback: (result: SpecResult) => void;
queueableFn: QueueableFn;
beforeAndAfterFns: () => {
befores: Array<QueueableFn>;
afters: Array<QueueableFn>;
};
userContext: () => unknown;
onStart: (spec: Spec) => void;
getSpecName: (spec: Spec) => string;
queueRunnerFactory: typeof queueRunner;
throwOnExpectationFailure: boolean;
initError: Error;
result: SpecResult;
disabled?: boolean;
currentRun?: ReturnType<typeof queueRunner>;
markedTodo?: boolean;
markedPending?: boolean;
expand?: boolean;
static pendingSpecExceptionMessage: string;
static isPendingSpecException(e: Error): boolean;
constructor(attrs: Attributes);
addExpectationResult(passed: boolean, data: ExpectationResultFactoryOptions, isError?: boolean): void;
execute(onComplete?: () => void, enabled?: boolean): void;
cancel(): void;
onException(error: ExpectationFailed | AssertionErrorWithStack): void;
disable(): void;
pend(message?: string): void;
todo(): void;
getResult(): SpecResult;
status(enabled?: boolean): "todo" | "passed" | "failed" | "pending" | "disabled";
isExecutable(): boolean;
getFullName(): string;
isAssertionError(error: Error): boolean;
}

298
node_modules/jest-jasmine2/build/jasmine/Spec.js generated vendored Normal file
View File

@ -0,0 +1,298 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _assert = require('assert');
var _ExpectationFailed = _interopRequireDefault(
require('../ExpectationFailed')
);
var _assertionErrorMessage = _interopRequireDefault(
require('../assertionErrorMessage')
);
var _expectationResultFactory = _interopRequireDefault(
require('../expectationResultFactory')
);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Spec {
static isPendingSpecException(e) {
return !!(
e &&
e.toString &&
e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1
);
}
constructor(attrs) {
_defineProperty(this, 'id', void 0);
_defineProperty(this, 'description', void 0);
_defineProperty(this, 'resultCallback', void 0);
_defineProperty(this, 'queueableFn', void 0);
_defineProperty(this, 'beforeAndAfterFns', void 0);
_defineProperty(this, 'userContext', void 0);
_defineProperty(this, 'onStart', void 0);
_defineProperty(this, 'getSpecName', void 0);
_defineProperty(this, 'queueRunnerFactory', void 0);
_defineProperty(this, 'throwOnExpectationFailure', void 0);
_defineProperty(this, 'initError', void 0);
_defineProperty(this, 'result', void 0);
_defineProperty(this, 'disabled', void 0);
_defineProperty(this, 'currentRun', void 0);
_defineProperty(this, 'markedTodo', void 0);
_defineProperty(this, 'markedPending', void 0);
_defineProperty(this, 'expand', void 0);
this.resultCallback = attrs.resultCallback || function () {};
this.id = attrs.id;
this.description = attrs.description || '';
this.queueableFn = attrs.queueableFn;
this.beforeAndAfterFns =
attrs.beforeAndAfterFns ||
function () {
return {
befores: [],
afters: []
};
};
this.userContext =
attrs.userContext ||
function () {
return {};
};
this.onStart = attrs.onStart || function () {};
this.getSpecName =
attrs.getSpecName ||
function () {
return '';
};
this.queueRunnerFactory = attrs.queueRunnerFactory || function () {};
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.initError = new Error();
this.initError.name = ''; // Without this line v8 stores references to all closures
// in the stack in the Error object. This line stringifies the stack
// property to allow garbage-collecting objects on the stack
// https://crbug.com/v8/7142
this.initError.stack = this.initError.stack;
this.queueableFn.initError = this.initError; // @ts-expect-error
this.result = {
id: this.id,
description: this.description,
fullName: this.getFullName(),
failedExpectations: [],
passedExpectations: [],
pendingReason: '',
testPath: attrs.getTestPath()
};
}
addExpectationResult(passed, data, isError) {
const expectationResult = (0, _expectationResultFactory.default)(
data,
this.initError
);
if (passed) {
this.result.passedExpectations.push(expectationResult);
} else {
this.result.failedExpectations.push(expectationResult);
if (this.throwOnExpectationFailure && !isError) {
throw new _ExpectationFailed.default();
}
}
}
execute(onComplete, enabled) {
const self = this;
this.onStart(this);
if (
!this.isExecutable() ||
this.markedPending ||
this.markedTodo ||
enabled === false
) {
complete(enabled);
return;
}
const fns = this.beforeAndAfterFns();
const allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
this.currentRun = this.queueRunnerFactory({
queueableFns: allFns,
onException() {
// @ts-expect-error
self.onException.apply(self, arguments);
},
userContext: this.userContext(),
setTimeout,
clearTimeout,
fail: () => {}
});
this.currentRun.then(() => complete(true));
function complete(enabledAgain) {
self.result.status = self.status(enabledAgain);
self.resultCallback(self.result);
if (onComplete) {
onComplete();
}
}
}
cancel() {
if (this.currentRun) {
this.currentRun.cancel();
}
}
onException(error) {
if (Spec.isPendingSpecException(error)) {
this.pend(extractCustomPendingMessage(error));
return;
}
if (error instanceof _ExpectationFailed.default) {
return;
}
this.addExpectationResult(
false,
{
matcherName: '',
passed: false,
expected: '',
actual: '',
error: this.isAssertionError(error)
? (0, _assertionErrorMessage.default)(error, {
expand: this.expand
})
: error
},
true
);
}
disable() {
this.disabled = true;
}
pend(message) {
this.markedPending = true;
if (message) {
this.result.pendingReason = message;
}
}
todo() {
this.markedTodo = true;
}
getResult() {
this.result.status = this.status();
return this.result;
}
status(enabled) {
if (this.disabled || enabled === false) {
return 'disabled';
}
if (this.markedTodo) {
return 'todo';
}
if (this.markedPending) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
return 'passed';
}
}
isExecutable() {
return !this.disabled;
}
getFullName() {
return this.getSpecName(this);
}
isAssertionError(error) {
return (
error instanceof _assert.AssertionError ||
(error && error.name === _assert.AssertionError.name)
);
}
}
exports.default = Spec;
_defineProperty(Spec, 'pendingSpecExceptionMessage', void 0);
Spec.pendingSpecExceptionMessage = '=> marked Pending';
const extractCustomPendingMessage = function (e) {
const fullMessage = e.toString();
const boilerplateStart = fullMessage.indexOf(
Spec.pendingSpecExceptionMessage
);
const boilerplateEnd =
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
return fullMessage.substr(boilerplateEnd);
};

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.
*
*/
export default class SpyStrategy {
identity: () => string;
exec: (...args: Array<any>) => unknown;
callThrough: () => unknown;
returnValue: (value: unknown) => unknown;
returnValues: () => unknown;
throwError: (something: string | Error) => unknown;
callFake: (fn: Function) => unknown;
stub: (fn: Function) => unknown;
constructor({ name, fn, getSpy, }?: {
name?: string;
fn?: Function;
getSpy?: () => unknown;
});
}

143
node_modules/jest-jasmine2/build/jasmine/SpyStrategy.js generated vendored Normal file
View File

@ -0,0 +1,143 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */
class SpyStrategy {
constructor({
name = 'unknown',
fn = function () {},
getSpy = function () {}
} = {}) {
_defineProperty(this, 'identity', void 0);
_defineProperty(this, 'exec', void 0);
_defineProperty(this, 'callThrough', void 0);
_defineProperty(this, 'returnValue', void 0);
_defineProperty(this, 'returnValues', void 0);
_defineProperty(this, 'throwError', void 0);
_defineProperty(this, 'callFake', void 0);
_defineProperty(this, 'stub', void 0);
const identity = name;
const originalFn = fn;
let plan = function () {};
this.identity = function () {
return identity;
};
this.exec = function () {
return plan.apply(this, arguments);
};
this.callThrough = function () {
plan = originalFn;
return getSpy();
};
this.returnValue = function (value) {
plan = function () {
return value;
};
return getSpy();
};
this.returnValues = function () {
const values = Array.prototype.slice.call(arguments);
plan = function () {
return values.shift();
};
return getSpy();
};
this.throwError = function (something) {
const error =
something instanceof Error ? something : new Error(something);
plan = function () {
throw error;
};
return getSpy();
};
this.callFake = function (fn) {
if (typeof fn !== 'function') {
throw new Error(
'Argument passed to callFake should be a function, got ' + fn
);
}
plan = fn;
return getSpy();
};
this.stub = function (_fn) {
plan = function () {};
return getSpy();
};
}
}
exports.default = SpyStrategy;

61
node_modules/jest-jasmine2/build/jasmine/Suite.d.ts generated vendored Normal file
View File

@ -0,0 +1,61 @@
/**
* 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 expectationResultFactory from '../expectationResultFactory';
import type { QueueableFn } from '../queueRunner';
import type Spec from './Spec';
export declare type SuiteResult = {
id: string;
description: string;
fullName: string;
failedExpectations: Array<ReturnType<typeof expectationResultFactory>>;
testPath: Config.Path;
status?: string;
};
export declare type Attributes = {
id: string;
parentSuite?: Suite;
description: string;
throwOnExpectationFailure?: boolean;
getTestPath: () => Config.Path;
};
export default class Suite {
id: string;
parentSuite?: Suite;
description: string;
throwOnExpectationFailure: boolean;
beforeFns: Array<QueueableFn>;
afterFns: Array<QueueableFn>;
beforeAllFns: Array<QueueableFn>;
afterAllFns: Array<QueueableFn>;
disabled: boolean;
children: Array<Suite | Spec>;
result: SuiteResult;
sharedContext?: object;
markedPending: boolean;
markedTodo: boolean;
isFocused: boolean;
constructor(attrs: Attributes);
getFullName(): string;
disable(): void;
pend(_message?: string): void;
beforeEach(fn: QueueableFn): void;
beforeAll(fn: QueueableFn): void;
afterEach(fn: QueueableFn): void;
afterAll(fn: QueueableFn): void;
addChild(child: Suite | Spec): void;
status(): "failed" | "pending" | "disabled" | "finished";
isExecutable(): boolean;
canBeReentered(): boolean;
getResult(): SuiteResult;
sharedUserContext(): object;
clonedSharedUserContext(): object;
onException(...args: Parameters<Spec['onException']>): void;
addExpectationResult(...args: Parameters<Spec['addExpectationResult']>): void;
execute(..._args: Array<any>): void;
}

235
node_modules/jest-jasmine2/build/jasmine/Suite.js generated vendored Normal file
View File

@ -0,0 +1,235 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _jestUtil = require('jest-util');
var _ExpectationFailed = _interopRequireDefault(
require('../ExpectationFailed')
);
var _expectationResultFactory = _interopRequireDefault(
require('../expectationResultFactory')
);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Suite {
constructor(attrs) {
_defineProperty(this, 'id', void 0);
_defineProperty(this, 'parentSuite', void 0);
_defineProperty(this, 'description', void 0);
_defineProperty(this, 'throwOnExpectationFailure', void 0);
_defineProperty(this, 'beforeFns', void 0);
_defineProperty(this, 'afterFns', void 0);
_defineProperty(this, 'beforeAllFns', void 0);
_defineProperty(this, 'afterAllFns', void 0);
_defineProperty(this, 'disabled', void 0);
_defineProperty(this, 'children', void 0);
_defineProperty(this, 'result', void 0);
_defineProperty(this, 'sharedContext', void 0);
_defineProperty(this, 'markedPending', void 0);
_defineProperty(this, 'markedTodo', void 0);
_defineProperty(this, 'isFocused', void 0);
this.markedPending = false;
this.markedTodo = false;
this.isFocused = false;
this.id = attrs.id;
this.parentSuite = attrs.parentSuite;
this.description = (0, _jestUtil.convertDescriptorToString)(
attrs.description
);
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.beforeFns = [];
this.afterFns = [];
this.beforeAllFns = [];
this.afterAllFns = [];
this.disabled = false;
this.children = [];
this.result = {
id: this.id,
description: this.description,
fullName: this.getFullName(),
failedExpectations: [],
testPath: attrs.getTestPath()
};
}
getFullName() {
const fullName = [];
for (
let parentSuite = this;
parentSuite;
parentSuite = parentSuite.parentSuite
) {
if (parentSuite.parentSuite) {
fullName.unshift(parentSuite.description);
}
}
return fullName.join(' ');
}
disable() {
this.disabled = true;
}
pend(_message) {
this.markedPending = true;
}
beforeEach(fn) {
this.beforeFns.unshift(fn);
}
beforeAll(fn) {
this.beforeAllFns.push(fn);
}
afterEach(fn) {
this.afterFns.unshift(fn);
}
afterAll(fn) {
this.afterAllFns.unshift(fn);
}
addChild(child) {
this.children.push(child);
}
status() {
if (this.disabled) {
return 'disabled';
}
if (this.markedPending) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
return 'finished';
}
}
isExecutable() {
return !this.disabled;
}
canBeReentered() {
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
}
getResult() {
this.result.status = this.status();
return this.result;
}
sharedUserContext() {
if (!this.sharedContext) {
this.sharedContext = {};
}
return this.sharedContext;
}
clonedSharedUserContext() {
return this.sharedUserContext();
}
onException(...args) {
if (args[0] instanceof _ExpectationFailed.default) {
return;
}
if (isAfterAll(this.children)) {
const data = {
matcherName: '',
passed: false,
expected: '',
actual: '',
error: arguments[0]
};
this.result.failedExpectations.push(
(0, _expectationResultFactory.default)(data)
);
} else {
for (let i = 0; i < this.children.length; i++) {
const child = this.children[i];
child.onException.apply(child, args);
}
}
}
addExpectationResult(...args) {
if (isAfterAll(this.children) && isFailure(args)) {
const data = args[1];
this.result.failedExpectations.push(
(0, _expectationResultFactory.default)(data)
);
if (this.throwOnExpectationFailure) {
throw new _ExpectationFailed.default();
}
} else {
for (let i = 0; i < this.children.length; i++) {
const child = this.children[i];
try {
child.addExpectationResult.apply(child, args);
} catch {
// keep going
}
}
}
}
execute(..._args) {}
}
exports.default = Suite;
function isAfterAll(children) {
return children && children[0] && children[0].result.status;
}
function isFailure(args) {
return !args[0];
}

14
node_modules/jest-jasmine2/build/jasmine/Timer.d.ts generated vendored Normal file
View File

@ -0,0 +1,14 @@
/**
* 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.
*
*/
export default class Timer {
start: () => void;
elapsed: () => number;
constructor(options?: {
now?: () => number;
});
}

79
node_modules/jest-jasmine2/build/jasmine/Timer.js generated vendored Normal file
View File

@ -0,0 +1,79 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return 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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const defaultNow = (function (Date) {
return function () {
return new Date().getTime();
};
})(Date);
class Timer {
constructor(options) {
_defineProperty(this, 'start', void 0);
_defineProperty(this, 'elapsed', void 0);
options = options || {};
const now = options.now || defaultNow;
let startTime;
this.start = function () {
startTime = now();
};
this.elapsed = function () {
return now() - startTime;
};
}
}
exports.default = Timer;

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 { Spy } from '../types';
interface Fn extends Record<string, unknown> {
(): unknown;
}
declare function createSpy(name: string, originalFn: Fn): Spy;
export default createSpy;

88
node_modules/jest-jasmine2/build/jasmine/createSpy.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _CallTracker = _interopRequireDefault(require('./CallTracker'));
var _SpyStrategy = _interopRequireDefault(require('./SpyStrategy'));
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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys, local/prefer-rest-params-eventually */
function createSpy(name, originalFn) {
const spyStrategy = new _SpyStrategy.default({
name,
fn: originalFn,
getSpy() {
return spy;
}
});
const callTracker = new _CallTracker.default();
const spy = function (...args) {
const callData = {
object: this,
args: Array.prototype.slice.apply(arguments)
};
callTracker.track(callData);
const returnValue = spyStrategy.exec.apply(this, args);
callData.returnValue = returnValue;
return returnValue;
};
for (const prop in originalFn) {
if (prop === 'and' || prop === 'calls') {
throw new Error(
"Jasmine spies would overwrite the 'and' and 'calls' properties " +
'on the object being spied upon'
);
}
spy[prop] = originalFn[prop];
}
spy.and = spyStrategy;
spy.calls = callTracker;
return spy;
}
var _default = createSpy;
exports.default = _default;

View File

@ -0,0 +1,27 @@
/**
* 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 { Jasmine, SpecDefinitionsFn } from '../types';
import JsApiReporter from './JsApiReporter';
export declare const create: (createOptions: Record<string, any>) => Jasmine;
export declare const _interface: (jasmine: Jasmine, env: any) => {
describe(description: string, specDefinitions: SpecDefinitionsFn): any;
xdescribe(description: string, specDefinitions: SpecDefinitionsFn): any;
fdescribe(description: string, specDefinitions: SpecDefinitionsFn): any;
it(): any;
xit(): any;
fit(): any;
beforeEach(): any;
afterEach(): any;
beforeAll(): any;
afterAll(): any;
pending(): any;
fail(): any;
spyOn(obj: Record<string, any>, methodName: string, accessType?: string | undefined): any;
jsApiReporter: JsApiReporter;
jasmine: Jasmine;
};

View File

@ -0,0 +1,171 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports._interface = exports.create = void 0;
var _Env = _interopRequireDefault(require('./Env'));
var _JsApiReporter = _interopRequireDefault(require('./JsApiReporter'));
var _ReportDispatcher = _interopRequireDefault(require('./ReportDispatcher'));
var _Spec = _interopRequireDefault(require('./Spec'));
var _Suite = _interopRequireDefault(require('./Suite'));
var _Timer = _interopRequireDefault(require('./Timer'));
var _createSpy = _interopRequireDefault(require('./createSpy'));
var _spyRegistry = _interopRequireDefault(require('./spyRegistry'));
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.
*
*/
// This file is a heavily modified fork of Jasmine. Original license:
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* eslint-disable sort-keys, local/prefer-spread-eventually, local/prefer-rest-params-eventually */
const create = function (createOptions) {
const j$ = {...createOptions};
j$._DEFAULT_TIMEOUT_INTERVAL = createOptions.testTimeout || 5000;
j$.getEnv = function (options) {
const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options)); //jasmine. singletons in here (setTimeout blah blah).
return env;
};
j$.createSpy = _createSpy.default;
j$.Env = (0, _Env.default)(j$);
j$.JsApiReporter = _JsApiReporter.default;
j$.ReportDispatcher = _ReportDispatcher.default;
j$.Spec = _Spec.default;
j$.SpyRegistry = _spyRegistry.default;
j$.Suite = _Suite.default;
j$.Timer = _Timer.default;
j$.version = '2.5.2-light';
return j$;
}; // Interface is a reserved word in strict mode, so can't export it as ESM
exports.create = create;
const _interface = function (jasmine, env) {
const jasmineInterface = {
describe(description, specDefinitions) {
return env.describe(description, specDefinitions);
},
xdescribe(description, specDefinitions) {
return env.xdescribe(description, specDefinitions);
},
fdescribe(description, specDefinitions) {
return env.fdescribe(description, specDefinitions);
},
it() {
return env.it.apply(env, arguments);
},
xit() {
return env.xit.apply(env, arguments);
},
fit() {
return env.fit.apply(env, arguments);
},
beforeEach() {
if (typeof arguments[0] !== 'function') {
throw new Error(
'Invalid first argument. It must be a callback function.'
);
}
return env.beforeEach.apply(env, arguments);
},
afterEach() {
if (typeof arguments[0] !== 'function') {
throw new Error(
'Invalid first argument. It must be a callback function.'
);
}
return env.afterEach.apply(env, arguments);
},
beforeAll() {
if (typeof arguments[0] !== 'function') {
throw new Error(
'Invalid first argument. It must be a callback function.'
);
}
return env.beforeAll.apply(env, arguments);
},
afterAll() {
if (typeof arguments[0] !== 'function') {
throw new Error(
'Invalid first argument. It must be a callback function.'
);
}
return env.afterAll.apply(env, arguments);
},
pending() {
return env.pending.apply(env, arguments);
},
fail() {
return env.fail.apply(env, arguments);
},
spyOn(obj, methodName, accessType) {
return env.spyOn(obj, methodName, accessType);
},
jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer()
}),
jasmine
};
return jasmineInterface;
};
exports._interface = _interface;

View File

@ -0,0 +1,18 @@
/**
* 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 { Spy } from '../types';
export default class SpyRegistry {
allowRespy: (allow: unknown) => void;
spyOn: (obj: Record<string, Spy>, methodName: string, accessType?: keyof PropertyDescriptor) => Spy;
clearSpies: () => void;
respy: unknown;
private _spyOnProperty;
constructor({ currentSpies, }?: {
currentSpies?: () => Array<Spy>;
});
}

222
node_modules/jest-jasmine2/build/jasmine/spyRegistry.js generated vendored Normal file
View File

@ -0,0 +1,222 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _CallTracker = _interopRequireDefault(require('./CallTracker'));
var _SpyStrategy = _interopRequireDefault(require('./SpyStrategy'));
var _createSpy = _interopRequireDefault(require('./createSpy'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
const formatErrorMsg = (domain, usage) => {
const usageDefinition = usage ? '\nUsage: ' + usage : '';
return msg => domain + ' : ' + msg + usageDefinition;
};
function isSpy(putativeSpy) {
if (!putativeSpy) {
return false;
}
return (
putativeSpy.and instanceof _SpyStrategy.default &&
putativeSpy.calls instanceof _CallTracker.default
);
}
const getErrorMsg = formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)');
class SpyRegistry {
constructor({currentSpies = () => []} = {}) {
_defineProperty(this, 'allowRespy', void 0);
_defineProperty(this, 'spyOn', void 0);
_defineProperty(this, 'clearSpies', void 0);
_defineProperty(this, 'respy', void 0);
_defineProperty(this, '_spyOnProperty', void 0);
this.allowRespy = function (allow) {
this.respy = allow;
};
this.spyOn = (obj, methodName, accessType) => {
if (accessType) {
return this._spyOnProperty(obj, methodName, accessType);
}
if (obj === void 0) {
throw new Error(
getErrorMsg(
'could not find an object to spy upon for ' + methodName + '()'
)
);
}
if (methodName === void 0) {
throw new Error(getErrorMsg('No method name supplied'));
}
if (obj[methodName] === void 0) {
throw new Error(getErrorMsg(methodName + '() method does not exist'));
}
if (obj[methodName] && isSpy(obj[methodName])) {
if (this.respy) {
return obj[methodName];
} else {
throw new Error(
getErrorMsg(methodName + ' has already been spied upon')
);
}
}
let descriptor;
try {
descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
} catch {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}
if (descriptor && !(descriptor.writable || descriptor.set)) {
throw new Error(
getErrorMsg(methodName + ' is not declared writable or has no setter')
);
}
const originalMethod = obj[methodName];
const spiedMethod = (0, _createSpy.default)(methodName, originalMethod);
let restoreStrategy;
if (Object.prototype.hasOwnProperty.call(obj, methodName)) {
restoreStrategy = function () {
obj[methodName] = originalMethod;
};
} else {
restoreStrategy = function () {
if (!delete obj[methodName]) {
obj[methodName] = originalMethod;
}
};
}
currentSpies().push({
restoreObjectToOriginalState: restoreStrategy
});
obj[methodName] = spiedMethod;
return spiedMethod;
};
this._spyOnProperty = function (obj, propertyName, accessType = 'get') {
if (!obj) {
throw new Error(
getErrorMsg(
'could not find an object to spy upon for ' + propertyName
)
);
}
if (!propertyName) {
throw new Error(getErrorMsg('No property name supplied'));
}
let descriptor;
try {
descriptor = Object.getOwnPropertyDescriptor(obj, propertyName);
} catch {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}
if (!descriptor) {
throw new Error(getErrorMsg(propertyName + ' property does not exist'));
}
if (!descriptor.configurable) {
throw new Error(
getErrorMsg(propertyName + ' is not declared configurable')
);
}
if (!descriptor[accessType]) {
throw new Error(
getErrorMsg(
'Property ' +
propertyName +
' does not have access type ' +
accessType
)
);
}
if (obj[propertyName] && isSpy(obj[propertyName])) {
if (this.respy) {
return obj[propertyName];
} else {
throw new Error(
getErrorMsg(propertyName + ' has already been spied upon')
);
}
}
const originalDescriptor = descriptor;
const spiedProperty = (0, _createSpy.default)(
propertyName,
descriptor[accessType]
);
let restoreStrategy;
if (Object.prototype.hasOwnProperty.call(obj, propertyName)) {
restoreStrategy = function () {
Object.defineProperty(obj, propertyName, originalDescriptor);
};
} else {
restoreStrategy = function () {
delete obj[propertyName];
};
}
currentSpies().push({
restoreObjectToOriginalState: restoreStrategy
});
const spiedDescriptor = {...descriptor, [accessType]: spiedProperty};
Object.defineProperty(obj, propertyName, spiedDescriptor);
return spiedProperty;
};
this.clearSpies = function () {
const spies = currentSpies();
for (let i = spies.length - 1; i >= 0; i--) {
const spyEntry = spies[i];
spyEntry.restoreObjectToOriginalState();
}
};
}
}
exports.default = SpyRegistry;

View File

@ -0,0 +1,8 @@
/**
* 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, Global } from '@jest/types';
export default function jasmineAsyncInstall(globalConfig: Config.GlobalConfig, global: Global.Global): void;

190
node_modules/jest-jasmine2/build/jasmineAsyncInstall.js generated vendored Normal file
View File

@ -0,0 +1,190 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = jasmineAsyncInstall;
var _co = _interopRequireDefault(require('co'));
var _isGeneratorFn = _interopRequireDefault(require('is-generator-fn'));
var _throat = _interopRequireDefault(require('throat'));
var _isError = _interopRequireDefault(require('./isError'));
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 isPromise(obj) {
return obj && typeof obj.then === 'function';
}
const doneFnNoop = () => {};
doneFnNoop.fail = () => {};
function promisifyLifeCycleFunction(originalFn, env) {
return function (fn, timeout) {
if (!fn) {
// @ts-expect-error: missing fn arg is handled by originalFn
return originalFn.call(env);
}
const hasDoneCallback = typeof fn === 'function' && fn.length > 0;
if (hasDoneCallback) {
// Jasmine will handle it
return originalFn.call(env, fn, timeout);
}
const extraError = new Error(); // Without this line v8 stores references to all closures
// in the stack in the Error object. This line stringifies the stack
// property to allow garbage-collecting objects on the stack
// https://crbug.com/v8/7142
extraError.stack = extraError.stack; // We make *all* functions async and run `done` right away if they
// didn't return a promise.
const asyncJestLifecycle = function (done) {
const wrappedFn = (0, _isGeneratorFn.default)(fn)
? _co.default.wrap(fn)
: fn;
const returnValue = wrappedFn.call({}, doneFnNoop);
if (isPromise(returnValue)) {
returnValue.then(done.bind(null, null), error => {
const {isError: checkIsError, message} = (0, _isError.default)(error);
if (message) {
extraError.message = message;
}
done.fail(checkIsError ? error : extraError);
});
} else {
done();
}
};
return originalFn.call(env, asyncJestLifecycle, timeout);
};
} // Similar to promisifyLifeCycleFunction but throws an error
// when the return value is neither a Promise nor `undefined`
function promisifyIt(originalFn, env, jasmine) {
return function (specName, fn, timeout) {
if (!fn) {
// @ts-expect-error: missing fn arg is handled by originalFn
const spec = originalFn.call(env, specName);
spec.pend('not implemented');
return spec;
}
const hasDoneCallback = fn.length > 0;
if (hasDoneCallback) {
return originalFn.call(env, specName, fn, timeout);
}
const extraError = new Error(); // Without this line v8 stores references to all closures
// in the stack in the Error object. This line stringifies the stack
// property to allow garbage-collecting objects on the stack
// https://crbug.com/v8/7142
extraError.stack = extraError.stack;
const asyncJestTest = function (done) {
const wrappedFn = (0, _isGeneratorFn.default)(fn)
? _co.default.wrap(fn)
: fn;
const returnValue = wrappedFn.call({}, doneFnNoop);
if (isPromise(returnValue)) {
returnValue.then(done.bind(null, null), error => {
const {isError: checkIsError, message} = (0, _isError.default)(error);
if (message) {
extraError.message = message;
}
if (jasmine.Spec.isPendingSpecException(error)) {
env.pending(message);
done();
} else {
done.fail(checkIsError ? error : extraError);
}
});
} else if (returnValue === undefined) {
done();
} else {
done.fail(
new Error(
'Jest: `it` and `test` must return either a Promise or undefined.'
)
);
}
};
return originalFn.call(env, specName, asyncJestTest, timeout);
};
}
function makeConcurrent(originalFn, env, mutex) {
const concurrentFn = function (specName, fn, timeout) {
let promise = Promise.resolve();
const spec = originalFn.call(env, specName, () => promise, timeout);
if (env != null && !env.specFilter(spec)) {
return spec;
}
try {
promise = mutex(() => {
const promise = fn();
if (isPromise(promise)) {
return promise;
}
throw new Error(
`Jest: concurrent test "${spec.getFullName()}" must return a Promise.`
);
});
} catch (error) {
promise = Promise.reject(error);
}
return spec;
}; // each is binded after the function is made concurrent, so for now it is made noop
concurrentFn.each = () => () => {};
return concurrentFn;
}
function jasmineAsyncInstall(globalConfig, global) {
const jasmine = global.jasmine;
const mutex = (0, _throat.default)(globalConfig.maxConcurrency);
const env = jasmine.getEnv();
env.it = promisifyIt(env.it, env, jasmine);
env.fit = promisifyIt(env.fit, env, jasmine);
global.it.concurrent = (env => {
const concurrent = makeConcurrent(env.it, env, mutex);
concurrent.only = makeConcurrent(env.fit, env, mutex);
concurrent.skip = makeConcurrent(env.xit, env, mutex);
return concurrent;
})(env);
global.fit.concurrent = makeConcurrent(env.fit, env, mutex);
env.afterAll = promisifyLifeCycleFunction(env.afterAll, env);
env.afterEach = promisifyLifeCycleFunction(env.afterEach, env);
env.beforeAll = promisifyLifeCycleFunction(env.beforeAll, env);
env.beforeEach = promisifyLifeCycleFunction(env.beforeEach, env);
}

10
node_modules/jest-jasmine2/build/jestExpect.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.
*/
declare const _default: (config: {
expand: boolean;
}) => void;
export default _default;

71
node_modules/jest-jasmine2/build/jestExpect.js generated vendored Normal file
View File

@ -0,0 +1,71 @@
'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.
*/
/* eslint-disable local/prefer-spread-eventually */
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;
const jasmine = global.jasmine;
jasmine.anything = _expect.default.anything;
jasmine.any = _expect.default.any;
jasmine.objectContaining = _expect.default.objectContaining;
jasmine.arrayContaining = _expect.default.arrayContaining;
jasmine.stringMatching = _expect.default.stringMatching;
jasmine.addMatchers = jasmineMatchersObject => {
const jestMatchersObject = Object.create(null);
Object.keys(jasmineMatchersObject).forEach(name => {
jestMatchersObject[name] = function (...args) {
// use "expect.extend" if you need to use equality testers (via this.equal)
const result = jasmineMatchersObject[name](null, null); // if there is no 'negativeCompare', both should be handled by `compare`
const negativeCompare = result.negativeCompare || result.compare;
return this.isNot
? negativeCompare.apply(
null, // @ts-expect-error
args
)
: result.compare.apply(
null, // @ts-expect-error
args
);
};
});
const expect = global.expect;
expect.extend(jestMatchersObject);
};
};
exports.default = _default;

7
node_modules/jest-jasmine2/build/pTimeout.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
/**
* 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.
*/
export default function pTimeout(promise: Promise<void>, ms: number, clearTimeout: NodeJS.Global['clearTimeout'], setTimeout: NodeJS.Global['setTimeout'], onTimeout: () => void): Promise<void>;

33
node_modules/jest-jasmine2/build/pTimeout.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = pTimeout;
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;
/**
* 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.
*/
// A specialized version of `p-timeout` that does not touch globals.
// It does not throw on timeout.
function pTimeout(promise, ms, clearTimeout, setTimeout, onTimeout) {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => resolve(onTimeout()), ms);
promise.then(
val => {
clearTimeout(timer);
resolve(val);
},
err => {
clearTimeout(timer);
reject(err);
}
);
});
}

30
node_modules/jest-jasmine2/build/queueRunner.d.ts generated vendored Normal file
View File

@ -0,0 +1,30 @@
/**
* 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 type Global = NodeJS.Global;
export declare type Options = {
clearTimeout: Global['clearTimeout'];
fail: (error: Error) => void;
onException: (error: Error) => void;
queueableFns: Array<QueueableFn>;
setTimeout: Global['setTimeout'];
userContext: unknown;
};
export interface DoneFn {
(error?: any): void;
fail: (error: Error) => void;
}
export declare type QueueableFn = {
fn: (done: DoneFn) => void;
timeout?: () => number;
initError?: Error;
};
declare type PromiseCallback = (() => void | PromiseLike<void>) | undefined | null;
export default function queueRunner(options: Options): PromiseLike<void> & {
cancel: () => void;
catch: (onRejected?: PromiseCallback) => Promise<void>;
};
export {};

83
node_modules/jest-jasmine2/build/queueRunner.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = queueRunner;
var _jestUtil = require('jest-util');
var _PCancelable = _interopRequireDefault(require('./PCancelable'));
var _pTimeout = _interopRequireDefault(require('./pTimeout'));
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 queueRunner(options) {
const token = new _PCancelable.default((onCancel, resolve) => {
onCancel(resolve);
});
const mapper = ({fn, timeout, initError = new Error()}) => {
let promise = new Promise(resolve => {
const next = function (...args) {
const err = args[0];
if (err) {
options.fail.apply(null, args);
}
resolve();
};
next.fail = function (...args) {
options.fail.apply(null, args);
resolve();
};
try {
fn.call(options.userContext, next);
} catch (e) {
options.onException(e);
resolve();
}
});
promise = Promise.race([promise, token]);
if (!timeout) {
return promise;
}
const timeoutMs = timeout();
return (0, _pTimeout.default)(
promise,
timeoutMs,
options.clearTimeout,
options.setTimeout,
() => {
initError.message =
'Timeout - Async callback was not invoked within the ' +
(0, _jestUtil.formatTime)(timeoutMs) +
' timeout specified by jest.setTimeout.';
initError.stack = initError.message + initError.stack;
options.onException(initError);
}
);
};
const result = options.queueableFns.reduce(
(promise, fn) => promise.then(() => mapper(fn)),
Promise.resolve()
);
return {
cancel: token.cancel.bind(token),
catch: result.catch.bind(result),
then: result.then.bind(result)
};
}

31
node_modules/jest-jasmine2/build/reporter.d.ts generated vendored Normal file
View File

@ -0,0 +1,31 @@
/**
* 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 { TestResult } from '@jest/test-result';
import type { Config } from '@jest/types';
import type { SpecResult } from './jasmine/Spec';
import type { SuiteResult } from './jasmine/Suite';
import type { Reporter, RunDetails } from './types';
export default class Jasmine2Reporter implements Reporter {
private _testResults;
private _globalConfig;
private _config;
private _currentSuites;
private _resolve;
private _resultsPromise;
private _startTimes;
private _testPath;
constructor(globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, testPath: Config.Path);
jasmineStarted(_runDetails: RunDetails): void;
specStarted(spec: SpecResult): void;
specDone(result: SpecResult): void;
suiteStarted(suite: SuiteResult): void;
suiteDone(_result: SuiteResult): void;
jasmineDone(_runDetails: RunDetails): void;
getResults(): Promise<TestResult>;
private _addMissingMessageToStack;
private _extractSpecResults;
}

177
node_modules/jest-jasmine2/build/reporter.js generated vendored Normal file
View File

@ -0,0 +1,177 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _testResult = require('@jest/test-result');
var _jestMessageUtil = require('jest-message-util');
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;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Jasmine2Reporter {
constructor(globalConfig, config, testPath) {
_defineProperty(this, '_testResults', void 0);
_defineProperty(this, '_globalConfig', void 0);
_defineProperty(this, '_config', void 0);
_defineProperty(this, '_currentSuites', void 0);
_defineProperty(this, '_resolve', void 0);
_defineProperty(this, '_resultsPromise', void 0);
_defineProperty(this, '_startTimes', void 0);
_defineProperty(this, '_testPath', void 0);
this._globalConfig = globalConfig;
this._config = config;
this._testPath = testPath;
this._testResults = [];
this._currentSuites = [];
this._resolve = null;
this._resultsPromise = new Promise(resolve => (this._resolve = resolve));
this._startTimes = new Map();
}
jasmineStarted(_runDetails) {}
specStarted(spec) {
this._startTimes.set(spec.id, jestNow());
}
specDone(result) {
this._testResults.push(
this._extractSpecResults(result, this._currentSuites.slice(0))
);
}
suiteStarted(suite) {
this._currentSuites.push(suite.description);
}
suiteDone(_result) {
this._currentSuites.pop();
}
jasmineDone(_runDetails) {
let numFailingTests = 0;
let numPassingTests = 0;
let numPendingTests = 0;
let numTodoTests = 0;
const testResults = this._testResults;
testResults.forEach(testResult => {
if (testResult.status === 'failed') {
numFailingTests++;
} else if (testResult.status === 'pending') {
numPendingTests++;
} else if (testResult.status === 'todo') {
numTodoTests++;
} else {
numPassingTests++;
}
});
const testResult = {
...(0, _testResult.createEmptyTestResult)(),
console: null,
failureMessage: (0, _jestMessageUtil.formatResultsErrors)(
testResults,
this._config,
this._globalConfig,
this._testPath
),
numFailingTests,
numPassingTests,
numPendingTests,
numTodoTests,
snapshot: {
added: 0,
fileDeleted: false,
matched: 0,
unchecked: 0,
unmatched: 0,
updated: 0
},
testFilePath: this._testPath,
testResults
};
this._resolve(testResult);
}
getResults() {
return this._resultsPromise;
}
_addMissingMessageToStack(stack, message) {
// Some errors (e.g. Angular injection error) don't prepend error.message
// to stack, instead the first line of the stack is just plain 'Error'
const ERROR_REGEX = /^Error:?\s*\n/;
if (stack && message && !stack.includes(message)) {
return message + stack.replace(ERROR_REGEX, '\n');
}
return stack;
}
_extractSpecResults(specResult, ancestorTitles) {
const start = this._startTimes.get(specResult.id);
const duration = start ? jestNow() - start : undefined;
const status =
specResult.status === 'disabled' ? 'pending' : specResult.status;
const location = specResult.__callsite
? {
column: specResult.__callsite.getColumnNumber(),
line: specResult.__callsite.getLineNumber()
}
: null;
const results = {
ancestorTitles,
duration,
failureDetails: [],
failureMessages: [],
fullName: specResult.fullName,
location,
numPassingAsserts: 0,
// Jasmine2 only returns an array of failed asserts.
status,
title: specResult.description
};
specResult.failedExpectations.forEach(failed => {
const message =
!failed.matcherName && typeof failed.stack === 'string'
? this._addMissingMessageToStack(failed.stack, failed.message)
: failed.message || '';
results.failureMessages.push(message);
results.failureDetails.push(failed);
});
return results;
}
}
exports.default = Jasmine2Reporter;

View File

@ -0,0 +1,17 @@
/**
* 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 { SnapshotStateType } from 'jest-snapshot';
import type { Plugin } from 'pretty-format';
export declare type SetupOptions = {
config: Config.ProjectConfig;
globalConfig: Config.GlobalConfig;
localRequire: (moduleName: string) => Plugin;
testPath: Config.Path;
};
declare const _default: ({ config, globalConfig, localRequire, testPath, }: SetupOptions) => SnapshotStateType;
export default _default;

115
node_modules/jest-jasmine2/build/setup_jest_globals.js generated vendored Normal file
View File

@ -0,0 +1,115 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _expect = require('expect');
var _jestSnapshot = require('jest-snapshot');
/**
* 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.
*/
// Get suppressed errors form jest-matchers that weren't throw during
// test execution and add them to the test result, potentially failing
// a passing test.
const addSuppressedErrors = result => {
const {suppressedErrors} = (0, _expect.getState)();
(0, _expect.setState)({
suppressedErrors: []
});
if (suppressedErrors.length) {
result.status = 'failed';
result.failedExpectations = suppressedErrors.map(error => ({
actual: '',
// passing error for custom test reporters
error,
expected: '',
matcherName: '',
message: error.message,
passed: false,
stack: error.stack
}));
}
};
const addAssertionErrors = result => {
const assertionErrors = (0, _expect.extractExpectedAssertionsErrors)();
if (assertionErrors.length) {
const jasmineErrors = assertionErrors.map(({actual, error, expected}) => ({
actual,
expected,
message: error.stack,
passed: false
}));
result.status = 'failed';
result.failedExpectations = result.failedExpectations.concat(jasmineErrors);
}
};
const patchJasmine = () => {
global.jasmine.Spec = (realSpec => {
class Spec extends realSpec {
constructor(attr) {
const resultCallback = attr.resultCallback;
attr.resultCallback = function (result) {
addSuppressedErrors(result);
addAssertionErrors(result);
resultCallback.call(attr, result);
};
const onStart = attr.onStart;
attr.onStart = context => {
(0, _expect.setState)({
currentTestName: context.getFullName()
});
onStart && onStart.call(attr, context);
};
super(attr);
}
}
return Spec;
})(global.jasmine.Spec);
};
var _default = ({config, globalConfig, localRequire, testPath}) => {
// 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));
});
patchJasmine();
const {expand, updateSnapshot} = globalConfig;
const snapshotResolver = (0, _jestSnapshot.buildSnapshotResolver)(config);
const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath);
const snapshotState = new _jestSnapshot.SnapshotState(snapshotPath, {
expand,
getBabelTraverse: () => require('@babel/traverse').default,
getPrettier: () =>
config.prettierPath ? require(config.prettierPath) : null,
updateSnapshot
}); // @ts-expect-error: snapshotState is a jest extension of `expect`
(0, _expect.setState)({
snapshotState,
testPath
}); // Return it back to the outer scope (test runner outside the VM).
return snapshotState;
};
exports.default = _default;

26
node_modules/jest-jasmine2/build/treeProcessor.d.ts generated vendored Normal file
View File

@ -0,0 +1,26 @@
/**
* 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 Suite from './jasmine/Suite';
declare type Options = {
nodeComplete: (suite: TreeNode) => void;
nodeStart: (suite: TreeNode) => void;
queueRunnerFactory: any;
runnableIds: Array<string>;
tree: TreeNode;
};
export declare type TreeNode = {
afterAllFns: Array<unknown>;
beforeAllFns: Array<unknown>;
disabled?: boolean;
execute: (onComplete: () => void, enabled: boolean) => void;
id: string;
onException: (error: Error) => void;
sharedUserContext: () => unknown;
children?: Array<TreeNode>;
} & Pick<Suite, 'getResult' | 'parentSuite' | 'result' | 'markedPending'>;
export default function treeProcessor(options: Options): void;
export {};

79
node_modules/jest-jasmine2/build/treeProcessor.js generated vendored Normal file
View File

@ -0,0 +1,79 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = treeProcessor;
/**
* 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.
*/
function treeProcessor(options) {
const {
nodeComplete,
nodeStart,
queueRunnerFactory,
runnableIds,
tree
} = options;
function isEnabled(node, parentEnabled) {
return parentEnabled || runnableIds.indexOf(node.id) !== -1;
}
function getNodeHandler(node, parentEnabled) {
const enabled = isEnabled(node, parentEnabled);
return node.children
? getNodeWithChildrenHandler(node, enabled)
: getNodeWithoutChildrenHandler(node, enabled);
}
function getNodeWithoutChildrenHandler(node, enabled) {
return function fn(done = () => {}) {
node.execute(done, enabled);
};
}
function getNodeWithChildrenHandler(node, enabled) {
return async function fn(done = () => {}) {
nodeStart(node);
await queueRunnerFactory({
onException: error => node.onException(error),
queueableFns: wrapChildren(node, enabled),
userContext: node.sharedUserContext()
});
nodeComplete(node);
done();
};
}
function hasNoEnabledTest(node) {
if (node.children) {
return node.children.every(hasNoEnabledTest);
}
return node.disabled || node.markedPending;
}
function wrapChildren(node, enabled) {
if (!node.children) {
throw new Error('`node.children` is not defined.');
}
const children = node.children.map(child => ({
fn: getNodeHandler(child, enabled)
}));
if (hasNoEnabledTest(node)) {
return children;
}
return node.beforeAllFns.concat(children).concat(node.afterAllFns);
}
const treeHandler = getNodeHandler(tree, false);
return treeHandler();
}

82
node_modules/jest-jasmine2/build/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,82 @@
/**
* 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 { AssertionError } from 'assert';
import type { Config } from '@jest/types';
import expect = require('expect');
import type CallTracker from './jasmine/CallTracker';
import type Env from './jasmine/Env';
import type JsApiReporter from './jasmine/JsApiReporter';
import type ReportDispatcher from './jasmine/ReportDispatcher';
import type { default as Spec, SpecResult } from './jasmine/Spec';
import type SpyStrategy from './jasmine/SpyStrategy';
import type { default as Suite, SuiteResult } from './jasmine/Suite';
import type Timer from './jasmine/Timer';
import type createSpy from './jasmine/createSpy';
import type SpyRegistry from './jasmine/spyRegistry';
export declare type SpecDefinitionsFn = () => void;
export interface AssertionErrorWithStack extends AssertionError {
stack: string;
}
export declare type SyncExpectationResult = {
pass: boolean;
message: () => string;
};
export declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
export declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
export declare type RawMatcherFn = (expected: unknown, actual: unknown, options?: unknown) => ExpectationResult;
export declare type RunDetails = {
totalSpecsDefined?: number;
failedExpectations?: SuiteResult['failedExpectations'];
};
export declare type Reporter = {
jasmineDone: (runDetails: RunDetails) => void;
jasmineStarted: (runDetails: RunDetails) => void;
specDone: (result: SpecResult) => void;
specStarted: (spec: SpecResult) => void;
suiteDone: (result: SuiteResult) => void;
suiteStarted: (result: SuiteResult) => void;
};
export interface Spy extends Record<string, any> {
(this: Record<string, unknown>, ...args: Array<any>): unknown;
and: SpyStrategy;
calls: CallTracker;
restoreObjectToOriginalState?: () => void;
}
declare type JasmineMatcher = {
(matchersUtil: unknown, context: unknown): JasmineMatcher;
compare: () => RawMatcherFn;
negativeCompare: () => RawMatcherFn;
};
export declare type JasmineMatchersObject = {
[id: string]: JasmineMatcher;
};
export declare type Jasmine = {
_DEFAULT_TIMEOUT_INTERVAL: number;
DEFAULT_TIMEOUT_INTERVAL: number;
currentEnv_: ReturnType<typeof Env>['prototype'];
getEnv: (options?: Record<string, unknown>) => ReturnType<typeof Env>['prototype'];
createSpy: typeof createSpy;
Env: ReturnType<typeof Env>;
JsApiReporter: typeof JsApiReporter;
ReportDispatcher: typeof ReportDispatcher;
Spec: typeof Spec;
SpyRegistry: typeof SpyRegistry;
Suite: typeof Suite;
Timer: typeof Timer;
version: string;
testPath: Config.Path;
addMatchers: (matchers: JasmineMatchersObject) => void;
} & typeof expect & NodeJS.Global;
declare global {
module NodeJS {
interface Global {
expect: typeof expect;
}
}
}
export {};

7
node_modules/jest-jasmine2/build/types.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
'use strict';
var _expect = _interopRequireDefault(require('expect'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,454 @@
# pretty-format
Stringify any JavaScript value.
- Serialize built-in JavaScript types.
- Serialize application-specific data types with built-in or user-defined plugins.
## Installation
```sh
$ yarn add pretty-format
```
## Usage
```js
const prettyFormat = require('pretty-format'); // CommonJS
```
```js
import prettyFormat from 'pretty-format'; // ES2015 modules
```
```js
const val = {object: {}};
val.circularReference = val;
val[Symbol('foo')] = 'foo';
val.map = new Map([['prop', 'value']]);
val.array = [-0, Infinity, NaN];
console.log(prettyFormat(val));
/*
Object {
"array": Array [
-0,
Infinity,
NaN,
],
"circularReference": [Circular],
"map": Map {
"prop" => "value",
},
"object": Object {},
Symbol(foo): "foo",
}
*/
```
## Usage with options
```js
function onClick() {}
console.log(prettyFormat(onClick));
/*
[Function onClick]
*/
const options = {
printFunctionName: false,
};
console.log(prettyFormat(onClick, options));
/*
[Function]
*/
```
<!-- prettier-ignore -->
| key | type | default | description |
| :------------------ | :-------- | :--------- | :------------------------------------------------------ |
| `callToJSON` | `boolean` | `true` | call `toJSON` method (if it exists) on objects |
| `escapeRegex` | `boolean` | `false` | escape special characters in regular expressions |
| `escapeString` | `boolean` | `true` | escape special characters in strings |
| `highlight` | `boolean` | `false` | highlight syntax with colors in terminal (some plugins) |
| `indent` | `number` | `2` | spaces in each level of indentation |
| `maxDepth` | `number` | `Infinity` | levels to print in arrays, objects, elements, and so on |
| `min` | `boolean` | `false` | minimize added space: no indentation nor line breaks |
| `plugins` | `array` | `[]` | plugins to serialize application-specific data types |
| `printFunctionName` | `boolean` | `true` | include or omit the name of a function |
| `theme` | `object` | | colors to highlight syntax in terminal |
Property values of `theme` are from [ansi-styles colors](https://github.com/chalk/ansi-styles#colors)
```js
const DEFAULT_THEME = {
comment: 'gray',
content: 'reset',
prop: 'yellow',
tag: 'cyan',
value: 'green',
};
```
## Usage with plugins
The `pretty-format` package provides some built-in plugins, including:
- `ReactElement` for elements from `react`
- `ReactTestComponent` for test objects from `react-test-renderer`
```js
// CommonJS
const React = require('react');
const renderer = require('react-test-renderer');
const prettyFormat = require('pretty-format');
const ReactElement = prettyFormat.plugins.ReactElement;
const ReactTestComponent = prettyFormat.plugins.ReactTestComponent;
```
```js
import React from 'react';
import renderer from 'react-test-renderer';
// ES2015 modules and destructuring assignment
import prettyFormat from 'pretty-format';
const {ReactElement, ReactTestComponent} = prettyFormat.plugins;
```
```js
const onClick = () => {};
const element = React.createElement('button', {onClick}, 'Hello World');
const formatted1 = prettyFormat(element, {
plugins: [ReactElement],
printFunctionName: false,
});
const formatted2 = prettyFormat(renderer.create(element).toJSON(), {
plugins: [ReactTestComponent],
printFunctionName: false,
});
/*
<button
onClick=[Function]
>
Hello World
</button>
*/
```
## Usage in Jest
For snapshot tests, Jest uses `pretty-format` with options that include some of its built-in plugins. For this purpose, plugins are also known as **snapshot serializers**.
To serialize application-specific data types, you can add modules to `devDependencies` of a project, and then:
In an **individual** test file, you can add a module as follows. It precedes any modules from Jest configuration.
```js
import serializer from 'my-serializer-module';
expect.addSnapshotSerializer(serializer);
// tests which have `expect(value).toMatchSnapshot()` assertions
```
For **all** test files, you can specify modules in Jest configuration. They precede built-in plugins for React, HTML, and Immutable.js data types. For example, in a `package.json` file:
```json
{
"jest": {
"snapshotSerializers": ["my-serializer-module"]
}
}
```
## Writing plugins
A plugin is a JavaScript object.
If `options` has a `plugins` array: for the first plugin whose `test(val)` method returns a truthy value, then `prettyFormat(val, options)` returns the result from either:
- `serialize(val, …)` method of the **improved** interface (available in **version 21** or later)
- `print(val, …)` method of the **original** interface (if plugin does not have `serialize` method)
### test
Write `test` so it can receive `val` argument of any type. To serialize **objects** which have certain properties, then a guarded expression like `val != null && …` or more concise `val && …` prevents the following errors:
- `TypeError: Cannot read property 'whatever' of null`
- `TypeError: Cannot read property 'whatever' of undefined`
For example, `test` method of built-in `ReactElement` plugin:
```js
const elementSymbol = Symbol.for('react.element');
const test = val => val && val.$$typeof === elementSymbol;
```
Pay attention to efficiency in `test` because `pretty-format` calls it often.
### serialize
The **improved** interface is available in **version 21** or later.
Write `serialize` to return a string, given the arguments:
- `val` which “passed the test”
- unchanging `config` object: derived from `options`
- current `indentation` string: concatenate to `indent` from `config`
- current `depth` number: compare to `maxDepth` from `config`
- current `refs` array: find circular references in objects
- `printer` callback function: serialize children
### config
<!-- prettier-ignore -->
| key | type | description |
| :------------------ | :-------- | :------------------------------------------------------ |
| `callToJSON` | `boolean` | call `toJSON` method (if it exists) on objects |
| `colors` | `Object` | escape codes for colors to highlight syntax |
| `escapeRegex` | `boolean` | escape special characters in regular expressions |
| `escapeString` | `boolean` | escape special characters in strings |
| `indent` | `string` | spaces in each level of indentation |
| `maxDepth` | `number` | levels to print in arrays, objects, elements, and so on |
| `min` | `boolean` | minimize added space: no indentation nor line breaks |
| `plugins` | `array` | plugins to serialize application-specific data types |
| `printFunctionName` | `boolean` | include or omit the name of a function |
| `spacingInner` | `strong` | spacing to separate items in a list |
| `spacingOuter` | `strong` | spacing to enclose a list of items |
Each property of `colors` in `config` corresponds to a property of `theme` in `options`:
- the key is the same (for example, `tag`)
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
Some properties in `config` are derived from `min` in `options`:
- `spacingInner` and `spacingOuter` are **newline** if `min` is `false`
- `spacingInner` is **space** and `spacingOuter` is **empty string** if `min` is `true`
### Example of serialize and test
This plugin is a pattern you can apply to serialize composite data types. Side note: `pretty-format` does not need a plugin to serialize arrays.
```js
// We reused more code when we factored out a function for child items
// that is independent of depth, name, and enclosing punctuation (see below).
const SEPARATOR = ',';
function serializeItems(items, config, indentation, depth, refs, printer) {
if (items.length === 0) {
return '';
}
const indentationItems = indentation + config.indent;
return (
config.spacingOuter +
items
.map(
item =>
indentationItems +
printer(item, config, indentationItems, depth, refs), // callback
)
.join(SEPARATOR + config.spacingInner) +
(config.min ? '' : SEPARATOR) + // following the last item
config.spacingOuter +
indentation
);
}
const plugin = {
test(val) {
return Array.isArray(val);
},
serialize(array, config, indentation, depth, refs, printer) {
const name = array.constructor.name;
return ++depth > config.maxDepth
? '[' + name + ']'
: (config.min ? '' : name + ' ') +
'[' +
serializeItems(array, config, indentation, depth, refs, printer) +
']';
},
};
```
```js
const val = {
filter: 'completed',
items: [
{
text: 'Write test',
completed: true,
},
{
text: 'Write serialize',
completed: true,
},
],
};
```
```js
console.log(
prettyFormat(val, {
plugins: [plugin],
}),
);
/*
Object {
"filter": "completed",
"items": Array [
Object {
"completed": true,
"text": "Write test",
},
Object {
"completed": true,
"text": "Write serialize",
},
],
}
*/
```
```js
console.log(
prettyFormat(val, {
indent: 4,
plugins: [plugin],
}),
);
/*
Object {
"filter": "completed",
"items": Array [
Object {
"completed": true,
"text": "Write test",
},
Object {
"completed": true,
"text": "Write serialize",
},
],
}
*/
```
```js
console.log(
prettyFormat(val, {
maxDepth: 1,
plugins: [plugin],
}),
);
/*
Object {
"filter": "completed",
"items": [Array],
}
*/
```
```js
console.log(
prettyFormat(val, {
min: true,
plugins: [plugin],
}),
);
/*
{"filter": "completed", "items": [{"completed": true, "text": "Write test"}, {"completed": true, "text": "Write serialize"}]}
*/
```
### print
The **original** interface is adequate for plugins:
- that **do not** depend on options other than `highlight` or `min`
- that **do not** depend on `depth` or `refs` in recursive traversal, and
- if values either
- do **not** require indentation, or
- do **not** occur as children of JavaScript data structures (for example, array)
Write `print` to return a string, given the arguments:
- `val` which “passed the test”
- current `printer(valChild)` callback function: serialize children
- current `indenter(lines)` callback function: indent lines at the next level
- unchanging `config` object: derived from `options`
- unchanging `colors` object: derived from `options`
The 3 properties of `config` are `min` in `options` and:
- `spacing` and `edgeSpacing` are **newline** if `min` is `false`
- `spacing` is **space** and `edgeSpacing` is **empty string** if `min` is `true`
Each property of `colors` corresponds to a property of `theme` in `options`:
- the key is the same (for example, `tag`)
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
### Example of print and test
This plugin prints functions with the **number of named arguments** excluding rest argument.
```js
const plugin = {
print(val) {
return `[Function ${val.name || 'anonymous'} ${val.length}]`;
},
test(val) {
return typeof val === 'function';
},
};
```
```js
const val = {
onClick(event) {},
render() {},
};
prettyFormat(val, {
plugins: [plugin],
});
/*
Object {
"onClick": [Function onClick 1],
"render": [Function render 0],
}
*/
prettyFormat(val);
/*
Object {
"onClick": [Function onClick],
"render": [Function render],
}
*/
```
This plugin **ignores** the `printFunctionName` option. That limitation of the original `print` interface is a reason to use the improved `serialize` interface, described above.
```js
prettyFormat(val, {
plugins: [pluginOld],
printFunctionName: false,
});
/*
Object {
"onClick": [Function onClick 1],
"render": [Function render 0],
}
*/
prettyFormat(val, {
printFunctionName: false,
});
/*
Object {
"onClick": [Function],
"render": [Function],
}
*/
```

View File

@ -0,0 +1,32 @@
/**
* 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, Printer, Refs } from './types';
/**
* Return entries (for example, of a map)
* with spacing, indentation, and comma
* without surrounding punctuation (for example, braces)
*/
export declare function printIteratorEntries(iterator: Iterator<[unknown, unknown]>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, separator?: string): string;
/**
* Return values (for example, of a set)
* with spacing, indentation, and comma
* without surrounding punctuation (braces or brackets)
*/
export declare function printIteratorValues(iterator: Iterator<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
/**
* Return items (for example, of an array)
* with spacing, indentation, and comma
* without surrounding punctuation (for example, brackets)
**/
export declare function printListItems(list: ArrayLike<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
/**
* Return properties of an object
* with spacing, indentation, and comma
* without surrounding punctuation (for example, braces)
*/
export declare function printObjectProperties(val: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;

View File

@ -0,0 +1,185 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printIteratorEntries = printIteratorEntries;
exports.printIteratorValues = printIteratorValues;
exports.printListItems = printListItems;
exports.printObjectProperties = printObjectProperties;
/**
* 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 getKeysOfEnumerableProperties = object => {
const keys = Object.keys(object).sort();
if (Object.getOwnPropertySymbols) {
Object.getOwnPropertySymbols(object).forEach(symbol => {
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
keys.push(symbol);
}
});
}
return keys;
};
/**
* Return entries (for example, of a map)
* with spacing, indentation, and comma
* without surrounding punctuation (for example, braces)
*/
function printIteratorEntries(
iterator,
config,
indentation,
depth,
refs,
printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
// What a distracting diff if you change a data structure to/from
// ECMAScript Object or Immutable.Map/OrderedMap which use the default.
separator = ': '
) {
let result = '';
let current = iterator.next();
if (!current.done) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
while (!current.done) {
const name = printer(
current.value[0],
config,
indentationNext,
depth,
refs
);
const value = printer(
current.value[1],
config,
indentationNext,
depth,
refs
);
result += indentationNext + name + separator + value;
current = iterator.next();
if (!current.done) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
/**
* Return values (for example, of a set)
* with spacing, indentation, and comma
* without surrounding punctuation (braces or brackets)
*/
function printIteratorValues(
iterator,
config,
indentation,
depth,
refs,
printer
) {
let result = '';
let current = iterator.next();
if (!current.done) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
while (!current.done) {
result +=
indentationNext +
printer(current.value, config, indentationNext, depth, refs);
current = iterator.next();
if (!current.done) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
/**
* Return items (for example, of an array)
* with spacing, indentation, and comma
* without surrounding punctuation (for example, brackets)
**/
function printListItems(list, config, indentation, depth, refs, printer) {
let result = '';
if (list.length) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
for (let i = 0; i < list.length; i++) {
result +=
indentationNext +
printer(list[i], config, indentationNext, depth, refs);
if (i < list.length - 1) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
/**
* Return properties of an object
* with spacing, indentation, and comma
* without surrounding punctuation (for example, braces)
*/
function printObjectProperties(val, config, indentation, depth, refs, printer) {
let result = '';
const keys = getKeysOfEnumerableProperties(val);
if (keys.length) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const name = printer(key, config, indentationNext, depth, refs);
const value = printer(val[key], config, indentationNext, depth, refs);
result += indentationNext + name + ': ' + value;
if (i < keys.length - 1) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}

View File

@ -0,0 +1,37 @@
/**
* 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 * as PrettyFormat from './types';
/**
* Returns a presentation string of your `val` object
* @param val any potential JavaScript object
* @param options Custom settings
*/
declare function prettyFormat(val: unknown, options?: PrettyFormat.OptionsReceived): string;
declare namespace prettyFormat {
var plugins: {
AsymmetricMatcher: PrettyFormat.NewPlugin;
ConvertAnsi: PrettyFormat.NewPlugin;
DOMCollection: PrettyFormat.NewPlugin;
DOMElement: PrettyFormat.NewPlugin;
Immutable: PrettyFormat.NewPlugin;
ReactElement: PrettyFormat.NewPlugin;
ReactTestComponent: PrettyFormat.NewPlugin;
};
}
declare namespace prettyFormat {
type Colors = PrettyFormat.Colors;
type Config = PrettyFormat.Config;
type Options = PrettyFormat.Options;
type OptionsReceived = PrettyFormat.OptionsReceived;
type OldPlugin = PrettyFormat.OldPlugin;
type NewPlugin = PrettyFormat.NewPlugin;
type Plugin = PrettyFormat.Plugin;
type Plugins = PrettyFormat.Plugins;
type Refs = PrettyFormat.Refs;
type Theme = PrettyFormat.Theme;
}
export = prettyFormat;

View File

@ -0,0 +1,560 @@
'use strict';
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
var _collections = require('./collections');
var _AsymmetricMatcher = _interopRequireDefault(
require('./plugins/AsymmetricMatcher')
);
var _ConvertAnsi = _interopRequireDefault(require('./plugins/ConvertAnsi'));
var _DOMCollection = _interopRequireDefault(require('./plugins/DOMCollection'));
var _DOMElement = _interopRequireDefault(require('./plugins/DOMElement'));
var _Immutable = _interopRequireDefault(require('./plugins/Immutable'));
var _ReactElement = _interopRequireDefault(require('./plugins/ReactElement'));
var _ReactTestComponent = _interopRequireDefault(
require('./plugins/ReactTestComponent')
);
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.
*/
/* eslint-disable local/ban-types-eventually */
const toString = Object.prototype.toString;
const toISOString = Date.prototype.toISOString;
const errorToString = Error.prototype.toString;
const regExpToString = RegExp.prototype.toString;
/**
* Explicitly comparing typeof constructor to function avoids undefined as name
* when mock identity-obj-proxy returns the key as the value for any key.
*/
const getConstructorName = val =>
(typeof val.constructor === 'function' && val.constructor.name) || 'Object';
/* global window */
/** Is val is equal to global window object? Works even if it does not exist :) */
const isWindow = val => typeof window !== 'undefined' && val === window;
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
const NEWLINE_REGEXP = /\n/gi;
class PrettyFormatPluginError extends Error {
constructor(message, stack) {
super(message);
this.stack = stack;
this.name = this.constructor.name;
}
}
function isToStringedArrayType(toStringed) {
return (
toStringed === '[object Array]' ||
toStringed === '[object ArrayBuffer]' ||
toStringed === '[object DataView]' ||
toStringed === '[object Float32Array]' ||
toStringed === '[object Float64Array]' ||
toStringed === '[object Int8Array]' ||
toStringed === '[object Int16Array]' ||
toStringed === '[object Int32Array]' ||
toStringed === '[object Uint8Array]' ||
toStringed === '[object Uint8ClampedArray]' ||
toStringed === '[object Uint16Array]' ||
toStringed === '[object Uint32Array]'
);
}
function printNumber(val) {
return Object.is(val, -0) ? '-0' : String(val);
}
function printBigInt(val) {
return String(`${val}n`);
}
function printFunction(val, printFunctionName) {
if (!printFunctionName) {
return '[Function]';
}
return '[Function ' + (val.name || 'anonymous') + ']';
}
function printSymbol(val) {
return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
}
function printError(val) {
return '[' + errorToString.call(val) + ']';
}
/**
* The first port of call for printing an object, handles most of the
* data-types in JS.
*/
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
if (val === true || val === false) {
return '' + val;
}
if (val === undefined) {
return 'undefined';
}
if (val === null) {
return 'null';
}
const typeOf = typeof val;
if (typeOf === 'number') {
return printNumber(val);
}
if (typeOf === 'bigint') {
return printBigInt(val);
}
if (typeOf === 'string') {
if (escapeString) {
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
}
return '"' + val + '"';
}
if (typeOf === 'function') {
return printFunction(val, printFunctionName);
}
if (typeOf === 'symbol') {
return printSymbol(val);
}
const toStringed = toString.call(val);
if (toStringed === '[object WeakMap]') {
return 'WeakMap {}';
}
if (toStringed === '[object WeakSet]') {
return 'WeakSet {}';
}
if (
toStringed === '[object Function]' ||
toStringed === '[object GeneratorFunction]'
) {
return printFunction(val, printFunctionName);
}
if (toStringed === '[object Symbol]') {
return printSymbol(val);
}
if (toStringed === '[object Date]') {
return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
}
if (toStringed === '[object Error]') {
return printError(val);
}
if (toStringed === '[object RegExp]') {
if (escapeRegex) {
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
}
return regExpToString.call(val);
}
if (val instanceof Error) {
return printError(val);
}
return null;
}
/**
* Handles more complex objects ( such as objects with circular references.
* maps and sets etc )
*/
function printComplexValue(
val,
config,
indentation,
depth,
refs,
hasCalledToJSON
) {
if (refs.indexOf(val) !== -1) {
return '[Circular]';
}
refs = refs.slice();
refs.push(val);
const hitMaxDepth = ++depth > config.maxDepth;
const min = config.min;
if (
config.callToJSON &&
!hitMaxDepth &&
val.toJSON &&
typeof val.toJSON === 'function' &&
!hasCalledToJSON
) {
return printer(val.toJSON(), config, indentation, depth, refs, true);
}
const toStringed = toString.call(val);
if (toStringed === '[object Arguments]') {
return hitMaxDepth
? '[Arguments]'
: (min ? '' : 'Arguments ') +
'[' +
(0, _collections.printListItems)(
val,
config,
indentation,
depth,
refs,
printer
) +
']';
}
if (isToStringedArrayType(toStringed)) {
return hitMaxDepth
? '[' + val.constructor.name + ']'
: (min ? '' : val.constructor.name + ' ') +
'[' +
(0, _collections.printListItems)(
val,
config,
indentation,
depth,
refs,
printer
) +
']';
}
if (toStringed === '[object Map]') {
return hitMaxDepth
? '[Map]'
: 'Map {' +
(0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer,
' => '
) +
'}';
}
if (toStringed === '[object Set]') {
return hitMaxDepth
? '[Set]'
: 'Set {' +
(0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer
) +
'}';
} // Avoid failure to serialize global window object in jsdom test environment.
// For example, not even relevant if window is prop of React element.
return hitMaxDepth || isWindow(val)
? '[' + getConstructorName(val) + ']'
: (min ? '' : getConstructorName(val) + ' ') +
'{' +
(0, _collections.printObjectProperties)(
val,
config,
indentation,
depth,
refs,
printer
) +
'}';
}
function isNewPlugin(plugin) {
return plugin.serialize != null;
}
function printPlugin(plugin, val, config, indentation, depth, refs) {
let printed;
try {
printed = isNewPlugin(plugin)
? plugin.serialize(val, config, indentation, depth, refs, printer)
: plugin.print(
val,
valChild => printer(valChild, config, indentation, depth, refs),
str => {
const indentationNext = indentation + config.indent;
return (
indentationNext +
str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
);
},
{
edgeSpacing: config.spacingOuter,
min: config.min,
spacing: config.spacingInner
},
config.colors
);
} catch (error) {
throw new PrettyFormatPluginError(error.message, error.stack);
}
if (typeof printed !== 'string') {
throw new Error(
`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
);
}
return printed;
}
function findPlugin(plugins, val) {
for (let p = 0; p < plugins.length; p++) {
try {
if (plugins[p].test(val)) {
return plugins[p];
}
} catch (error) {
throw new PrettyFormatPluginError(error.message, error.stack);
}
}
return null;
}
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
const plugin = findPlugin(config.plugins, val);
if (plugin !== null) {
return printPlugin(plugin, val, config, indentation, depth, refs);
}
const basicResult = printBasicValue(
val,
config.printFunctionName,
config.escapeRegex,
config.escapeString
);
if (basicResult !== null) {
return basicResult;
}
return printComplexValue(
val,
config,
indentation,
depth,
refs,
hasCalledToJSON
);
}
const DEFAULT_THEME = {
comment: 'gray',
content: 'reset',
prop: 'yellow',
tag: 'cyan',
value: 'green'
};
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
const DEFAULT_OPTIONS = {
callToJSON: true,
escapeRegex: false,
escapeString: true,
highlight: false,
indent: 2,
maxDepth: Infinity,
min: false,
plugins: [],
printFunctionName: true,
theme: DEFAULT_THEME
};
function validateOptions(options) {
Object.keys(options).forEach(key => {
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
throw new Error(`pretty-format: Unknown option "${key}".`);
}
});
if (options.min && options.indent !== undefined && options.indent !== 0) {
throw new Error(
'pretty-format: Options "min" and "indent" cannot be used together.'
);
}
if (options.theme !== undefined) {
if (options.theme === null) {
throw new Error(`pretty-format: Option "theme" must not be null.`);
}
if (typeof options.theme !== 'object') {
throw new Error(
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
);
}
}
}
const getColorsHighlight = options =>
DEFAULT_THEME_KEYS.reduce((colors, key) => {
const value =
options.theme && options.theme[key] !== undefined
? options.theme[key]
: DEFAULT_THEME[key];
const color = value && _ansiStyles.default[value];
if (
color &&
typeof color.close === 'string' &&
typeof color.open === 'string'
) {
colors[key] = color;
} else {
throw new Error(
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
);
}
return colors;
}, Object.create(null));
const getColorsEmpty = () =>
DEFAULT_THEME_KEYS.reduce((colors, key) => {
colors[key] = {
close: '',
open: ''
};
return colors;
}, Object.create(null));
const getPrintFunctionName = options =>
options && options.printFunctionName !== undefined
? options.printFunctionName
: DEFAULT_OPTIONS.printFunctionName;
const getEscapeRegex = options =>
options && options.escapeRegex !== undefined
? options.escapeRegex
: DEFAULT_OPTIONS.escapeRegex;
const getEscapeString = options =>
options && options.escapeString !== undefined
? options.escapeString
: DEFAULT_OPTIONS.escapeString;
const getConfig = options => ({
callToJSON:
options && options.callToJSON !== undefined
? options.callToJSON
: DEFAULT_OPTIONS.callToJSON,
colors:
options && options.highlight
? getColorsHighlight(options)
: getColorsEmpty(),
escapeRegex: getEscapeRegex(options),
escapeString: getEscapeString(options),
indent:
options && options.min
? ''
: createIndent(
options && options.indent !== undefined
? options.indent
: DEFAULT_OPTIONS.indent
),
maxDepth:
options && options.maxDepth !== undefined
? options.maxDepth
: DEFAULT_OPTIONS.maxDepth,
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
plugins:
options && options.plugins !== undefined
? options.plugins
: DEFAULT_OPTIONS.plugins,
printFunctionName: getPrintFunctionName(options),
spacingInner: options && options.min ? ' ' : '\n',
spacingOuter: options && options.min ? '' : '\n'
});
function createIndent(indent) {
return new Array(indent + 1).join(' ');
}
/**
* Returns a presentation string of your `val` object
* @param val any potential JavaScript object
* @param options Custom settings
*/
function prettyFormat(val, options) {
if (options) {
validateOptions(options);
if (options.plugins) {
const plugin = findPlugin(options.plugins, val);
if (plugin !== null) {
return printPlugin(plugin, val, getConfig(options), '', 0, []);
}
}
}
const basicResult = printBasicValue(
val,
getPrintFunctionName(options),
getEscapeRegex(options),
getEscapeString(options)
);
if (basicResult !== null) {
return basicResult;
}
return printComplexValue(val, getConfig(options), '', 0, []);
}
prettyFormat.plugins = {
AsymmetricMatcher: _AsymmetricMatcher.default,
ConvertAnsi: _ConvertAnsi.default,
DOMCollection: _DOMCollection.default,
DOMElement: _DOMElement.default,
Immutable: _Immutable.default,
ReactElement: _ReactElement.default,
ReactTestComponent: _ReactTestComponent.default
};
module.exports = prettyFormat;

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 { NewPlugin } from '../types';
export declare const serialize: NewPlugin['serialize'];
export declare const test: NewPlugin['test'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,103 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.serialize = void 0;
var _collections = require('../collections');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const asymmetricMatcher =
typeof Symbol === 'function' && Symbol.for
? Symbol.for('jest.asymmetricMatcher')
: 0x1357a5;
const SPACE = ' ';
const serialize = (val, config, indentation, depth, refs, printer) => {
const stringedValue = val.toString();
if (
stringedValue === 'ArrayContaining' ||
stringedValue === 'ArrayNotContaining'
) {
if (++depth > config.maxDepth) {
return '[' + stringedValue + ']';
}
return (
stringedValue +
SPACE +
'[' +
(0, _collections.printListItems)(
val.sample,
config,
indentation,
depth,
refs,
printer
) +
']'
);
}
if (
stringedValue === 'ObjectContaining' ||
stringedValue === 'ObjectNotContaining'
) {
if (++depth > config.maxDepth) {
return '[' + stringedValue + ']';
}
return (
stringedValue +
SPACE +
'{' +
(0, _collections.printObjectProperties)(
val.sample,
config,
indentation,
depth,
refs,
printer
) +
'}'
);
}
if (
stringedValue === 'StringMatching' ||
stringedValue === 'StringNotMatching'
) {
return (
stringedValue +
SPACE +
printer(val.sample, config, indentation, depth, refs)
);
}
if (
stringedValue === 'StringContaining' ||
stringedValue === 'StringNotContaining'
) {
return (
stringedValue +
SPACE +
printer(val.sample, config, indentation, depth, refs)
);
}
return val.toAsymmetricMatcher();
};
exports.serialize = serialize;
const test = val => val && val.$$typeof === asymmetricMatcher;
exports.test = test;
const plugin = {
serialize,
test
};
var _default = plugin;
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.
*/
import type { NewPlugin } from '../types';
export declare const test: NewPlugin['test'];
export declare const serialize: NewPlugin['serialize'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,96 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.serialize = exports.test = void 0;
var _ansiRegex = _interopRequireDefault(require('ansi-regex'));
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
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 toHumanReadableAnsi = text =>
text.replace((0, _ansiRegex.default)(), match => {
switch (match) {
case _ansiStyles.default.red.close:
case _ansiStyles.default.green.close:
case _ansiStyles.default.cyan.close:
case _ansiStyles.default.gray.close:
case _ansiStyles.default.white.close:
case _ansiStyles.default.yellow.close:
case _ansiStyles.default.bgRed.close:
case _ansiStyles.default.bgGreen.close:
case _ansiStyles.default.bgYellow.close:
case _ansiStyles.default.inverse.close:
case _ansiStyles.default.dim.close:
case _ansiStyles.default.bold.close:
case _ansiStyles.default.reset.open:
case _ansiStyles.default.reset.close:
return '</>';
case _ansiStyles.default.red.open:
return '<red>';
case _ansiStyles.default.green.open:
return '<green>';
case _ansiStyles.default.cyan.open:
return '<cyan>';
case _ansiStyles.default.gray.open:
return '<gray>';
case _ansiStyles.default.white.open:
return '<white>';
case _ansiStyles.default.yellow.open:
return '<yellow>';
case _ansiStyles.default.bgRed.open:
return '<bgRed>';
case _ansiStyles.default.bgGreen.open:
return '<bgGreen>';
case _ansiStyles.default.bgYellow.open:
return '<bgYellow>';
case _ansiStyles.default.inverse.open:
return '<inverse>';
case _ansiStyles.default.dim.open:
return '<dim>';
case _ansiStyles.default.bold.open:
return '<bold>';
default:
return '';
}
});
const test = val =>
typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
exports.test = test;
const serialize = (val, config, indentation, depth, refs, printer) =>
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
exports.serialize = serialize;
const plugin = {
serialize,
test
};
var _default = plugin;
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.
*/
import type { NewPlugin } from '../types';
export declare const test: NewPlugin['test'];
export declare const serialize: NewPlugin['serialize'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,80 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.serialize = exports.test = void 0;
var _collections = require('../collections');
/**
* 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.
*/
/* eslint-disable local/ban-types-eventually */
const SPACE = ' ';
const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
const testName = name =>
OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
const test = val =>
val &&
val.constructor &&
!!val.constructor.name &&
testName(val.constructor.name);
exports.test = test;
const isNamedNodeMap = collection =>
collection.constructor.name === 'NamedNodeMap';
const serialize = (collection, config, indentation, depth, refs, printer) => {
const name = collection.constructor.name;
if (++depth > config.maxDepth) {
return '[' + name + ']';
}
return (
(config.min ? '' : name + SPACE) +
(OBJECT_NAMES.indexOf(name) !== -1
? '{' +
(0, _collections.printObjectProperties)(
isNamedNodeMap(collection)
? Array.from(collection).reduce((props, attribute) => {
props[attribute.name] = attribute.value;
return props;
}, {})
: {...collection},
config,
indentation,
depth,
refs,
printer
) +
'}'
: '[' +
(0, _collections.printListItems)(
Array.from(collection),
config,
indentation,
depth,
refs,
printer
) +
']')
);
};
exports.serialize = serialize;
const plugin = {
serialize,
test
};
var _default = plugin;
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.
*/
import type { NewPlugin } from '../types';
export declare const test: NewPlugin['test'];
export declare const serialize: NewPlugin['serialize'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,125 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.serialize = exports.test = void 0;
var _markup = require('./lib/markup');
/**
* 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 ELEMENT_NODE = 1;
const TEXT_NODE = 3;
const COMMENT_NODE = 8;
const FRAGMENT_NODE = 11;
const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
const testNode = val => {
var _val$hasAttribute;
const constructorName = val.constructor.name;
const {nodeType, tagName} = val;
const isCustomElement =
(typeof tagName === 'string' && tagName.includes('-')) ||
((_val$hasAttribute = val.hasAttribute) === null ||
_val$hasAttribute === void 0
? void 0
: _val$hasAttribute.call(val, 'is'));
return (
(nodeType === ELEMENT_NODE &&
(ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
(nodeType === TEXT_NODE && constructorName === 'Text') ||
(nodeType === COMMENT_NODE && constructorName === 'Comment') ||
(nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
);
};
const test = val => {
var _val$constructor;
return (
(val === null || val === void 0
? void 0
: (_val$constructor = val.constructor) === null ||
_val$constructor === void 0
? void 0
: _val$constructor.name) && testNode(val)
);
};
exports.test = test;
function nodeIsText(node) {
return node.nodeType === TEXT_NODE;
}
function nodeIsComment(node) {
return node.nodeType === COMMENT_NODE;
}
function nodeIsFragment(node) {
return node.nodeType === FRAGMENT_NODE;
}
const serialize = (node, config, indentation, depth, refs, printer) => {
if (nodeIsText(node)) {
return (0, _markup.printText)(node.data, config);
}
if (nodeIsComment(node)) {
return (0, _markup.printComment)(node.data, config);
}
const type = nodeIsFragment(node)
? `DocumentFragment`
: node.tagName.toLowerCase();
if (++depth > config.maxDepth) {
return (0, _markup.printElementAsLeaf)(type, config);
}
return (0, _markup.printElement)(
type,
(0, _markup.printProps)(
nodeIsFragment(node)
? []
: Array.from(node.attributes)
.map(attr => attr.name)
.sort(),
nodeIsFragment(node)
? {}
: Array.from(node.attributes).reduce((props, attribute) => {
props[attribute.name] = attribute.value;
return props;
}, {}),
config,
indentation + config.indent,
depth,
refs,
printer
),
(0, _markup.printChildren)(
Array.prototype.slice.call(node.childNodes || node.children),
config,
indentation + config.indent,
depth,
refs,
printer
),
config,
indentation
);
};
exports.serialize = serialize;
const plugin = {
serialize,
test
};
var _default = plugin;
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.
*/
import type { NewPlugin } from '../types';
export declare const serialize: NewPlugin['serialize'];
export declare const test: NewPlugin['test'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,247 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.serialize = void 0;
var _collections = require('../collections');
/**
* 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.
*/
// SENTINEL constants are from https://github.com/facebook/immutable-js
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
const getImmutableName = name => 'Immutable.' + name;
const printAsLeaf = name => '[' + name + ']';
const SPACE = ' ';
const LAZY = '…'; // Seq is lazy if it calls a method like filter
const printImmutableEntries = (
val,
config,
indentation,
depth,
refs,
printer,
type
) =>
++depth > config.maxDepth
? printAsLeaf(getImmutableName(type))
: getImmutableName(type) +
SPACE +
'{' +
(0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer
) +
'}'; // Record has an entries method because it is a collection in immutable v3.
// Return an iterator for Immutable Record from version v3 or v4.
function getRecordEntries(val) {
let i = 0;
return {
next() {
if (i < val._keys.length) {
const key = val._keys[i++];
return {
done: false,
value: [key, val.get(key)]
};
}
return {
done: true,
value: undefined
};
}
};
}
const printImmutableRecord = (
val,
config,
indentation,
depth,
refs,
printer
) => {
// _name property is defined only for an Immutable Record instance
// which was constructed with a second optional descriptive name arg
const name = getImmutableName(val._name || 'Record');
return ++depth > config.maxDepth
? printAsLeaf(name)
: name +
SPACE +
'{' +
(0, _collections.printIteratorEntries)(
getRecordEntries(val),
config,
indentation,
depth,
refs,
printer
) +
'}';
};
const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
const name = getImmutableName('Seq');
if (++depth > config.maxDepth) {
return printAsLeaf(name);
}
if (val[IS_KEYED_SENTINEL]) {
return (
name +
SPACE +
'{' + // from Immutable collection of entries or from ECMAScript object
(val._iter || val._object
? (0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer
)
: LAZY) +
'}'
);
}
return (
name +
SPACE +
'[' +
(val._iter || // from Immutable collection of values
val._array || // from ECMAScript array
val._collection || // from ECMAScript collection in immutable v4
val._iterable // from ECMAScript collection in immutable v3
? (0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer
)
: LAZY) +
']'
);
};
const printImmutableValues = (
val,
config,
indentation,
depth,
refs,
printer,
type
) =>
++depth > config.maxDepth
? printAsLeaf(getImmutableName(type))
: getImmutableName(type) +
SPACE +
'[' +
(0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer
) +
']';
const serialize = (val, config, indentation, depth, refs, printer) => {
if (val[IS_MAP_SENTINEL]) {
return printImmutableEntries(
val,
config,
indentation,
depth,
refs,
printer,
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
);
}
if (val[IS_LIST_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
'List'
);
}
if (val[IS_SET_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
);
}
if (val[IS_STACK_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
'Stack'
);
}
if (val[IS_SEQ_SENTINEL]) {
return printImmutableSeq(val, config, indentation, depth, refs, printer);
} // For compatibility with immutable v3 and v4, let record be the default.
return printImmutableRecord(val, config, indentation, depth, refs, printer);
}; // Explicitly comparing sentinel properties to true avoids false positive
// when mock identity-obj-proxy returns the key as the value for any key.
exports.serialize = serialize;
const test = val =>
val &&
(val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
exports.test = test;
const plugin = {
serialize,
test
};
var _default = plugin;
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.
*/
import type { NewPlugin } from '../types';
export declare const serialize: NewPlugin['serialize'];
export declare const test: NewPlugin['test'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,166 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.serialize = void 0;
var ReactIs = _interopRequireWildcard(require('react-is'));
var _markup = require('./lib/markup');
function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Given element.props.children, or subtree during recursive traversal,
// return flattened array of children.
const getChildren = (arg, children = []) => {
if (Array.isArray(arg)) {
arg.forEach(item => {
getChildren(item, children);
});
} else if (arg != null && arg !== false) {
children.push(arg);
}
return children;
};
const getType = element => {
const type = element.type;
if (typeof type === 'string') {
return type;
}
if (typeof type === 'function') {
return type.displayName || type.name || 'Unknown';
}
if (ReactIs.isFragment(element)) {
return 'React.Fragment';
}
if (ReactIs.isSuspense(element)) {
return 'React.Suspense';
}
if (typeof type === 'object' && type !== null) {
if (ReactIs.isContextProvider(element)) {
return 'Context.Provider';
}
if (ReactIs.isContextConsumer(element)) {
return 'Context.Consumer';
}
if (ReactIs.isForwardRef(element)) {
if (type.displayName) {
return type.displayName;
}
const functionName = type.render.displayName || type.render.name || '';
return functionName !== ''
? 'ForwardRef(' + functionName + ')'
: 'ForwardRef';
}
if (ReactIs.isMemo(element)) {
const functionName =
type.displayName || type.type.displayName || type.type.name || '';
return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
}
}
return 'UNDEFINED';
};
const getPropKeys = element => {
const {props} = element;
return Object.keys(props)
.filter(key => key !== 'children' && props[key] !== undefined)
.sort();
};
const serialize = (element, config, indentation, depth, refs, printer) =>
++depth > config.maxDepth
? (0, _markup.printElementAsLeaf)(getType(element), config)
: (0, _markup.printElement)(
getType(element),
(0, _markup.printProps)(
getPropKeys(element),
element.props,
config,
indentation + config.indent,
depth,
refs,
printer
),
(0, _markup.printChildren)(
getChildren(element.props.children),
config,
indentation + config.indent,
depth,
refs,
printer
),
config,
indentation
);
exports.serialize = serialize;
const test = val => val && ReactIs.isElement(val);
exports.test = test;
const plugin = {
serialize,
test
};
var _default = plugin;
exports.default = _default;

View File

@ -0,0 +1,18 @@
/**
* 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 { NewPlugin } from '../types';
export declare type ReactTestObject = {
$$typeof: symbol;
type: string;
props?: Record<string, unknown>;
children?: null | Array<ReactTestChild>;
};
declare type ReactTestChild = ReactTestObject | string | number;
export declare const serialize: NewPlugin['serialize'];
export declare const test: NewPlugin['test'];
declare const plugin: NewPlugin;
export default plugin;

View File

@ -0,0 +1,65 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.test = exports.serialize = void 0;
var _markup = require('./lib/markup');
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
const testSymbol =
typeof Symbol === 'function' && Symbol.for
? Symbol.for('react.test.json')
: 0xea71357;
const getPropKeys = object => {
const {props} = object;
return props
? Object.keys(props)
.filter(key => props[key] !== undefined)
.sort()
: [];
};
const serialize = (object, config, indentation, depth, refs, printer) =>
++depth > config.maxDepth
? (0, _markup.printElementAsLeaf)(object.type, config)
: (0, _markup.printElement)(
object.type,
object.props
? (0, _markup.printProps)(
getPropKeys(object),
object.props,
config,
indentation + config.indent,
depth,
refs,
printer
)
: '',
object.children
? (0, _markup.printChildren)(
object.children,
config,
indentation + config.indent,
depth,
refs,
printer
)
: '',
config,
indentation
);
exports.serialize = serialize;
const test = val => val && val.$$typeof === testSymbol;
exports.test = test;
const plugin = {
serialize,
test
};
var _default = plugin;
exports.default = _default;

View File

@ -0,0 +1,7 @@
/**
* 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.
*/
export default function escapeHTML(str: string): string;

View File

@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = escapeHTML;
/**
* 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.
*/
function escapeHTML(str) {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

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 { Config, Printer, Refs } from '../../types';
export declare const printProps: (keys: Array<string>, props: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
export declare const printChildren: (children: Array<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
export declare const printText: (text: string, config: Config) => string;
export declare const printComment: (comment: string, config: Config) => string;
export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string;
export declare const printElementAsLeaf: (type: string, config: Config) => string;

View File

@ -0,0 +1,147 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = void 0;
var _escapeHTML = _interopRequireDefault(require('./escapeHTML'));
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.
*/
// Return empty string if keys is empty.
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
const indentationNext = indentation + config.indent;
const colors = config.colors;
return keys
.map(key => {
const value = props[key];
let printed = printer(value, config, indentationNext, depth, refs);
if (typeof value !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed =
config.spacingOuter +
indentationNext +
printed +
config.spacingOuter +
indentation;
}
printed = '{' + printed + '}';
}
return (
config.spacingInner +
indentation +
colors.prop.open +
key +
colors.prop.close +
'=' +
colors.value.open +
printed +
colors.value.close
);
})
.join('');
}; // Return empty string if children is empty.
exports.printProps = printProps;
const printChildren = (children, config, indentation, depth, refs, printer) =>
children
.map(
child =>
config.spacingOuter +
indentation +
(typeof child === 'string'
? printText(child, config)
: printer(child, config, indentation, depth, refs))
)
.join('');
exports.printChildren = printChildren;
const printText = (text, config) => {
const contentColor = config.colors.content;
return (
contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
);
};
exports.printText = printText;
const printComment = (comment, config) => {
const commentColor = config.colors.comment;
return (
commentColor.open +
'<!--' +
(0, _escapeHTML.default)(comment) +
'-->' +
commentColor.close
);
}; // Separate the functions to format props, children, and element,
// so a plugin could override a particular function, if needed.
// Too bad, so sad: the traditional (but unnecessary) space
// in a self-closing tagColor requires a second test of printedProps.
exports.printComment = printComment;
const printElement = (
type,
printedProps,
printedChildren,
config,
indentation
) => {
const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type +
(printedProps &&
tagColor.close +
printedProps +
config.spacingOuter +
indentation +
tagColor.open) +
(printedChildren
? '>' +
tagColor.close +
printedChildren +
config.spacingOuter +
indentation +
tagColor.open +
'</' +
type
: (printedProps && !config.min ? '' : ' ') + '/') +
'>' +
tagColor.close
);
};
exports.printElement = printElement;
const printElementAsLeaf = (type, config) => {
const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type +
tagColor.close +
' …' +
tagColor.open +
' />' +
tagColor.close
);
};
exports.printElementAsLeaf = printElementAsLeaf;

View File

@ -0,0 +1,100 @@
/**
* 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.
*/
export declare type Colors = {
comment: {
close: string;
open: string;
};
content: {
close: string;
open: string;
};
prop: {
close: string;
open: string;
};
tag: {
close: string;
open: string;
};
value: {
close: string;
open: string;
};
};
declare type Indent = (arg0: string) => string;
export declare type Refs = Array<unknown>;
declare type Print = (arg0: unknown) => string;
export declare type Theme = {
comment: string;
content: string;
prop: string;
tag: string;
value: string;
};
declare type ThemeReceived = {
comment?: string;
content?: string;
prop?: string;
tag?: string;
value?: string;
};
export declare type Options = {
callToJSON: boolean;
escapeRegex: boolean;
escapeString: boolean;
highlight: boolean;
indent: number;
maxDepth: number;
min: boolean;
plugins: Plugins;
printFunctionName: boolean;
theme: Theme;
};
export declare type OptionsReceived = {
callToJSON?: boolean;
escapeRegex?: boolean;
escapeString?: boolean;
highlight?: boolean;
indent?: number;
maxDepth?: number;
min?: boolean;
plugins?: Plugins;
printFunctionName?: boolean;
theme?: ThemeReceived;
};
export declare type Config = {
callToJSON: boolean;
colors: Colors;
escapeRegex: boolean;
escapeString: boolean;
indent: string;
maxDepth: number;
min: boolean;
plugins: Plugins;
printFunctionName: boolean;
spacingInner: string;
spacingOuter: string;
};
export declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
declare type Test = (arg0: any) => boolean;
export declare type NewPlugin = {
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
test: Test;
};
declare type PluginOptions = {
edgeSpacing: string;
min: boolean;
spacing: string;
};
export declare type OldPlugin = {
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
test: Test;
};
export declare type Plugin = NewPlugin | OldPlugin;
export declare type Plugins = Array<Plugin>;
export {};

View File

@ -0,0 +1 @@
'use strict';

View File

@ -0,0 +1,37 @@
{
"name": "pretty-format",
"version": "26.6.2",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/pretty-format"
},
"license": "MIT",
"description": "Stringify any JavaScript value.",
"main": "build/index.js",
"types": "build/index.d.ts",
"author": "James Kyle <me@thejameskyle.com>",
"dependencies": {
"@jest/types": "^26.6.2",
"ansi-regex": "^5.0.0",
"ansi-styles": "^4.0.0",
"react-is": "^17.0.1"
},
"devDependencies": {
"@types/react": "*",
"@types/react-is": "^16.7.1",
"@types/react-test-renderer": "*",
"immutable": "4.0.0-rc.9",
"jest-util": "^26.6.2",
"react": "*",
"react-dom": "*",
"react-test-renderer": "*"
},
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4c46930615602cbf983fb7e8e82884c282a624d5"
}

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,104 @@
# `react-is`
This package allows you to test arbitrary values and see if they're a particular React element type.
## Installation
```sh
# Yarn
yarn add react-is
# NPM
npm install react-is
```
## Usage
### Determining if a Component is Valid
```js
import React from "react";
import * as ReactIs from "react-is";
class ClassComponent extends React.Component {
render() {
return React.createElement("div");
}
}
const FunctionComponent = () => React.createElement("div");
const ForwardRefComponent = React.forwardRef((props, ref) =>
React.createElement(Component, { forwardedRef: ref, ...props })
);
const Context = React.createContext(false);
ReactIs.isValidElementType("div"); // true
ReactIs.isValidElementType(ClassComponent); // true
ReactIs.isValidElementType(FunctionComponent); // true
ReactIs.isValidElementType(ForwardRefComponent); // true
ReactIs.isValidElementType(Context.Provider); // true
ReactIs.isValidElementType(Context.Consumer); // true
ReactIs.isValidElementType(React.createFactory("div")); // true
```
### Determining an Element's Type
#### Context
```js
import React from "react";
import * as ReactIs from 'react-is';
const ThemeContext = React.createContext("blue");
ReactIs.isContextConsumer(<ThemeContext.Consumer />); // true
ReactIs.isContextProvider(<ThemeContext.Provider />); // true
ReactIs.typeOf(<ThemeContext.Provider />) === ReactIs.ContextProvider; // true
ReactIs.typeOf(<ThemeContext.Consumer />) === ReactIs.ContextConsumer; // true
```
#### Element
```js
import React from "react";
import * as ReactIs from 'react-is';
ReactIs.isElement(<div />); // true
ReactIs.typeOf(<div />) === ReactIs.Element; // true
```
#### Fragment
```js
import React from "react";
import * as ReactIs from 'react-is';
ReactIs.isFragment(<></>); // true
ReactIs.typeOf(<></>) === ReactIs.Fragment; // true
```
#### Portal
```js
import React from "react";
import ReactDOM from "react-dom";
import * as ReactIs from 'react-is';
const div = document.createElement("div");
const portal = ReactDOM.createPortal(<div />, div);
ReactIs.isPortal(portal); // true
ReactIs.typeOf(portal) === ReactIs.Portal; // true
```
#### StrictMode
```js
import React from "react";
import * as ReactIs from 'react-is';
ReactIs.isStrictMode(<React.StrictMode />); // true
ReactIs.typeOf(<React.StrictMode />) === ReactIs.StrictMode; // true
```

View File

@ -0,0 +1,8 @@
{
"branch": "pull/21051",
"buildNumber": "287151",
"checksum": "94f5c65",
"commit": "12adaffef",
"environment": "ci",
"reactVersion": "17.0.0-12adaffef"
}

View File

@ -0,0 +1,226 @@
/** @license React v17.0.2
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE = 0xeac7;
var REACT_PORTAL_TYPE = 0xeaca;
var REACT_FRAGMENT_TYPE = 0xeacb;
var REACT_STRICT_MODE_TYPE = 0xeacc;
var REACT_PROFILER_TYPE = 0xead2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
var REACT_BLOCK_TYPE = 0xead9;
var REACT_SERVER_BLOCK_TYPE = 0xeada;
var REACT_FUNDAMENTAL_TYPE = 0xead5;
var REACT_SCOPE_TYPE = 0xead7;
var REACT_OPAQUE_ID_TYPE = 0xeae0;
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
var REACT_OFFSCREEN_TYPE = 0xeae2;
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
REACT_PORTAL_TYPE = symbolFor('react.portal');
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
REACT_MEMO_TYPE = symbolFor('react.memo');
REACT_LAZY_TYPE = symbolFor('react.lazy');
REACT_BLOCK_TYPE = symbolFor('react.block');
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
REACT_SCOPE_TYPE = symbolFor('react.scope');
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
}
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
var enableScopeAPI = false; // Experimental Create Event Handle API.
function isValidElementType(type) {
if (typeof type === 'string' || typeof type === 'function') {
return true;
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
return true;
}
if (typeof type === 'object' && type !== null) {
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
return true;
}
}
return false;
}
function typeOf(object) {
if (typeof object === 'object' && object !== null) {
var $$typeof = object.$$typeof;
switch ($$typeof) {
case REACT_ELEMENT_TYPE:
var type = object.type;
switch (type) {
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_SUSPENSE_TYPE:
case REACT_SUSPENSE_LIST_TYPE:
return type;
default:
var $$typeofType = type && type.$$typeof;
switch ($$typeofType) {
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
case REACT_MEMO_TYPE:
case REACT_PROVIDER_TYPE:
return $$typeofType;
default:
return $$typeof;
}
}
case REACT_PORTAL_TYPE:
return $$typeof;
}
}
return undefined;
}
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
var Lazy = REACT_LAZY_TYPE;
var Memo = REACT_MEMO_TYPE;
var Portal = REACT_PORTAL_TYPE;
var Profiler = REACT_PROFILER_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false;
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
function isAsyncMode(object) {
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
}
}
return false;
}
function isConcurrentMode(object) {
{
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
}
}
return false;
}
function isContextConsumer(object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
function isContextProvider(object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
function isElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
}
function isForwardRef(object) {
return typeOf(object) === REACT_FORWARD_REF_TYPE;
}
function isFragment(object) {
return typeOf(object) === REACT_FRAGMENT_TYPE;
}
function isLazy(object) {
return typeOf(object) === REACT_LAZY_TYPE;
}
function isMemo(object) {
return typeOf(object) === REACT_MEMO_TYPE;
}
function isPortal(object) {
return typeOf(object) === REACT_PORTAL_TYPE;
}
function isProfiler(object) {
return typeOf(object) === REACT_PROFILER_TYPE;
}
function isStrictMode(object) {
return typeOf(object) === REACT_STRICT_MODE_TYPE;
}
function isSuspense(object) {
return typeOf(object) === REACT_SUSPENSE_TYPE;
}
exports.ContextConsumer = ContextConsumer;
exports.ContextProvider = ContextProvider;
exports.Element = Element;
exports.ForwardRef = ForwardRef;
exports.Fragment = Fragment;
exports.Lazy = Lazy;
exports.Memo = Memo;
exports.Portal = Portal;
exports.Profiler = Profiler;
exports.StrictMode = StrictMode;
exports.Suspense = Suspense;
exports.isAsyncMode = isAsyncMode;
exports.isConcurrentMode = isConcurrentMode;
exports.isContextConsumer = isContextConsumer;
exports.isContextProvider = isContextProvider;
exports.isElement = isElement;
exports.isForwardRef = isForwardRef;
exports.isFragment = isFragment;
exports.isLazy = isLazy;
exports.isMemo = isMemo;
exports.isPortal = isPortal;
exports.isProfiler = isProfiler;
exports.isStrictMode = isStrictMode;
exports.isSuspense = isSuspense;
exports.isValidElementType = isValidElementType;
exports.typeOf = typeOf;
})();
}

View File

@ -0,0 +1,14 @@
/** @license React v17.0.2
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden")}
function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;exports.ContextConsumer=h;exports.ContextProvider=z;exports.Element=A;exports.ForwardRef=B;exports.Fragment=C;exports.Lazy=D;exports.Memo=E;exports.Portal=F;exports.Profiler=G;exports.StrictMode=H;
exports.Suspense=I;exports.isAsyncMode=function(){return!1};exports.isConcurrentMode=function(){return!1};exports.isContextConsumer=function(a){return y(a)===h};exports.isContextProvider=function(a){return y(a)===g};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};exports.isForwardRef=function(a){return y(a)===k};exports.isFragment=function(a){return y(a)===d};exports.isLazy=function(a){return y(a)===p};exports.isMemo=function(a){return y(a)===n};
exports.isPortal=function(a){return y(a)===c};exports.isProfiler=function(a){return y(a)===f};exports.isStrictMode=function(a){return y(a)===e};exports.isSuspense=function(a){return y(a)===l};exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
exports.typeOf=y;

View File

@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-is.production.min.js');
} else {
module.exports = require('./cjs/react-is.development.js');
}

View File

@ -0,0 +1,27 @@
{
"name": "react-is",
"version": "17.0.2",
"description": "Brand checking of React Elements.",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react-is"
},
"keywords": [
"react"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://reactjs.org/",
"files": [
"LICENSE",
"README.md",
"build-info.json",
"index.js",
"cjs/",
"umd/"
]
}

View File

@ -0,0 +1,225 @@
/** @license React v17.0.2
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.ReactIs = {}));
}(this, (function (exports) { 'use strict';
// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE = 0xeac7;
var REACT_PORTAL_TYPE = 0xeaca;
var REACT_FRAGMENT_TYPE = 0xeacb;
var REACT_STRICT_MODE_TYPE = 0xeacc;
var REACT_PROFILER_TYPE = 0xead2;
var REACT_PROVIDER_TYPE = 0xeacd;
var REACT_CONTEXT_TYPE = 0xeace;
var REACT_FORWARD_REF_TYPE = 0xead0;
var REACT_SUSPENSE_TYPE = 0xead1;
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
var REACT_MEMO_TYPE = 0xead3;
var REACT_LAZY_TYPE = 0xead4;
var REACT_BLOCK_TYPE = 0xead9;
var REACT_SERVER_BLOCK_TYPE = 0xeada;
var REACT_FUNDAMENTAL_TYPE = 0xead5;
var REACT_SCOPE_TYPE = 0xead7;
var REACT_OPAQUE_ID_TYPE = 0xeae0;
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
var REACT_OFFSCREEN_TYPE = 0xeae2;
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
if (typeof Symbol === 'function' && Symbol.for) {
var symbolFor = Symbol.for;
REACT_ELEMENT_TYPE = symbolFor('react.element');
REACT_PORTAL_TYPE = symbolFor('react.portal');
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
REACT_PROFILER_TYPE = symbolFor('react.profiler');
REACT_PROVIDER_TYPE = symbolFor('react.provider');
REACT_CONTEXT_TYPE = symbolFor('react.context');
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
REACT_MEMO_TYPE = symbolFor('react.memo');
REACT_LAZY_TYPE = symbolFor('react.lazy');
REACT_BLOCK_TYPE = symbolFor('react.block');
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
REACT_SCOPE_TYPE = symbolFor('react.scope');
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
}
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
var enableScopeAPI = false; // Experimental Create Event Handle API.
function isValidElementType(type) {
if (typeof type === 'string' || typeof type === 'function') {
return true;
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
return true;
}
if (typeof type === 'object' && type !== null) {
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
return true;
}
}
return false;
}
function typeOf(object) {
if (typeof object === 'object' && object !== null) {
var $$typeof = object.$$typeof;
switch ($$typeof) {
case REACT_ELEMENT_TYPE:
var type = object.type;
switch (type) {
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_SUSPENSE_TYPE:
case REACT_SUSPENSE_LIST_TYPE:
return type;
default:
var $$typeofType = type && type.$$typeof;
switch ($$typeofType) {
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
case REACT_MEMO_TYPE:
case REACT_PROVIDER_TYPE:
return $$typeofType;
default:
return $$typeof;
}
}
case REACT_PORTAL_TYPE:
return $$typeof;
}
}
return undefined;
}
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
var Lazy = REACT_LAZY_TYPE;
var Memo = REACT_MEMO_TYPE;
var Portal = REACT_PORTAL_TYPE;
var Profiler = REACT_PROFILER_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false;
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
function isAsyncMode(object) {
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
}
}
return false;
}
function isConcurrentMode(object) {
{
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
}
}
return false;
}
function isContextConsumer(object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
function isContextProvider(object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
function isElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
}
function isForwardRef(object) {
return typeOf(object) === REACT_FORWARD_REF_TYPE;
}
function isFragment(object) {
return typeOf(object) === REACT_FRAGMENT_TYPE;
}
function isLazy(object) {
return typeOf(object) === REACT_LAZY_TYPE;
}
function isMemo(object) {
return typeOf(object) === REACT_MEMO_TYPE;
}
function isPortal(object) {
return typeOf(object) === REACT_PORTAL_TYPE;
}
function isProfiler(object) {
return typeOf(object) === REACT_PROFILER_TYPE;
}
function isStrictMode(object) {
return typeOf(object) === REACT_STRICT_MODE_TYPE;
}
function isSuspense(object) {
return typeOf(object) === REACT_SUSPENSE_TYPE;
}
exports.ContextConsumer = ContextConsumer;
exports.ContextProvider = ContextProvider;
exports.Element = Element;
exports.ForwardRef = ForwardRef;
exports.Fragment = Fragment;
exports.Lazy = Lazy;
exports.Memo = Memo;
exports.Portal = Portal;
exports.Profiler = Profiler;
exports.StrictMode = StrictMode;
exports.Suspense = Suspense;
exports.isAsyncMode = isAsyncMode;
exports.isConcurrentMode = isConcurrentMode;
exports.isContextConsumer = isContextConsumer;
exports.isContextProvider = isContextProvider;
exports.isElement = isElement;
exports.isForwardRef = isForwardRef;
exports.isFragment = isFragment;
exports.isLazy = isLazy;
exports.isMemo = isMemo;
exports.isPortal = isPortal;
exports.isProfiler = isProfiler;
exports.isStrictMode = isStrictMode;
exports.isSuspense = isSuspense;
exports.isValidElementType = isValidElementType;
exports.typeOf = typeOf;
})));

View File

@ -0,0 +1,14 @@
/** @license React v17.0.2
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function(){'use strict';(function(b,d){"object"===typeof exports&&"undefined"!==typeof module?d(exports):"function"===typeof define&&define.amd?define(["exports"],d):(b=b||self,d(b.ReactIs={}))})(this,function(b){function d(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case q:switch(a=a.type,a){case e:case f:case g:case h:case t:return a;default:switch(a=a&&a.$$typeof,a){case k:case l:case m:case n:case p:return a;default:return b}}case r:return b}}}var q=60103,r=60106,e=60107,g=60108,f=60114,
p=60109,k=60110,l=60112,h=60113,t=60120,n=60115,m=60116,u=60121,v=60122,w=60117,x=60129,y=60131;if("function"===typeof Symbol&&Symbol.for){var c=Symbol.for;q=c("react.element");r=c("react.portal");e=c("react.fragment");g=c("react.strict_mode");f=c("react.profiler");p=c("react.provider");k=c("react.context");l=c("react.forward_ref");h=c("react.suspense");t=c("react.suspense_list");n=c("react.memo");m=c("react.lazy");u=c("react.block");v=c("react.server.block");w=c("react.fundamental");x=c("react.debug_trace_mode");
y=c("react.legacy_hidden")}b.ContextConsumer=k;b.ContextProvider=p;b.Element=q;b.ForwardRef=l;b.Fragment=e;b.Lazy=m;b.Memo=n;b.Portal=r;b.Profiler=f;b.StrictMode=g;b.Suspense=h;b.isAsyncMode=function(a){return!1};b.isConcurrentMode=function(a){return!1};b.isContextConsumer=function(a){return d(a)===k};b.isContextProvider=function(a){return d(a)===p};b.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===q};b.isForwardRef=function(a){return d(a)===l};b.isFragment=function(a){return d(a)===
e};b.isLazy=function(a){return d(a)===m};b.isMemo=function(a){return d(a)===n};b.isPortal=function(a){return d(a)===r};b.isProfiler=function(a){return d(a)===f};b.isStrictMode=function(a){return d(a)===g};b.isSuspense=function(a){return d(a)===h};b.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===f||a===x||a===g||a===h||a===t||a===y||"object"===typeof a&&null!==a&&(a.$$typeof===m||a.$$typeof===n||a.$$typeof===p||a.$$typeof===k||a.$$typeof===l||a.$$typeof===
w||a.$$typeof===u||a[0]===v)?!0:!1};b.typeOf=d});
})();

43
node_modules/jest-jasmine2/package.json generated vendored Normal file
View File

@ -0,0 +1,43 @@
{
"name": "jest-jasmine2",
"version": "26.6.3",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-jasmine2"
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@babel/traverse": "^7.1.0",
"@jest/environment": "^26.6.2",
"@jest/source-map": "^26.6.2",
"@jest/test-result": "^26.6.2",
"@jest/types": "^26.6.2",
"@types/node": "*",
"chalk": "^4.0.0",
"co": "^4.6.0",
"expect": "^26.6.2",
"is-generator-fn": "^2.0.0",
"jest-each": "^26.6.2",
"jest-matcher-utils": "^26.6.2",
"jest-message-util": "^26.6.2",
"jest-runtime": "^26.6.3",
"jest-snapshot": "^26.6.2",
"jest-util": "^26.6.2",
"pretty-format": "^26.6.2",
"throat": "^5.0.0"
},
"devDependencies": {
"@types/babel__traverse": "^7.0.4",
"@types/co": "^4.6.2"
},
"engines": {
"node": ">= 10.14.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "2f6931e91d5ab126de70caf150c68709752e7f6c"
}