mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
21
backend/apis/nodejs/node_modules/@jest/console/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/console/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
197
backend/apis/nodejs/node_modules/@jest/console/build/BufferedConsole.js
generated
vendored
Normal file
197
backend/apis/nodejs/node_modules/@jest/console/build/BufferedConsole.js
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _assert() {
|
||||
const data = require('assert');
|
||||
_assert = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _console() {
|
||||
const data = require('console');
|
||||
_console = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _util() {
|
||||
const data = require('util');
|
||||
_util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class BufferedConsole extends _console().Console {
|
||||
_buffer = [];
|
||||
_counters = {};
|
||||
_timers = {};
|
||||
_groupDepth = 0;
|
||||
Console = _console().Console;
|
||||
constructor() {
|
||||
super({
|
||||
write: message => {
|
||||
BufferedConsole.write(this._buffer, 'log', message, null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
static write(buffer, type, message, level) {
|
||||
const stackLevel = level != null ? level : 2;
|
||||
const rawStack = new (_jestUtil().ErrorWithStack)(
|
||||
undefined,
|
||||
BufferedConsole.write
|
||||
).stack;
|
||||
(0, _jestUtil().invariant)(rawStack != null, 'always have a stack trace');
|
||||
const origin = rawStack
|
||||
.split('\n')
|
||||
.slice(stackLevel)
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
buffer.push({
|
||||
message,
|
||||
origin,
|
||||
type
|
||||
});
|
||||
return buffer;
|
||||
}
|
||||
_log(type, message) {
|
||||
BufferedConsole.write(
|
||||
this._buffer,
|
||||
type,
|
||||
' '.repeat(this._groupDepth) + message,
|
||||
3
|
||||
);
|
||||
}
|
||||
assert(value, message) {
|
||||
try {
|
||||
(0, _assert().strict)(value, message);
|
||||
} catch (error) {
|
||||
if (!(error instanceof _assert().AssertionError)) {
|
||||
throw error;
|
||||
}
|
||||
// https://github.com/jestjs/jest/pull/13422#issuecomment-1273396392
|
||||
this._log('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
|
||||
}
|
||||
}
|
||||
count(label = 'default') {
|
||||
if (!this._counters[label]) {
|
||||
this._counters[label] = 0;
|
||||
}
|
||||
this._log(
|
||||
'count',
|
||||
(0, _util().format)(`${label}: ${++this._counters[label]}`)
|
||||
);
|
||||
}
|
||||
countReset(label = 'default') {
|
||||
this._counters[label] = 0;
|
||||
}
|
||||
debug(firstArg, ...rest) {
|
||||
this._log('debug', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
dir(firstArg, options = {}) {
|
||||
const representation = (0, _util().inspect)(firstArg, options);
|
||||
this._log('dir', (0, _util().formatWithOptions)(options, representation));
|
||||
}
|
||||
dirxml(firstArg, ...rest) {
|
||||
this._log('dirxml', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
error(firstArg, ...rest) {
|
||||
this._log('error', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
group(title, ...rest) {
|
||||
this._groupDepth++;
|
||||
if (title != null || rest.length > 0) {
|
||||
this._log(
|
||||
'group',
|
||||
_chalk().default.bold((0, _util().format)(title, ...rest))
|
||||
);
|
||||
}
|
||||
}
|
||||
groupCollapsed(title, ...rest) {
|
||||
this._groupDepth++;
|
||||
if (title != null || rest.length > 0) {
|
||||
this._log(
|
||||
'groupCollapsed',
|
||||
_chalk().default.bold((0, _util().format)(title, ...rest))
|
||||
);
|
||||
}
|
||||
}
|
||||
groupEnd() {
|
||||
if (this._groupDepth > 0) {
|
||||
this._groupDepth--;
|
||||
}
|
||||
}
|
||||
info(firstArg, ...rest) {
|
||||
this._log('info', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
log(firstArg, ...rest) {
|
||||
this._log('log', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
time(label = 'default') {
|
||||
if (this._timers[label] != null) {
|
||||
return;
|
||||
}
|
||||
this._timers[label] = new Date();
|
||||
}
|
||||
timeEnd(label = 'default') {
|
||||
const startTime = this._timers[label];
|
||||
if (startTime != null) {
|
||||
const endTime = new Date();
|
||||
const time = endTime.getTime() - startTime.getTime();
|
||||
this._log(
|
||||
'time',
|
||||
(0, _util().format)(`${label}: ${(0, _jestUtil().formatTime)(time)}`)
|
||||
);
|
||||
delete this._timers[label];
|
||||
}
|
||||
}
|
||||
timeLog(label = 'default', ...data) {
|
||||
const startTime = this._timers[label];
|
||||
if (startTime != null) {
|
||||
const endTime = new Date();
|
||||
const time = endTime.getTime() - startTime.getTime();
|
||||
this._log(
|
||||
'time',
|
||||
(0, _util().format)(
|
||||
`${label}: ${(0, _jestUtil().formatTime)(time)}`,
|
||||
...data
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
warn(firstArg, ...rest) {
|
||||
this._log('warn', (0, _util().format)(firstArg, ...rest));
|
||||
}
|
||||
getBuffer() {
|
||||
return this._buffer.length ? this._buffer : undefined;
|
||||
}
|
||||
}
|
||||
exports.default = BufferedConsole;
|
182
backend/apis/nodejs/node_modules/@jest/console/build/CustomConsole.js
generated
vendored
Normal file
182
backend/apis/nodejs/node_modules/@jest/console/build/CustomConsole.js
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _assert() {
|
||||
const data = require('assert');
|
||||
_assert = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _console() {
|
||||
const data = require('console');
|
||||
_console = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _util() {
|
||||
const data = require('util');
|
||||
_util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class CustomConsole extends _console().Console {
|
||||
_stdout;
|
||||
_stderr;
|
||||
_formatBuffer;
|
||||
_counters = {};
|
||||
_timers = {};
|
||||
_groupDepth = 0;
|
||||
Console = _console().Console;
|
||||
constructor(stdout, stderr, formatBuffer = (_type, message) => message) {
|
||||
super(stdout, stderr);
|
||||
this._stdout = stdout;
|
||||
this._stderr = stderr;
|
||||
this._formatBuffer = formatBuffer;
|
||||
}
|
||||
_log(type, message) {
|
||||
(0, _jestUtil().clearLine)(this._stdout);
|
||||
super.log(
|
||||
this._formatBuffer(type, ' '.repeat(this._groupDepth) + message)
|
||||
);
|
||||
}
|
||||
_logError(type, message) {
|
||||
(0, _jestUtil().clearLine)(this._stderr);
|
||||
super.error(
|
||||
this._formatBuffer(type, ' '.repeat(this._groupDepth) + message)
|
||||
);
|
||||
}
|
||||
assert(value, message) {
|
||||
try {
|
||||
(0, _assert().strict)(value, message);
|
||||
} catch (error) {
|
||||
if (!(error instanceof _assert().AssertionError)) {
|
||||
throw error;
|
||||
}
|
||||
// https://github.com/jestjs/jest/pull/13422#issuecomment-1273396392
|
||||
this._logError('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
|
||||
}
|
||||
}
|
||||
count(label = 'default') {
|
||||
if (!this._counters[label]) {
|
||||
this._counters[label] = 0;
|
||||
}
|
||||
this._log(
|
||||
'count',
|
||||
(0, _util().format)(`${label}: ${++this._counters[label]}`)
|
||||
);
|
||||
}
|
||||
countReset(label = 'default') {
|
||||
this._counters[label] = 0;
|
||||
}
|
||||
debug(firstArg, ...args) {
|
||||
this._log('debug', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
dir(firstArg, options = {}) {
|
||||
const representation = (0, _util().inspect)(firstArg, options);
|
||||
this._log('dir', (0, _util().formatWithOptions)(options, representation));
|
||||
}
|
||||
dirxml(firstArg, ...args) {
|
||||
this._log('dirxml', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
error(firstArg, ...args) {
|
||||
this._logError('error', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
group(title, ...args) {
|
||||
this._groupDepth++;
|
||||
if (title != null || args.length > 0) {
|
||||
this._log(
|
||||
'group',
|
||||
_chalk().default.bold((0, _util().format)(title, ...args))
|
||||
);
|
||||
}
|
||||
}
|
||||
groupCollapsed(title, ...args) {
|
||||
this._groupDepth++;
|
||||
if (title != null || args.length > 0) {
|
||||
this._log(
|
||||
'groupCollapsed',
|
||||
_chalk().default.bold((0, _util().format)(title, ...args))
|
||||
);
|
||||
}
|
||||
}
|
||||
groupEnd() {
|
||||
if (this._groupDepth > 0) {
|
||||
this._groupDepth--;
|
||||
}
|
||||
}
|
||||
info(firstArg, ...args) {
|
||||
this._log('info', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
log(firstArg, ...args) {
|
||||
this._log('log', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
time(label = 'default') {
|
||||
if (this._timers[label] != null) {
|
||||
return;
|
||||
}
|
||||
this._timers[label] = new Date();
|
||||
}
|
||||
timeEnd(label = 'default') {
|
||||
const startTime = this._timers[label];
|
||||
if (startTime != null) {
|
||||
const endTime = new Date().getTime();
|
||||
const time = endTime - startTime.getTime();
|
||||
this._log(
|
||||
'time',
|
||||
(0, _util().format)(`${label}: ${(0, _jestUtil().formatTime)(time)}`)
|
||||
);
|
||||
delete this._timers[label];
|
||||
}
|
||||
}
|
||||
timeLog(label = 'default', ...data) {
|
||||
const startTime = this._timers[label];
|
||||
if (startTime != null) {
|
||||
const endTime = new Date();
|
||||
const time = endTime.getTime() - startTime.getTime();
|
||||
this._log(
|
||||
'time',
|
||||
(0, _util().format)(
|
||||
`${label}: ${(0, _jestUtil().formatTime)(time)}`,
|
||||
...data
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
warn(firstArg, ...args) {
|
||||
this._logError('warn', (0, _util().format)(firstArg, ...args));
|
||||
}
|
||||
getBuffer() {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.default = CustomConsole;
|
35
backend/apis/nodejs/node_modules/@jest/console/build/NullConsole.js
generated
vendored
Normal file
35
backend/apis/nodejs/node_modules/@jest/console/build/NullConsole.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _CustomConsole = _interopRequireDefault(require('./CustomConsole'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class NullConsole extends _CustomConsole.default {
|
||||
assert() {}
|
||||
debug() {}
|
||||
dir() {}
|
||||
error() {}
|
||||
info() {}
|
||||
log() {}
|
||||
time() {}
|
||||
timeEnd() {}
|
||||
timeLog() {}
|
||||
trace() {}
|
||||
warn() {}
|
||||
group() {}
|
||||
groupCollapsed() {}
|
||||
groupEnd() {}
|
||||
}
|
||||
exports.default = NullConsole;
|
70
backend/apis/nodejs/node_modules/@jest/console/build/getConsoleOutput.js
generated
vendored
Normal file
70
backend/apis/nodejs/node_modules/@jest/console/build/getConsoleOutput.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getConsoleOutput;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getConsoleOutput(buffer, config, globalConfig) {
|
||||
const TITLE_INDENT =
|
||||
globalConfig.verbose === true ? ' '.repeat(2) : ' '.repeat(4);
|
||||
const CONSOLE_INDENT = TITLE_INDENT + ' '.repeat(2);
|
||||
const logEntries = buffer.reduce((output, {type, message, origin}) => {
|
||||
message = message
|
||||
.split(/\n/)
|
||||
.map(line => CONSOLE_INDENT + line)
|
||||
.join('\n');
|
||||
let typeMessage = `console.${type}`;
|
||||
let noStackTrace = true;
|
||||
let noCodeFrame = true;
|
||||
if (type === 'warn') {
|
||||
message = _chalk().default.yellow(message);
|
||||
typeMessage = _chalk().default.yellow(typeMessage);
|
||||
noStackTrace = globalConfig?.noStackTrace ?? false;
|
||||
noCodeFrame = false;
|
||||
} else if (type === 'error') {
|
||||
message = _chalk().default.red(message);
|
||||
typeMessage = _chalk().default.red(typeMessage);
|
||||
noStackTrace = globalConfig?.noStackTrace ?? false;
|
||||
noCodeFrame = false;
|
||||
}
|
||||
const options = {
|
||||
noCodeFrame,
|
||||
noStackTrace
|
||||
};
|
||||
const formattedStackTrace = (0, _jestMessageUtil().formatStackTrace)(
|
||||
origin,
|
||||
config,
|
||||
options
|
||||
);
|
||||
return `${
|
||||
output + TITLE_INDENT + _chalk().default.dim(typeMessage)
|
||||
}\n${message.trimRight()}\n${_chalk().default.dim(
|
||||
formattedStackTrace.trimRight()
|
||||
)}\n\n`;
|
||||
}, '');
|
||||
return `${logEntries.trimRight()}\n`;
|
||||
}
|
131
backend/apis/nodejs/node_modules/@jest/console/build/index.d.ts
generated
vendored
Normal file
131
backend/apis/nodejs/node_modules/@jest/console/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 {Config} from '@jest/types';
|
||||
import {Console as Console_2} from 'console';
|
||||
import {InspectOptions} from 'util';
|
||||
import {StackTraceConfig} from 'jest-message-util';
|
||||
|
||||
export declare class BufferedConsole extends Console_2 {
|
||||
private readonly _buffer;
|
||||
private _counters;
|
||||
private _timers;
|
||||
private _groupDepth;
|
||||
Console: typeof Console_2;
|
||||
constructor();
|
||||
static write(
|
||||
this: void,
|
||||
buffer: ConsoleBuffer,
|
||||
type: LogType,
|
||||
message: LogMessage,
|
||||
level?: number | null,
|
||||
): ConsoleBuffer;
|
||||
private _log;
|
||||
assert(value: unknown, message?: string | Error): void;
|
||||
count(label?: string): void;
|
||||
countReset(label?: string): void;
|
||||
debug(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
dir(firstArg: unknown, options?: InspectOptions): void;
|
||||
dirxml(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
error(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
group(title?: string, ...rest: Array<unknown>): void;
|
||||
groupCollapsed(title?: string, ...rest: Array<unknown>): void;
|
||||
groupEnd(): void;
|
||||
info(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
log(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
time(label?: string): void;
|
||||
timeEnd(label?: string): void;
|
||||
timeLog(label?: string, ...data: Array<unknown>): void;
|
||||
warn(firstArg: unknown, ...rest: Array<unknown>): void;
|
||||
getBuffer(): ConsoleBuffer | undefined;
|
||||
}
|
||||
|
||||
export declare type ConsoleBuffer = Array<LogEntry>;
|
||||
|
||||
export declare class CustomConsole extends Console_2 {
|
||||
private readonly _stdout;
|
||||
private readonly _stderr;
|
||||
private readonly _formatBuffer;
|
||||
private _counters;
|
||||
private _timers;
|
||||
private _groupDepth;
|
||||
Console: typeof Console_2;
|
||||
constructor(
|
||||
stdout: NodeJS.WriteStream,
|
||||
stderr: NodeJS.WriteStream,
|
||||
formatBuffer?: Formatter,
|
||||
);
|
||||
private _log;
|
||||
private _logError;
|
||||
assert(value: unknown, message?: string | Error): asserts value;
|
||||
count(label?: string): void;
|
||||
countReset(label?: string): void;
|
||||
debug(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
dir(firstArg: unknown, options?: InspectOptions): void;
|
||||
dirxml(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
error(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
group(title?: string, ...args: Array<unknown>): void;
|
||||
groupCollapsed(title?: string, ...args: Array<unknown>): void;
|
||||
groupEnd(): void;
|
||||
info(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
log(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
time(label?: string): void;
|
||||
timeEnd(label?: string): void;
|
||||
timeLog(label?: string, ...data: Array<unknown>): void;
|
||||
warn(firstArg: unknown, ...args: Array<unknown>): void;
|
||||
getBuffer(): undefined;
|
||||
}
|
||||
|
||||
declare type Formatter = (type: LogType, message: LogMessage) => string;
|
||||
|
||||
export declare function getConsoleOutput(
|
||||
buffer: ConsoleBuffer,
|
||||
config: StackTraceConfig,
|
||||
globalConfig: Config.GlobalConfig,
|
||||
): string;
|
||||
|
||||
export declare type LogEntry = {
|
||||
message: LogMessage;
|
||||
origin: string;
|
||||
type: LogType;
|
||||
};
|
||||
|
||||
export declare type LogMessage = string;
|
||||
|
||||
export declare type LogType =
|
||||
| 'assert'
|
||||
| 'count'
|
||||
| 'debug'
|
||||
| 'dir'
|
||||
| 'dirxml'
|
||||
| 'error'
|
||||
| 'group'
|
||||
| 'groupCollapsed'
|
||||
| 'info'
|
||||
| 'log'
|
||||
| 'time'
|
||||
| 'warn';
|
||||
|
||||
export declare class NullConsole extends CustomConsole {
|
||||
assert(): void;
|
||||
debug(): void;
|
||||
dir(): void;
|
||||
error(): void;
|
||||
info(): void;
|
||||
log(): void;
|
||||
time(): void;
|
||||
timeEnd(): void;
|
||||
timeLog(): void;
|
||||
trace(): void;
|
||||
warn(): void;
|
||||
group(): void;
|
||||
groupCollapsed(): void;
|
||||
groupEnd(): void;
|
||||
}
|
||||
|
||||
export {};
|
36
backend/apis/nodejs/node_modules/@jest/console/build/index.js
generated
vendored
Normal file
36
backend/apis/nodejs/node_modules/@jest/console/build/index.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'BufferedConsole', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _BufferedConsole.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'CustomConsole', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _CustomConsole.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'NullConsole', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _NullConsole.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getConsoleOutput', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getConsoleOutput.default;
|
||||
}
|
||||
});
|
||||
var _BufferedConsole = _interopRequireDefault(require('./BufferedConsole'));
|
||||
var _CustomConsole = _interopRequireDefault(require('./CustomConsole'));
|
||||
var _NullConsole = _interopRequireDefault(require('./NullConsole'));
|
||||
var _getConsoleOutput = _interopRequireDefault(require('./getConsoleOutput'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
1
backend/apis/nodejs/node_modules/@jest/console/build/types.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/@jest/console/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
37
backend/apis/nodejs/node_modules/@jest/console/package.json
generated
vendored
Normal file
37
backend/apis/nodejs/node_modules/@jest/console/package.json
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@jest/console",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-console"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/types": "^29.6.3",
|
||||
"@types/node": "*",
|
||||
"chalk": "^4.0.0",
|
||||
"jest-message-util": "^29.7.0",
|
||||
"jest-util": "^29.7.0",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "^29.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/core/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/core/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
3
backend/apis/nodejs/node_modules/@jest/core/README.md
generated
vendored
Normal file
3
backend/apis/nodejs/node_modules/@jest/core/README.md
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# @jest/core
|
||||
|
||||
Jest is currently working on providing a programmatic API. This is under development, and usage of this package directly is currently not supported.
|
46
backend/apis/nodejs/node_modules/@jest/core/build/FailedTestsCache.js
generated
vendored
Normal file
46
backend/apis/nodejs/node_modules/@jest/core/build/FailedTestsCache.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class FailedTestsCache {
|
||||
_enabledTestsMap;
|
||||
filterTests(tests) {
|
||||
const enabledTestsMap = this._enabledTestsMap;
|
||||
if (!enabledTestsMap) {
|
||||
return tests;
|
||||
}
|
||||
return tests.filter(testResult => enabledTestsMap[testResult.path]);
|
||||
}
|
||||
setTestResults(testResults) {
|
||||
this._enabledTestsMap = (testResults || []).reduce(
|
||||
(suiteMap, testResult) => {
|
||||
if (!testResult.numFailingTests) {
|
||||
return suiteMap;
|
||||
}
|
||||
suiteMap[testResult.testFilePath] = testResult.testResults.reduce(
|
||||
(testMap, test) => {
|
||||
if (test.status !== 'failed') {
|
||||
return testMap;
|
||||
}
|
||||
testMap[test.fullName] = true;
|
||||
return testMap;
|
||||
},
|
||||
{}
|
||||
);
|
||||
return suiteMap;
|
||||
},
|
||||
{}
|
||||
);
|
||||
this._enabledTestsMap = Object.freeze(this._enabledTestsMap);
|
||||
}
|
||||
}
|
||||
exports.default = FailedTestsCache;
|
195
backend/apis/nodejs/node_modules/@jest/core/build/FailedTestsInteractiveMode.js
generated
vendored
Normal file
195
backend/apis/nodejs/node_modules/@jest/core/build/FailedTestsInteractiveMode.js
generated
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _ansiEscapes() {
|
||||
const data = _interopRequireDefault(require('ansi-escapes'));
|
||||
_ansiEscapes = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {ARROW, CLEAR} = _jestUtil().specialChars;
|
||||
function describeKey(key, description) {
|
||||
return `${_chalk().default.dim(
|
||||
`${ARROW}Press`
|
||||
)} ${key} ${_chalk().default.dim(description)}`;
|
||||
}
|
||||
const TestProgressLabel = _chalk().default.bold('Interactive Test Progress');
|
||||
class FailedTestsInteractiveMode {
|
||||
_isActive = false;
|
||||
_countPaths = 0;
|
||||
_skippedNum = 0;
|
||||
_testAssertions = [];
|
||||
_updateTestRunnerConfig;
|
||||
constructor(_pipe) {
|
||||
this._pipe = _pipe;
|
||||
}
|
||||
isActive() {
|
||||
return this._isActive;
|
||||
}
|
||||
put(key) {
|
||||
switch (key) {
|
||||
case 's':
|
||||
if (this._skippedNum === this._testAssertions.length) {
|
||||
break;
|
||||
}
|
||||
this._skippedNum += 1;
|
||||
// move skipped test to the end
|
||||
this._testAssertions.push(this._testAssertions.shift());
|
||||
if (this._testAssertions.length - this._skippedNum > 0) {
|
||||
this._run();
|
||||
} else {
|
||||
this._drawUIDoneWithSkipped();
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
case _jestWatcher().KEYS.ESCAPE:
|
||||
this.abort();
|
||||
break;
|
||||
case 'r':
|
||||
this.restart();
|
||||
break;
|
||||
case _jestWatcher().KEYS.ENTER:
|
||||
if (this._testAssertions.length === 0) {
|
||||
this.abort();
|
||||
} else {
|
||||
this._run();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
run(failedTestAssertions, updateConfig) {
|
||||
if (failedTestAssertions.length === 0) return;
|
||||
this._testAssertions = [...failedTestAssertions];
|
||||
this._countPaths = this._testAssertions.length;
|
||||
this._updateTestRunnerConfig = updateConfig;
|
||||
this._isActive = true;
|
||||
this._run();
|
||||
}
|
||||
updateWithResults(results) {
|
||||
if (!results.snapshot.failure && results.numFailedTests > 0) {
|
||||
return this._drawUIOverlay();
|
||||
}
|
||||
this._testAssertions.shift();
|
||||
if (this._testAssertions.length === 0) {
|
||||
return this._drawUIOverlay();
|
||||
}
|
||||
|
||||
// Go to the next test
|
||||
return this._run();
|
||||
}
|
||||
_clearTestSummary() {
|
||||
this._pipe.write(_ansiEscapes().default.cursorUp(6));
|
||||
this._pipe.write(_ansiEscapes().default.eraseDown);
|
||||
}
|
||||
_drawUIDone() {
|
||||
this._pipe.write(CLEAR);
|
||||
const messages = [
|
||||
_chalk().default.bold('Watch Usage'),
|
||||
describeKey('Enter', 'to return to watch mode.')
|
||||
];
|
||||
this._pipe.write(`${messages.join('\n')}\n`);
|
||||
}
|
||||
_drawUIDoneWithSkipped() {
|
||||
this._pipe.write(CLEAR);
|
||||
let stats = `${(0, _jestUtil().pluralize)(
|
||||
'test',
|
||||
this._countPaths
|
||||
)} reviewed`;
|
||||
if (this._skippedNum > 0) {
|
||||
const skippedText = _chalk().default.bold.yellow(
|
||||
`${(0, _jestUtil().pluralize)('test', this._skippedNum)} skipped`
|
||||
);
|
||||
stats = `${stats}, ${skippedText}`;
|
||||
}
|
||||
const message = [
|
||||
TestProgressLabel,
|
||||
`${ARROW}${stats}`,
|
||||
'\n',
|
||||
_chalk().default.bold('Watch Usage'),
|
||||
describeKey('r', 'to restart Interactive Mode.'),
|
||||
describeKey('q', 'to quit Interactive Mode.'),
|
||||
describeKey('Enter', 'to return to watch mode.')
|
||||
];
|
||||
this._pipe.write(`\n${message.join('\n')}`);
|
||||
}
|
||||
_drawUIProgress() {
|
||||
this._clearTestSummary();
|
||||
const numPass = this._countPaths - this._testAssertions.length;
|
||||
const numRemaining = this._countPaths - numPass - this._skippedNum;
|
||||
let stats = `${(0, _jestUtil().pluralize)('test', numRemaining)} remaining`;
|
||||
if (this._skippedNum > 0) {
|
||||
const skippedText = _chalk().default.bold.yellow(
|
||||
`${(0, _jestUtil().pluralize)('test', this._skippedNum)} skipped`
|
||||
);
|
||||
stats = `${stats}, ${skippedText}`;
|
||||
}
|
||||
const message = [
|
||||
TestProgressLabel,
|
||||
`${ARROW}${stats}`,
|
||||
'\n',
|
||||
_chalk().default.bold('Watch Usage'),
|
||||
describeKey('s', 'to skip the current test.'),
|
||||
describeKey('q', 'to quit Interactive Mode.'),
|
||||
describeKey('Enter', 'to return to watch mode.')
|
||||
];
|
||||
this._pipe.write(`\n${message.join('\n')}`);
|
||||
}
|
||||
_drawUIOverlay() {
|
||||
if (this._testAssertions.length === 0) return this._drawUIDone();
|
||||
return this._drawUIProgress();
|
||||
}
|
||||
_run() {
|
||||
if (this._updateTestRunnerConfig) {
|
||||
this._updateTestRunnerConfig(this._testAssertions[0]);
|
||||
}
|
||||
}
|
||||
abort() {
|
||||
this._isActive = false;
|
||||
this._skippedNum = 0;
|
||||
if (this._updateTestRunnerConfig) {
|
||||
this._updateTestRunnerConfig();
|
||||
}
|
||||
}
|
||||
restart() {
|
||||
this._skippedNum = 0;
|
||||
this._countPaths = this._testAssertions.length;
|
||||
this._run();
|
||||
}
|
||||
}
|
||||
exports.default = FailedTestsInteractiveMode;
|
87
backend/apis/nodejs/node_modules/@jest/core/build/ReporterDispatcher.js
generated
vendored
Normal file
87
backend/apis/nodejs/node_modules/@jest/core/build/ReporterDispatcher.js
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class ReporterDispatcher {
|
||||
_reporters;
|
||||
constructor() {
|
||||
this._reporters = [];
|
||||
}
|
||||
register(reporter) {
|
||||
this._reporters.push(reporter);
|
||||
}
|
||||
unregister(reporterConstructor) {
|
||||
this._reporters = this._reporters.filter(
|
||||
reporter => !(reporter instanceof reporterConstructor)
|
||||
);
|
||||
}
|
||||
async onTestFileResult(test, testResult, results) {
|
||||
for (const reporter of this._reporters) {
|
||||
if (reporter.onTestFileResult) {
|
||||
await reporter.onTestFileResult(test, testResult, results);
|
||||
} else if (reporter.onTestResult) {
|
||||
await reporter.onTestResult(test, testResult, results);
|
||||
}
|
||||
}
|
||||
|
||||
// Release memory if unused later.
|
||||
testResult.coverage = undefined;
|
||||
testResult.console = undefined;
|
||||
}
|
||||
async onTestFileStart(test) {
|
||||
for (const reporter of this._reporters) {
|
||||
if (reporter.onTestFileStart) {
|
||||
await reporter.onTestFileStart(test);
|
||||
} else if (reporter.onTestStart) {
|
||||
await reporter.onTestStart(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
async onRunStart(results, options) {
|
||||
for (const reporter of this._reporters) {
|
||||
reporter.onRunStart && (await reporter.onRunStart(results, options));
|
||||
}
|
||||
}
|
||||
async onTestCaseStart(test, testCaseStartInfo) {
|
||||
for (const reporter of this._reporters) {
|
||||
if (reporter.onTestCaseStart) {
|
||||
await reporter.onTestCaseStart(test, testCaseStartInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
async onTestCaseResult(test, testCaseResult) {
|
||||
for (const reporter of this._reporters) {
|
||||
if (reporter.onTestCaseResult) {
|
||||
await reporter.onTestCaseResult(test, testCaseResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
async onRunComplete(testContexts, results) {
|
||||
for (const reporter of this._reporters) {
|
||||
if (reporter.onRunComplete) {
|
||||
await reporter.onRunComplete(testContexts, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return a list of last errors for every reporter
|
||||
getErrors() {
|
||||
return this._reporters.reduce((list, reporter) => {
|
||||
const error = reporter.getLastError && reporter.getLastError();
|
||||
return error ? list.concat(error) : list;
|
||||
}, []);
|
||||
}
|
||||
hasErrors() {
|
||||
return this.getErrors().length !== 0;
|
||||
}
|
||||
}
|
||||
exports.default = ReporterDispatcher;
|
408
backend/apis/nodejs/node_modules/@jest/core/build/SearchSource.js
generated
vendored
Normal file
408
backend/apis/nodejs/node_modules/@jest/core/build/SearchSource.js
generated
vendored
Normal file
@ -0,0 +1,408 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function os() {
|
||||
const data = _interopRequireWildcard(require('os'));
|
||||
os = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _micromatch() {
|
||||
const data = _interopRequireDefault(require('micromatch'));
|
||||
_micromatch = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestConfig() {
|
||||
const data = require('jest-config');
|
||||
_jestConfig = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
_jestRegexUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestResolveDependencies() {
|
||||
const data = require('jest-resolve-dependencies');
|
||||
_jestResolveDependencies = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestSnapshot() {
|
||||
const data = require('jest-snapshot');
|
||||
_jestSnapshot = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const regexToMatcher = testRegex => {
|
||||
const regexes = testRegex.map(testRegex => new RegExp(testRegex));
|
||||
return path =>
|
||||
regexes.some(regex => {
|
||||
const result = regex.test(path);
|
||||
|
||||
// prevent stateful regexes from breaking, just in case
|
||||
regex.lastIndex = 0;
|
||||
return result;
|
||||
});
|
||||
};
|
||||
const toTests = (context, tests) =>
|
||||
tests.map(path => ({
|
||||
context,
|
||||
duration: undefined,
|
||||
path
|
||||
}));
|
||||
const hasSCM = changedFilesInfo => {
|
||||
const {repos} = changedFilesInfo;
|
||||
// no SCM (git/hg/...) is found in any of the roots.
|
||||
const noSCM = Object.values(repos).every(scm => scm.size === 0);
|
||||
return !noSCM;
|
||||
};
|
||||
class SearchSource {
|
||||
_context;
|
||||
_dependencyResolver;
|
||||
_testPathCases = [];
|
||||
constructor(context) {
|
||||
const {config} = context;
|
||||
this._context = context;
|
||||
this._dependencyResolver = null;
|
||||
const rootPattern = new RegExp(
|
||||
config.roots
|
||||
.map(dir => (0, _jestRegexUtil().escapePathForRegex)(dir + path().sep))
|
||||
.join('|')
|
||||
);
|
||||
this._testPathCases.push({
|
||||
isMatch: path => rootPattern.test(path),
|
||||
stat: 'roots'
|
||||
});
|
||||
if (config.testMatch.length) {
|
||||
this._testPathCases.push({
|
||||
isMatch: (0, _jestUtil().globsToMatcher)(config.testMatch),
|
||||
stat: 'testMatch'
|
||||
});
|
||||
}
|
||||
if (config.testPathIgnorePatterns.length) {
|
||||
const testIgnorePatternsRegex = new RegExp(
|
||||
config.testPathIgnorePatterns.join('|')
|
||||
);
|
||||
this._testPathCases.push({
|
||||
isMatch: path => !testIgnorePatternsRegex.test(path),
|
||||
stat: 'testPathIgnorePatterns'
|
||||
});
|
||||
}
|
||||
if (config.testRegex.length) {
|
||||
this._testPathCases.push({
|
||||
isMatch: regexToMatcher(config.testRegex),
|
||||
stat: 'testRegex'
|
||||
});
|
||||
}
|
||||
}
|
||||
async _getOrBuildDependencyResolver() {
|
||||
if (!this._dependencyResolver) {
|
||||
this._dependencyResolver =
|
||||
new (_jestResolveDependencies().DependencyResolver)(
|
||||
this._context.resolver,
|
||||
this._context.hasteFS,
|
||||
await (0, _jestSnapshot().buildSnapshotResolver)(this._context.config)
|
||||
);
|
||||
}
|
||||
return this._dependencyResolver;
|
||||
}
|
||||
_filterTestPathsWithStats(allPaths, testPathPattern) {
|
||||
const data = {
|
||||
stats: {
|
||||
roots: 0,
|
||||
testMatch: 0,
|
||||
testPathIgnorePatterns: 0,
|
||||
testRegex: 0
|
||||
},
|
||||
tests: [],
|
||||
total: allPaths.length
|
||||
};
|
||||
const testCases = Array.from(this._testPathCases); // clone
|
||||
if (testPathPattern) {
|
||||
const regex = (0, _jestUtil().testPathPatternToRegExp)(testPathPattern);
|
||||
testCases.push({
|
||||
isMatch: path => regex.test(path),
|
||||
stat: 'testPathPattern'
|
||||
});
|
||||
data.stats.testPathPattern = 0;
|
||||
}
|
||||
data.tests = allPaths.filter(test => {
|
||||
let filterResult = true;
|
||||
for (const {isMatch, stat} of testCases) {
|
||||
if (isMatch(test.path)) {
|
||||
data.stats[stat]++;
|
||||
} else {
|
||||
filterResult = false;
|
||||
}
|
||||
}
|
||||
return filterResult;
|
||||
});
|
||||
return data;
|
||||
}
|
||||
_getAllTestPaths(testPathPattern) {
|
||||
return this._filterTestPathsWithStats(
|
||||
toTests(this._context, this._context.hasteFS.getAllFiles()),
|
||||
testPathPattern
|
||||
);
|
||||
}
|
||||
isTestFilePath(path) {
|
||||
return this._testPathCases.every(testCase => testCase.isMatch(path));
|
||||
}
|
||||
findMatchingTests(testPathPattern) {
|
||||
return this._getAllTestPaths(testPathPattern);
|
||||
}
|
||||
async findRelatedTests(allPaths, collectCoverage) {
|
||||
const dependencyResolver = await this._getOrBuildDependencyResolver();
|
||||
if (!collectCoverage) {
|
||||
return {
|
||||
tests: toTests(
|
||||
this._context,
|
||||
dependencyResolver.resolveInverse(
|
||||
allPaths,
|
||||
this.isTestFilePath.bind(this),
|
||||
{
|
||||
skipNodeResolution: this._context.config.skipNodeResolution
|
||||
}
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
const testModulesMap = dependencyResolver.resolveInverseModuleMap(
|
||||
allPaths,
|
||||
this.isTestFilePath.bind(this),
|
||||
{
|
||||
skipNodeResolution: this._context.config.skipNodeResolution
|
||||
}
|
||||
);
|
||||
const allPathsAbsolute = Array.from(allPaths).map(p => path().resolve(p));
|
||||
const collectCoverageFrom = new Set();
|
||||
testModulesMap.forEach(testModule => {
|
||||
if (!testModule.dependencies) {
|
||||
return;
|
||||
}
|
||||
testModule.dependencies.forEach(p => {
|
||||
if (!allPathsAbsolute.includes(p)) {
|
||||
return;
|
||||
}
|
||||
const filename = (0, _jestConfig().replaceRootDirInPath)(
|
||||
this._context.config.rootDir,
|
||||
p
|
||||
);
|
||||
collectCoverageFrom.add(
|
||||
path().isAbsolute(filename)
|
||||
? path().relative(this._context.config.rootDir, filename)
|
||||
: filename
|
||||
);
|
||||
});
|
||||
});
|
||||
return {
|
||||
collectCoverageFrom,
|
||||
tests: toTests(
|
||||
this._context,
|
||||
testModulesMap.map(testModule => testModule.file)
|
||||
)
|
||||
};
|
||||
}
|
||||
findTestsByPaths(paths) {
|
||||
return {
|
||||
tests: toTests(
|
||||
this._context,
|
||||
paths
|
||||
.map(p => path().resolve(this._context.config.cwd, p))
|
||||
.filter(this.isTestFilePath.bind(this))
|
||||
)
|
||||
};
|
||||
}
|
||||
async findRelatedTestsFromPattern(paths, collectCoverage) {
|
||||
if (Array.isArray(paths) && paths.length) {
|
||||
const resolvedPaths = paths.map(p =>
|
||||
path().resolve(this._context.config.cwd, p)
|
||||
);
|
||||
return this.findRelatedTests(new Set(resolvedPaths), collectCoverage);
|
||||
}
|
||||
return {
|
||||
tests: []
|
||||
};
|
||||
}
|
||||
async findTestRelatedToChangedFiles(changedFilesInfo, collectCoverage) {
|
||||
if (!hasSCM(changedFilesInfo)) {
|
||||
return {
|
||||
noSCM: true,
|
||||
tests: []
|
||||
};
|
||||
}
|
||||
const {changedFiles} = changedFilesInfo;
|
||||
return this.findRelatedTests(changedFiles, collectCoverage);
|
||||
}
|
||||
async _getTestPaths(globalConfig, changedFiles) {
|
||||
if (globalConfig.onlyChanged) {
|
||||
if (!changedFiles) {
|
||||
throw new Error('Changed files must be set when running with -o.');
|
||||
}
|
||||
return this.findTestRelatedToChangedFiles(
|
||||
changedFiles,
|
||||
globalConfig.collectCoverage
|
||||
);
|
||||
}
|
||||
let paths = globalConfig.nonFlagArgs;
|
||||
if (globalConfig.findRelatedTests && 'win32' === os().platform()) {
|
||||
paths = this.filterPathsWin32(paths);
|
||||
}
|
||||
if (globalConfig.runTestsByPath && paths && paths.length) {
|
||||
return this.findTestsByPaths(paths);
|
||||
} else if (globalConfig.findRelatedTests && paths && paths.length) {
|
||||
return this.findRelatedTestsFromPattern(
|
||||
paths,
|
||||
globalConfig.collectCoverage
|
||||
);
|
||||
} else if (globalConfig.testPathPattern != null) {
|
||||
return this.findMatchingTests(globalConfig.testPathPattern);
|
||||
} else {
|
||||
return {
|
||||
tests: []
|
||||
};
|
||||
}
|
||||
}
|
||||
filterPathsWin32(paths) {
|
||||
const allFiles = this._context.hasteFS.getAllFiles();
|
||||
const options = {
|
||||
nocase: true,
|
||||
windows: false
|
||||
};
|
||||
function normalizePosix(filePath) {
|
||||
return filePath.replace(/\\/g, '/');
|
||||
}
|
||||
paths = paths
|
||||
.map(p => {
|
||||
// micromatch works with forward slashes: https://github.com/micromatch/micromatch#backslashes
|
||||
const normalizedPath = normalizePosix(
|
||||
path().resolve(this._context.config.cwd, p)
|
||||
);
|
||||
const match = (0, _micromatch().default)(
|
||||
allFiles.map(normalizePosix),
|
||||
normalizedPath,
|
||||
options
|
||||
);
|
||||
return match[0];
|
||||
})
|
||||
.filter(Boolean)
|
||||
.map(p => path().resolve(p));
|
||||
return paths;
|
||||
}
|
||||
async getTestPaths(globalConfig, changedFiles, filter) {
|
||||
const searchResult = await this._getTestPaths(globalConfig, changedFiles);
|
||||
const filterPath = globalConfig.filter;
|
||||
if (filter) {
|
||||
const tests = searchResult.tests;
|
||||
const filterResult = await filter(tests.map(test => test.path));
|
||||
if (!Array.isArray(filterResult.filtered)) {
|
||||
throw new Error(
|
||||
`Filter ${filterPath} did not return a valid test list`
|
||||
);
|
||||
}
|
||||
const filteredSet = new Set(
|
||||
filterResult.filtered.map(result => result.test)
|
||||
);
|
||||
return {
|
||||
...searchResult,
|
||||
tests: tests.filter(test => filteredSet.has(test.path))
|
||||
};
|
||||
}
|
||||
return searchResult;
|
||||
}
|
||||
async findRelatedSourcesFromTestsInChangedFiles(changedFilesInfo) {
|
||||
if (!hasSCM(changedFilesInfo)) {
|
||||
return [];
|
||||
}
|
||||
const {changedFiles} = changedFilesInfo;
|
||||
const dependencyResolver = await this._getOrBuildDependencyResolver();
|
||||
const relatedSourcesSet = new Set();
|
||||
changedFiles.forEach(filePath => {
|
||||
if (this.isTestFilePath(filePath)) {
|
||||
const sourcePaths = dependencyResolver.resolve(filePath, {
|
||||
skipNodeResolution: this._context.config.skipNodeResolution
|
||||
});
|
||||
sourcePaths.forEach(sourcePath => relatedSourcesSet.add(sourcePath));
|
||||
}
|
||||
});
|
||||
return Array.from(relatedSourcesSet);
|
||||
}
|
||||
}
|
||||
exports.default = SearchSource;
|
238
backend/apis/nodejs/node_modules/@jest/core/build/SnapshotInteractiveMode.js
generated
vendored
Normal file
238
backend/apis/nodejs/node_modules/@jest/core/build/SnapshotInteractiveMode.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _ansiEscapes() {
|
||||
const data = _interopRequireDefault(require('ansi-escapes'));
|
||||
_ansiEscapes = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {ARROW, CLEAR} = _jestUtil().specialChars;
|
||||
class SnapshotInteractiveMode {
|
||||
_pipe;
|
||||
_isActive;
|
||||
_updateTestRunnerConfig;
|
||||
_testAssertions;
|
||||
_countPaths;
|
||||
_skippedNum;
|
||||
constructor(pipe) {
|
||||
this._pipe = pipe;
|
||||
this._isActive = false;
|
||||
this._skippedNum = 0;
|
||||
}
|
||||
isActive() {
|
||||
return this._isActive;
|
||||
}
|
||||
getSkippedNum() {
|
||||
return this._skippedNum;
|
||||
}
|
||||
_clearTestSummary() {
|
||||
this._pipe.write(_ansiEscapes().default.cursorUp(6));
|
||||
this._pipe.write(_ansiEscapes().default.eraseDown);
|
||||
}
|
||||
_drawUIProgress() {
|
||||
this._clearTestSummary();
|
||||
const numPass = this._countPaths - this._testAssertions.length;
|
||||
const numRemaining = this._countPaths - numPass - this._skippedNum;
|
||||
let stats = _chalk().default.bold.dim(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', numRemaining)} remaining`
|
||||
);
|
||||
if (numPass) {
|
||||
stats += `, ${_chalk().default.bold.green(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', numPass)} updated`
|
||||
)}`;
|
||||
}
|
||||
if (this._skippedNum) {
|
||||
stats += `, ${_chalk().default.bold.yellow(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', this._skippedNum)} skipped`
|
||||
)}`;
|
||||
}
|
||||
const messages = [
|
||||
`\n${_chalk().default.bold('Interactive Snapshot Progress')}`,
|
||||
ARROW + stats,
|
||||
`\n${_chalk().default.bold('Watch Usage')}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}u${_chalk().default.dim(
|
||||
' to update failing snapshots for this test.'
|
||||
)}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}s${_chalk().default.dim(
|
||||
' to skip the current test.'
|
||||
)}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}q${_chalk().default.dim(
|
||||
' to quit Interactive Snapshot Mode.'
|
||||
)}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}Enter${_chalk().default.dim(
|
||||
' to trigger a test run.'
|
||||
)}`
|
||||
];
|
||||
this._pipe.write(`${messages.filter(Boolean).join('\n')}\n`);
|
||||
}
|
||||
_drawUIDoneWithSkipped() {
|
||||
this._pipe.write(CLEAR);
|
||||
const numPass = this._countPaths - this._testAssertions.length;
|
||||
let stats = _chalk().default.bold.dim(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', this._countPaths)} reviewed`
|
||||
);
|
||||
if (numPass) {
|
||||
stats += `, ${_chalk().default.bold.green(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', numPass)} updated`
|
||||
)}`;
|
||||
}
|
||||
if (this._skippedNum) {
|
||||
stats += `, ${_chalk().default.bold.yellow(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', this._skippedNum)} skipped`
|
||||
)}`;
|
||||
}
|
||||
const messages = [
|
||||
`\n${_chalk().default.bold('Interactive Snapshot Result')}`,
|
||||
ARROW + stats,
|
||||
`\n${_chalk().default.bold('Watch Usage')}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}r${_chalk().default.dim(
|
||||
' to restart Interactive Snapshot Mode.'
|
||||
)}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}q${_chalk().default.dim(
|
||||
' to quit Interactive Snapshot Mode.'
|
||||
)}`
|
||||
];
|
||||
this._pipe.write(`${messages.filter(Boolean).join('\n')}\n`);
|
||||
}
|
||||
_drawUIDone() {
|
||||
this._pipe.write(CLEAR);
|
||||
const numPass = this._countPaths - this._testAssertions.length;
|
||||
let stats = _chalk().default.bold.dim(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', this._countPaths)} reviewed`
|
||||
);
|
||||
if (numPass) {
|
||||
stats += `, ${_chalk().default.bold.green(
|
||||
`${(0, _jestUtil().pluralize)('snapshot', numPass)} updated`
|
||||
)}`;
|
||||
}
|
||||
const messages = [
|
||||
`\n${_chalk().default.bold('Interactive Snapshot Result')}`,
|
||||
ARROW + stats,
|
||||
`\n${_chalk().default.bold('Watch Usage')}`,
|
||||
`${_chalk().default.dim(`${ARROW}Press `)}Enter${_chalk().default.dim(
|
||||
' to return to watch mode.'
|
||||
)}`
|
||||
];
|
||||
this._pipe.write(`${messages.filter(Boolean).join('\n')}\n`);
|
||||
}
|
||||
_drawUIOverlay() {
|
||||
if (this._testAssertions.length === 0) {
|
||||
return this._drawUIDone();
|
||||
}
|
||||
if (this._testAssertions.length - this._skippedNum === 0) {
|
||||
return this._drawUIDoneWithSkipped();
|
||||
}
|
||||
return this._drawUIProgress();
|
||||
}
|
||||
put(key) {
|
||||
switch (key) {
|
||||
case 's':
|
||||
if (this._skippedNum === this._testAssertions.length) break;
|
||||
this._skippedNum += 1;
|
||||
|
||||
// move skipped test to the end
|
||||
this._testAssertions.push(this._testAssertions.shift());
|
||||
if (this._testAssertions.length - this._skippedNum > 0) {
|
||||
this._run(false);
|
||||
} else {
|
||||
this._drawUIDoneWithSkipped();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
this._run(true);
|
||||
break;
|
||||
case 'q':
|
||||
case _jestWatcher().KEYS.ESCAPE:
|
||||
this.abort();
|
||||
break;
|
||||
case 'r':
|
||||
this.restart();
|
||||
break;
|
||||
case _jestWatcher().KEYS.ENTER:
|
||||
if (this._testAssertions.length === 0) {
|
||||
this.abort();
|
||||
} else {
|
||||
this._run(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
abort() {
|
||||
this._isActive = false;
|
||||
this._skippedNum = 0;
|
||||
this._updateTestRunnerConfig(null, false);
|
||||
}
|
||||
restart() {
|
||||
this._skippedNum = 0;
|
||||
this._countPaths = this._testAssertions.length;
|
||||
this._run(false);
|
||||
}
|
||||
updateWithResults(results) {
|
||||
const hasSnapshotFailure = !!results.snapshot.failure;
|
||||
if (hasSnapshotFailure) {
|
||||
this._drawUIOverlay();
|
||||
return;
|
||||
}
|
||||
this._testAssertions.shift();
|
||||
if (this._testAssertions.length - this._skippedNum === 0) {
|
||||
this._drawUIOverlay();
|
||||
return;
|
||||
}
|
||||
|
||||
// Go to the next test
|
||||
this._run(false);
|
||||
}
|
||||
_run(shouldUpdateSnapshot) {
|
||||
const testAssertion = this._testAssertions[0];
|
||||
this._updateTestRunnerConfig(testAssertion, shouldUpdateSnapshot);
|
||||
}
|
||||
run(failedSnapshotTestAssertions, onConfigChange) {
|
||||
if (!failedSnapshotTestAssertions.length) {
|
||||
return;
|
||||
}
|
||||
this._testAssertions = [...failedSnapshotTestAssertions];
|
||||
this._countPaths = this._testAssertions.length;
|
||||
this._updateTestRunnerConfig = onConfigChange;
|
||||
this._isActive = true;
|
||||
this._run(false);
|
||||
}
|
||||
}
|
||||
exports.default = SnapshotInteractiveMode;
|
39
backend/apis/nodejs/node_modules/@jest/core/build/TestNamePatternPrompt.js
generated
vendored
Normal file
39
backend/apis/nodejs/node_modules/@jest/core/build/TestNamePatternPrompt.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class TestNamePatternPrompt extends _jestWatcher().PatternPrompt {
|
||||
constructor(pipe, prompt) {
|
||||
super(pipe, prompt, 'tests');
|
||||
}
|
||||
_onChange(pattern, options) {
|
||||
super._onChange(pattern, options);
|
||||
this._printPrompt(pattern);
|
||||
}
|
||||
_printPrompt(pattern) {
|
||||
const pipe = this._pipe;
|
||||
(0, _jestWatcher().printPatternCaret)(pattern, pipe);
|
||||
(0, _jestWatcher().printRestoredPatternCaret)(
|
||||
pattern,
|
||||
this._currentUsageRows,
|
||||
pipe
|
||||
);
|
||||
}
|
||||
}
|
||||
exports.default = TestNamePatternPrompt;
|
39
backend/apis/nodejs/node_modules/@jest/core/build/TestPathPatternPrompt.js
generated
vendored
Normal file
39
backend/apis/nodejs/node_modules/@jest/core/build/TestPathPatternPrompt.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class TestPathPatternPrompt extends _jestWatcher().PatternPrompt {
|
||||
constructor(pipe, prompt) {
|
||||
super(pipe, prompt, 'filenames');
|
||||
}
|
||||
_onChange(pattern, options) {
|
||||
super._onChange(pattern, options);
|
||||
this._printPrompt(pattern);
|
||||
}
|
||||
_printPrompt(pattern) {
|
||||
const pipe = this._pipe;
|
||||
(0, _jestWatcher().printPatternCaret)(pattern, pipe);
|
||||
(0, _jestWatcher().printRestoredPatternCaret)(
|
||||
pattern,
|
||||
this._currentUsageRows,
|
||||
pipe
|
||||
);
|
||||
}
|
||||
}
|
||||
exports.default = TestPathPatternPrompt;
|
463
backend/apis/nodejs/node_modules/@jest/core/build/TestScheduler.js
generated
vendored
Normal file
463
backend/apis/nodejs/node_modules/@jest/core/build/TestScheduler.js
generated
vendored
Normal file
@ -0,0 +1,463 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.createTestScheduler = createTestScheduler;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _ciInfo() {
|
||||
const data = require('ci-info');
|
||||
_ciInfo = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _reporters() {
|
||||
const data = require('@jest/reporters');
|
||||
_reporters = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _testResult() {
|
||||
const data = require('@jest/test-result');
|
||||
_testResult = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _transform() {
|
||||
const data = require('@jest/transform');
|
||||
_transform = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestSnapshot() {
|
||||
const data = require('jest-snapshot');
|
||||
_jestSnapshot = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _ReporterDispatcher = _interopRequireDefault(
|
||||
require('./ReporterDispatcher')
|
||||
);
|
||||
var _testSchedulerHelper = require('./testSchedulerHelper');
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
async function createTestScheduler(globalConfig, context) {
|
||||
const scheduler = new TestScheduler(globalConfig, context);
|
||||
await scheduler._setupReporters();
|
||||
return scheduler;
|
||||
}
|
||||
class TestScheduler {
|
||||
_context;
|
||||
_dispatcher;
|
||||
_globalConfig;
|
||||
constructor(globalConfig, context) {
|
||||
this._context = context;
|
||||
this._dispatcher = new _ReporterDispatcher.default();
|
||||
this._globalConfig = globalConfig;
|
||||
}
|
||||
addReporter(reporter) {
|
||||
this._dispatcher.register(reporter);
|
||||
}
|
||||
removeReporter(reporterConstructor) {
|
||||
this._dispatcher.unregister(reporterConstructor);
|
||||
}
|
||||
async scheduleTests(tests, watcher) {
|
||||
const onTestFileStart = this._dispatcher.onTestFileStart.bind(
|
||||
this._dispatcher
|
||||
);
|
||||
const timings = [];
|
||||
const testContexts = new Set();
|
||||
tests.forEach(test => {
|
||||
testContexts.add(test.context);
|
||||
if (test.duration) {
|
||||
timings.push(test.duration);
|
||||
}
|
||||
});
|
||||
const aggregatedResults = createAggregatedResults(tests.length);
|
||||
const estimatedTime = Math.ceil(
|
||||
getEstimatedTime(timings, this._globalConfig.maxWorkers) / 1000
|
||||
);
|
||||
const runInBand = (0, _testSchedulerHelper.shouldRunInBand)(
|
||||
tests,
|
||||
timings,
|
||||
this._globalConfig
|
||||
);
|
||||
const onResult = async (test, testResult) => {
|
||||
if (watcher.isInterrupted()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (testResult.testResults.length === 0) {
|
||||
const message = 'Your test suite must contain at least one test.';
|
||||
return onFailure(test, {
|
||||
message,
|
||||
stack: new Error(message).stack
|
||||
});
|
||||
}
|
||||
|
||||
// Throws when the context is leaked after executing a test.
|
||||
if (testResult.leaks) {
|
||||
const message =
|
||||
`${_chalk().default.red.bold(
|
||||
'EXPERIMENTAL FEATURE!\n'
|
||||
)}Your test suite is leaking memory. Please ensure all references are cleaned.\n` +
|
||||
'\n' +
|
||||
'There is a number of things that can leak memory:\n' +
|
||||
' - Async operations that have not finished (e.g. fs.readFile).\n' +
|
||||
' - Timers not properly mocked (e.g. setInterval, setTimeout).\n' +
|
||||
' - Keeping references to the global scope.';
|
||||
return onFailure(test, {
|
||||
message,
|
||||
stack: new Error(message).stack
|
||||
});
|
||||
}
|
||||
(0, _testResult().addResult)(aggregatedResults, testResult);
|
||||
await this._dispatcher.onTestFileResult(
|
||||
test,
|
||||
testResult,
|
||||
aggregatedResults
|
||||
);
|
||||
return this._bailIfNeeded(testContexts, aggregatedResults, watcher);
|
||||
};
|
||||
const onFailure = async (test, error) => {
|
||||
if (watcher.isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
const testResult = (0, _testResult().buildFailureTestResult)(
|
||||
test.path,
|
||||
error
|
||||
);
|
||||
testResult.failureMessage = (0, _jestMessageUtil().formatExecError)(
|
||||
testResult.testExecError,
|
||||
test.context.config,
|
||||
this._globalConfig,
|
||||
test.path
|
||||
);
|
||||
(0, _testResult().addResult)(aggregatedResults, testResult);
|
||||
await this._dispatcher.onTestFileResult(
|
||||
test,
|
||||
testResult,
|
||||
aggregatedResults
|
||||
);
|
||||
};
|
||||
const updateSnapshotState = async () => {
|
||||
const contextsWithSnapshotResolvers = await Promise.all(
|
||||
Array.from(testContexts).map(async context => [
|
||||
context,
|
||||
await (0, _jestSnapshot().buildSnapshotResolver)(context.config)
|
||||
])
|
||||
);
|
||||
contextsWithSnapshotResolvers.forEach(([context, snapshotResolver]) => {
|
||||
const status = (0, _jestSnapshot().cleanup)(
|
||||
context.hasteFS,
|
||||
this._globalConfig.updateSnapshot,
|
||||
snapshotResolver,
|
||||
context.config.testPathIgnorePatterns
|
||||
);
|
||||
aggregatedResults.snapshot.filesRemoved += status.filesRemoved;
|
||||
aggregatedResults.snapshot.filesRemovedList = (
|
||||
aggregatedResults.snapshot.filesRemovedList || []
|
||||
).concat(status.filesRemovedList);
|
||||
});
|
||||
const updateAll = this._globalConfig.updateSnapshot === 'all';
|
||||
aggregatedResults.snapshot.didUpdate = updateAll;
|
||||
aggregatedResults.snapshot.failure = !!(
|
||||
!updateAll &&
|
||||
(aggregatedResults.snapshot.unchecked ||
|
||||
aggregatedResults.snapshot.unmatched ||
|
||||
aggregatedResults.snapshot.filesRemoved)
|
||||
);
|
||||
};
|
||||
await this._dispatcher.onRunStart(aggregatedResults, {
|
||||
estimatedTime,
|
||||
showStatus: !runInBand
|
||||
});
|
||||
const testRunners = Object.create(null);
|
||||
const contextsByTestRunner = new WeakMap();
|
||||
try {
|
||||
await Promise.all(
|
||||
Array.from(testContexts).map(async context => {
|
||||
const {config} = context;
|
||||
if (!testRunners[config.runner]) {
|
||||
const transformer = await (0, _transform().createScriptTransformer)(
|
||||
config
|
||||
);
|
||||
const Runner = await transformer.requireAndTranspileModule(
|
||||
config.runner
|
||||
);
|
||||
const runner = new Runner(this._globalConfig, {
|
||||
changedFiles: this._context.changedFiles,
|
||||
sourcesRelatedToTestsInChangedFiles:
|
||||
this._context.sourcesRelatedToTestsInChangedFiles
|
||||
});
|
||||
testRunners[config.runner] = runner;
|
||||
contextsByTestRunner.set(runner, context);
|
||||
}
|
||||
})
|
||||
);
|
||||
const testsByRunner = this._partitionTests(testRunners, tests);
|
||||
if (testsByRunner) {
|
||||
try {
|
||||
for (const runner of Object.keys(testRunners)) {
|
||||
const testRunner = testRunners[runner];
|
||||
const context = contextsByTestRunner.get(testRunner);
|
||||
(0, _jestUtil().invariant)(context);
|
||||
const tests = testsByRunner[runner];
|
||||
const testRunnerOptions = {
|
||||
serial: runInBand || Boolean(testRunner.isSerial)
|
||||
};
|
||||
if (testRunner.supportsEventEmitters) {
|
||||
const unsubscribes = [
|
||||
testRunner.on('test-file-start', ([test]) =>
|
||||
onTestFileStart(test)
|
||||
),
|
||||
testRunner.on('test-file-success', ([test, testResult]) =>
|
||||
onResult(test, testResult)
|
||||
),
|
||||
testRunner.on('test-file-failure', ([test, error]) =>
|
||||
onFailure(test, error)
|
||||
),
|
||||
testRunner.on(
|
||||
'test-case-start',
|
||||
([testPath, testCaseStartInfo]) => {
|
||||
const test = {
|
||||
context,
|
||||
path: testPath
|
||||
};
|
||||
this._dispatcher.onTestCaseStart(test, testCaseStartInfo);
|
||||
}
|
||||
),
|
||||
testRunner.on(
|
||||
'test-case-result',
|
||||
([testPath, testCaseResult]) => {
|
||||
const test = {
|
||||
context,
|
||||
path: testPath
|
||||
};
|
||||
this._dispatcher.onTestCaseResult(test, testCaseResult);
|
||||
}
|
||||
)
|
||||
];
|
||||
await testRunner.runTests(tests, watcher, testRunnerOptions);
|
||||
unsubscribes.forEach(sub => sub());
|
||||
} else {
|
||||
await testRunner.runTests(
|
||||
tests,
|
||||
watcher,
|
||||
onTestFileStart,
|
||||
onResult,
|
||||
onFailure,
|
||||
testRunnerOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (!watcher.isInterrupted()) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
aggregatedResults.runExecError = buildExecError(error);
|
||||
await this._dispatcher.onRunComplete(testContexts, aggregatedResults);
|
||||
throw error;
|
||||
}
|
||||
await updateSnapshotState();
|
||||
aggregatedResults.wasInterrupted = watcher.isInterrupted();
|
||||
await this._dispatcher.onRunComplete(testContexts, aggregatedResults);
|
||||
const anyTestFailures = !(
|
||||
aggregatedResults.numFailedTests === 0 &&
|
||||
aggregatedResults.numRuntimeErrorTestSuites === 0
|
||||
);
|
||||
const anyReporterErrors = this._dispatcher.hasErrors();
|
||||
aggregatedResults.success = !(
|
||||
anyTestFailures ||
|
||||
aggregatedResults.snapshot.failure ||
|
||||
anyReporterErrors
|
||||
);
|
||||
return aggregatedResults;
|
||||
}
|
||||
_partitionTests(testRunners, tests) {
|
||||
if (Object.keys(testRunners).length > 1) {
|
||||
return tests.reduce((testRuns, test) => {
|
||||
const runner = test.context.config.runner;
|
||||
if (!testRuns[runner]) {
|
||||
testRuns[runner] = [];
|
||||
}
|
||||
testRuns[runner].push(test);
|
||||
return testRuns;
|
||||
}, Object.create(null));
|
||||
} else if (tests.length > 0 && tests[0] != null) {
|
||||
// If there is only one runner, don't partition the tests.
|
||||
return Object.assign(Object.create(null), {
|
||||
[tests[0].context.config.runner]: tests
|
||||
});
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async _setupReporters() {
|
||||
const {collectCoverage: coverage, notify, verbose} = this._globalConfig;
|
||||
const reporters = this._globalConfig.reporters || [['default', {}]];
|
||||
let summaryOptions = null;
|
||||
for (const [reporter, options] of reporters) {
|
||||
switch (reporter) {
|
||||
case 'default':
|
||||
summaryOptions = options;
|
||||
verbose
|
||||
? this.addReporter(
|
||||
new (_reporters().VerboseReporter)(this._globalConfig)
|
||||
)
|
||||
: this.addReporter(
|
||||
new (_reporters().DefaultReporter)(this._globalConfig)
|
||||
);
|
||||
break;
|
||||
case 'github-actions':
|
||||
_ciInfo().GITHUB_ACTIONS &&
|
||||
this.addReporter(
|
||||
new (_reporters().GitHubActionsReporter)(
|
||||
this._globalConfig,
|
||||
options
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'summary':
|
||||
summaryOptions = options;
|
||||
break;
|
||||
default:
|
||||
await this._addCustomReporter(reporter, options);
|
||||
}
|
||||
}
|
||||
if (notify) {
|
||||
this.addReporter(
|
||||
new (_reporters().NotifyReporter)(this._globalConfig, this._context)
|
||||
);
|
||||
}
|
||||
if (coverage) {
|
||||
this.addReporter(
|
||||
new (_reporters().CoverageReporter)(this._globalConfig, this._context)
|
||||
);
|
||||
}
|
||||
if (summaryOptions != null) {
|
||||
this.addReporter(
|
||||
new (_reporters().SummaryReporter)(this._globalConfig, summaryOptions)
|
||||
);
|
||||
}
|
||||
}
|
||||
async _addCustomReporter(reporter, options) {
|
||||
try {
|
||||
const Reporter = await (0, _jestUtil().requireOrImportModule)(reporter);
|
||||
this.addReporter(
|
||||
new Reporter(this._globalConfig, options, this._context)
|
||||
);
|
||||
} catch (error) {
|
||||
error.message = `An error occurred while adding the reporter at path "${_chalk().default.bold(
|
||||
reporter
|
||||
)}".\n${error instanceof Error ? error.message : ''}`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async _bailIfNeeded(testContexts, aggregatedResults, watcher) {
|
||||
if (
|
||||
this._globalConfig.bail !== 0 &&
|
||||
aggregatedResults.numFailedTests >= this._globalConfig.bail
|
||||
) {
|
||||
if (watcher.isWatchMode()) {
|
||||
await watcher.setState({
|
||||
interrupted: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this._dispatcher.onRunComplete(testContexts, aggregatedResults);
|
||||
} finally {
|
||||
const exitCode = this._globalConfig.testFailureExitCode;
|
||||
(0, _exit().default)(exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const createAggregatedResults = numTotalTestSuites => {
|
||||
const result = (0, _testResult().makeEmptyAggregatedTestResult)();
|
||||
result.numTotalTestSuites = numTotalTestSuites;
|
||||
result.startTime = Date.now();
|
||||
result.success = false;
|
||||
return result;
|
||||
};
|
||||
const getEstimatedTime = (timings, workers) => {
|
||||
if (timings.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
const max = Math.max(...timings);
|
||||
return timings.length <= workers
|
||||
? max
|
||||
: Math.max(timings.reduce((sum, time) => sum + time) / workers, max);
|
||||
};
|
||||
const strToError = errString => {
|
||||
const {message, stack} = (0, _jestMessageUtil().separateMessageFromStack)(
|
||||
errString
|
||||
);
|
||||
if (stack.length > 0) {
|
||||
return {
|
||||
message,
|
||||
stack
|
||||
};
|
||||
}
|
||||
const error = new (_jestUtil().ErrorWithStack)(message, buildExecError);
|
||||
return {
|
||||
message,
|
||||
stack: error.stack || ''
|
||||
};
|
||||
};
|
||||
const buildExecError = err => {
|
||||
if (typeof err === 'string' || err == null) {
|
||||
return strToError(err || 'Error');
|
||||
}
|
||||
const anyErr = err;
|
||||
if (typeof anyErr.message === 'string') {
|
||||
if (typeof anyErr.stack === 'string' && anyErr.stack.length > 0) {
|
||||
return anyErr;
|
||||
}
|
||||
return strToError(anyErr.message);
|
||||
}
|
||||
return strToError(JSON.stringify(err));
|
||||
};
|
417
backend/apis/nodejs/node_modules/@jest/core/build/cli/index.js
generated
vendored
Normal file
417
backend/apis/nodejs/node_modules/@jest/core/build/cli/index.js
generated
vendored
Normal file
@ -0,0 +1,417 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.runCLI = runCLI;
|
||||
function _perf_hooks() {
|
||||
const data = require('perf_hooks');
|
||||
_perf_hooks = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _console() {
|
||||
const data = require('@jest/console');
|
||||
_console = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestConfig() {
|
||||
const data = require('jest-config');
|
||||
_jestConfig = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestRuntime() {
|
||||
const data = _interopRequireDefault(require('jest-runtime'));
|
||||
_jestRuntime = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _collectHandles = require('../collectHandles');
|
||||
var _getChangedFilesPromise = _interopRequireDefault(
|
||||
require('../getChangedFilesPromise')
|
||||
);
|
||||
var _getConfigsOfProjectsToRun = _interopRequireDefault(
|
||||
require('../getConfigsOfProjectsToRun')
|
||||
);
|
||||
var _getProjectNamesMissingWarning = _interopRequireDefault(
|
||||
require('../getProjectNamesMissingWarning')
|
||||
);
|
||||
var _getSelectProjectsMessage = _interopRequireDefault(
|
||||
require('../getSelectProjectsMessage')
|
||||
);
|
||||
var _createContext = _interopRequireDefault(require('../lib/createContext'));
|
||||
var _handleDeprecationWarnings = _interopRequireDefault(
|
||||
require('../lib/handleDeprecationWarnings')
|
||||
);
|
||||
var _logDebugMessages = _interopRequireDefault(
|
||||
require('../lib/logDebugMessages')
|
||||
);
|
||||
var _runJest = _interopRequireDefault(require('../runJest'));
|
||||
var _watch = _interopRequireDefault(require('../watch'));
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {print: preRunMessagePrint} = _jestUtil().preRunMessage;
|
||||
async function runCLI(argv, projects) {
|
||||
_perf_hooks().performance.mark('jest/runCLI:start');
|
||||
let results;
|
||||
|
||||
// If we output a JSON object, we can't write anything to stdout, since
|
||||
// it'll break the JSON structure and it won't be valid.
|
||||
const outputStream =
|
||||
argv.json || argv.useStderr ? process.stderr : process.stdout;
|
||||
const {globalConfig, configs, hasDeprecationWarnings} = await (0,
|
||||
_jestConfig().readConfigs)(argv, projects);
|
||||
if (argv.debug) {
|
||||
(0, _logDebugMessages.default)(globalConfig, configs, outputStream);
|
||||
}
|
||||
if (argv.showConfig) {
|
||||
(0, _logDebugMessages.default)(globalConfig, configs, process.stdout);
|
||||
(0, _exit().default)(0);
|
||||
}
|
||||
if (argv.clearCache) {
|
||||
// stick in a Set to dedupe the deletions
|
||||
new Set(configs.map(config => config.cacheDirectory)).forEach(
|
||||
cacheDirectory => {
|
||||
fs().rmSync(cacheDirectory, {
|
||||
force: true,
|
||||
recursive: true
|
||||
});
|
||||
process.stdout.write(`Cleared ${cacheDirectory}\n`);
|
||||
}
|
||||
);
|
||||
(0, _exit().default)(0);
|
||||
}
|
||||
const configsOfProjectsToRun = (0, _getConfigsOfProjectsToRun.default)(
|
||||
configs,
|
||||
{
|
||||
ignoreProjects: argv.ignoreProjects,
|
||||
selectProjects: argv.selectProjects
|
||||
}
|
||||
);
|
||||
if (argv.selectProjects || argv.ignoreProjects) {
|
||||
const namesMissingWarning = (0, _getProjectNamesMissingWarning.default)(
|
||||
configs,
|
||||
{
|
||||
ignoreProjects: argv.ignoreProjects,
|
||||
selectProjects: argv.selectProjects
|
||||
}
|
||||
);
|
||||
if (namesMissingWarning) {
|
||||
outputStream.write(namesMissingWarning);
|
||||
}
|
||||
outputStream.write(
|
||||
(0, _getSelectProjectsMessage.default)(configsOfProjectsToRun, {
|
||||
ignoreProjects: argv.ignoreProjects,
|
||||
selectProjects: argv.selectProjects
|
||||
})
|
||||
);
|
||||
}
|
||||
await _run10000(
|
||||
globalConfig,
|
||||
configsOfProjectsToRun,
|
||||
hasDeprecationWarnings,
|
||||
outputStream,
|
||||
r => {
|
||||
results = r;
|
||||
}
|
||||
);
|
||||
if (argv.watch || argv.watchAll) {
|
||||
// If in watch mode, return the promise that will never resolve.
|
||||
// If the watch mode is interrupted, watch should handle the process
|
||||
// shutdown.
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
return new Promise(() => {});
|
||||
}
|
||||
if (!results) {
|
||||
throw new Error(
|
||||
'AggregatedResult must be present after test run is complete'
|
||||
);
|
||||
}
|
||||
const {openHandles} = results;
|
||||
if (openHandles && openHandles.length) {
|
||||
const formatted = (0, _collectHandles.formatHandleErrors)(
|
||||
openHandles,
|
||||
configs[0]
|
||||
);
|
||||
const openHandlesString = (0, _jestUtil().pluralize)(
|
||||
'open handle',
|
||||
formatted.length,
|
||||
's'
|
||||
);
|
||||
const message =
|
||||
_chalk().default.red(
|
||||
`\nJest has detected the following ${openHandlesString} potentially keeping Jest from exiting:\n\n`
|
||||
) + formatted.join('\n\n');
|
||||
console.error(message);
|
||||
}
|
||||
_perf_hooks().performance.mark('jest/runCLI:end');
|
||||
return {
|
||||
globalConfig,
|
||||
results
|
||||
};
|
||||
}
|
||||
const buildContextsAndHasteMaps = async (
|
||||
configs,
|
||||
globalConfig,
|
||||
outputStream
|
||||
) => {
|
||||
const hasteMapInstances = Array(configs.length);
|
||||
const contexts = await Promise.all(
|
||||
configs.map(async (config, index) => {
|
||||
(0, _jestUtil().createDirectory)(config.cacheDirectory);
|
||||
const hasteMapInstance = await _jestRuntime().default.createHasteMap(
|
||||
config,
|
||||
{
|
||||
console: new (_console().CustomConsole)(outputStream, outputStream),
|
||||
maxWorkers: Math.max(
|
||||
1,
|
||||
Math.floor(globalConfig.maxWorkers / configs.length)
|
||||
),
|
||||
resetCache: !config.cache,
|
||||
watch: globalConfig.watch || globalConfig.watchAll,
|
||||
watchman: globalConfig.watchman,
|
||||
workerThreads: globalConfig.workerThreads
|
||||
}
|
||||
);
|
||||
hasteMapInstances[index] = hasteMapInstance;
|
||||
return (0, _createContext.default)(
|
||||
config,
|
||||
await hasteMapInstance.build()
|
||||
);
|
||||
})
|
||||
);
|
||||
return {
|
||||
contexts,
|
||||
hasteMapInstances
|
||||
};
|
||||
};
|
||||
const _run10000 = async (
|
||||
globalConfig,
|
||||
configs,
|
||||
hasDeprecationWarnings,
|
||||
outputStream,
|
||||
onComplete
|
||||
) => {
|
||||
// Queries to hg/git can take a while, so we need to start the process
|
||||
// as soon as possible, so by the time we need the result it's already there.
|
||||
const changedFilesPromise = (0, _getChangedFilesPromise.default)(
|
||||
globalConfig,
|
||||
configs
|
||||
);
|
||||
if (changedFilesPromise) {
|
||||
_perf_hooks().performance.mark('jest/getChangedFiles:start');
|
||||
changedFilesPromise.finally(() => {
|
||||
_perf_hooks().performance.mark('jest/getChangedFiles:end');
|
||||
});
|
||||
}
|
||||
|
||||
// Filter may need to do an HTTP call or something similar to setup.
|
||||
// We will wait on an async response from this before using the filter.
|
||||
let filter;
|
||||
if (globalConfig.filter && !globalConfig.skipFilter) {
|
||||
const rawFilter = require(globalConfig.filter);
|
||||
let filterSetupPromise;
|
||||
if (rawFilter.setup) {
|
||||
// Wrap filter setup Promise to avoid "uncaught Promise" error.
|
||||
// If an error is returned, we surface it in the return value.
|
||||
filterSetupPromise = (async () => {
|
||||
try {
|
||||
await rawFilter.setup();
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
return undefined;
|
||||
})();
|
||||
}
|
||||
filter = async testPaths => {
|
||||
if (filterSetupPromise) {
|
||||
// Expect an undefined return value unless there was an error.
|
||||
const err = await filterSetupPromise;
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return rawFilter(testPaths);
|
||||
};
|
||||
}
|
||||
_perf_hooks().performance.mark('jest/buildContextsAndHasteMaps:start');
|
||||
const {contexts, hasteMapInstances} = await buildContextsAndHasteMaps(
|
||||
configs,
|
||||
globalConfig,
|
||||
outputStream
|
||||
);
|
||||
_perf_hooks().performance.mark('jest/buildContextsAndHasteMaps:end');
|
||||
globalConfig.watch || globalConfig.watchAll
|
||||
? await runWatch(
|
||||
contexts,
|
||||
configs,
|
||||
hasDeprecationWarnings,
|
||||
globalConfig,
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
filter
|
||||
)
|
||||
: await runWithoutWatch(
|
||||
globalConfig,
|
||||
contexts,
|
||||
outputStream,
|
||||
onComplete,
|
||||
changedFilesPromise,
|
||||
filter
|
||||
);
|
||||
};
|
||||
const runWatch = async (
|
||||
contexts,
|
||||
_configs,
|
||||
hasDeprecationWarnings,
|
||||
globalConfig,
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
filter
|
||||
) => {
|
||||
if (hasDeprecationWarnings) {
|
||||
try {
|
||||
await (0, _handleDeprecationWarnings.default)(
|
||||
outputStream,
|
||||
process.stdin
|
||||
);
|
||||
return await (0, _watch.default)(
|
||||
globalConfig,
|
||||
contexts,
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
undefined,
|
||||
undefined,
|
||||
filter
|
||||
);
|
||||
} catch {
|
||||
(0, _exit().default)(0);
|
||||
}
|
||||
}
|
||||
return (0, _watch.default)(
|
||||
globalConfig,
|
||||
contexts,
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
undefined,
|
||||
undefined,
|
||||
filter
|
||||
);
|
||||
};
|
||||
const runWithoutWatch = async (
|
||||
globalConfig,
|
||||
contexts,
|
||||
outputStream,
|
||||
onComplete,
|
||||
changedFilesPromise,
|
||||
filter
|
||||
) => {
|
||||
const startRun = async () => {
|
||||
if (!globalConfig.listTests) {
|
||||
preRunMessagePrint(outputStream);
|
||||
}
|
||||
return (0, _runJest.default)({
|
||||
changedFilesPromise,
|
||||
contexts,
|
||||
failedTestsCache: undefined,
|
||||
filter,
|
||||
globalConfig,
|
||||
onComplete,
|
||||
outputStream,
|
||||
startRun,
|
||||
testWatcher: new (_jestWatcher().TestWatcher)({
|
||||
isWatchMode: false
|
||||
})
|
||||
});
|
||||
};
|
||||
return startRun();
|
||||
};
|
266
backend/apis/nodejs/node_modules/@jest/core/build/collectHandles.js
generated
vendored
Normal file
266
backend/apis/nodejs/node_modules/@jest/core/build/collectHandles.js
generated
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = collectHandles;
|
||||
exports.formatHandleErrors = formatHandleErrors;
|
||||
function asyncHooks() {
|
||||
const data = _interopRequireWildcard(require('async_hooks'));
|
||||
asyncHooks = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _util() {
|
||||
const data = require('util');
|
||||
_util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function v8() {
|
||||
const data = _interopRequireWildcard(require('v8'));
|
||||
v8 = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function vm() {
|
||||
const data = _interopRequireWildcard(require('vm'));
|
||||
vm = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _stripAnsi() {
|
||||
const data = _interopRequireDefault(require('strip-ansi'));
|
||||
_stripAnsi = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 */
|
||||
|
||||
function stackIsFromUser(stack) {
|
||||
// Either the test file, or something required by it
|
||||
if (stack.includes('Runtime.requireModule')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// jest-jasmine it or describe call
|
||||
if (stack.includes('asyncJestTest') || stack.includes('asyncJestLifecycle')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// An async function call from within circus
|
||||
if (stack.includes('callAsyncCircusFn')) {
|
||||
// jest-circus it or describe call
|
||||
return (
|
||||
stack.includes('_callCircusTest') || stack.includes('_callCircusHook')
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const alwaysActive = () => true;
|
||||
|
||||
// @ts-expect-error: doesn't exist in v12 typings
|
||||
const hasWeakRef = typeof WeakRef === 'function';
|
||||
const asyncSleep = (0, _util().promisify)(setTimeout);
|
||||
let gcFunc = globalThis.gc;
|
||||
function runGC() {
|
||||
if (!gcFunc) {
|
||||
v8().setFlagsFromString('--expose-gc');
|
||||
gcFunc = vm().runInNewContext('gc');
|
||||
v8().setFlagsFromString('--no-expose-gc');
|
||||
if (!gcFunc) {
|
||||
throw new Error(
|
||||
'Cannot find `global.gc` function. Please run node with `--expose-gc` and report this issue in jest repo.'
|
||||
);
|
||||
}
|
||||
}
|
||||
gcFunc();
|
||||
}
|
||||
|
||||
// Inspired by https://github.com/mafintosh/why-is-node-running/blob/master/index.js
|
||||
// Extracted as we want to format the result ourselves
|
||||
function collectHandles() {
|
||||
const activeHandles = new Map();
|
||||
const hook = asyncHooks().createHook({
|
||||
destroy(asyncId) {
|
||||
activeHandles.delete(asyncId);
|
||||
},
|
||||
init: function initHook(asyncId, type, triggerAsyncId, resource) {
|
||||
// Skip resources that should not generally prevent the process from
|
||||
// exiting, not last a meaningfully long time, or otherwise shouldn't be
|
||||
// tracked.
|
||||
if (
|
||||
type === 'PROMISE' ||
|
||||
type === 'TIMERWRAP' ||
|
||||
type === 'ELDHISTOGRAM' ||
|
||||
type === 'PerformanceObserver' ||
|
||||
type === 'RANDOMBYTESREQUEST' ||
|
||||
type === 'DNSCHANNEL' ||
|
||||
type === 'ZLIB' ||
|
||||
type === 'SIGNREQUEST'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const error = new (_jestUtil().ErrorWithStack)(type, initHook, 100);
|
||||
let fromUser = stackIsFromUser(error.stack || '');
|
||||
|
||||
// If the async resource was not directly created by user code, but was
|
||||
// triggered by another async resource from user code, track it and use
|
||||
// the original triggering resource's stack.
|
||||
if (!fromUser) {
|
||||
const triggeringHandle = activeHandles.get(triggerAsyncId);
|
||||
if (triggeringHandle) {
|
||||
fromUser = true;
|
||||
error.stack = triggeringHandle.error.stack;
|
||||
}
|
||||
}
|
||||
if (fromUser) {
|
||||
let isActive;
|
||||
|
||||
// Handle that supports hasRef
|
||||
if ('hasRef' in resource) {
|
||||
if (hasWeakRef) {
|
||||
// @ts-expect-error: doesn't exist in v12 typings
|
||||
const ref = new WeakRef(resource);
|
||||
isActive = () => {
|
||||
return ref.deref()?.hasRef() ?? false;
|
||||
};
|
||||
} else {
|
||||
isActive = resource.hasRef.bind(resource);
|
||||
}
|
||||
} else {
|
||||
// Handle that doesn't support hasRef
|
||||
isActive = alwaysActive;
|
||||
}
|
||||
activeHandles.set(asyncId, {
|
||||
error,
|
||||
isActive
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
hook.enable();
|
||||
return async () => {
|
||||
// Wait briefly for any async resources that have been queued for
|
||||
// destruction to actually be destroyed.
|
||||
// For example, Node.js TCP Servers are not destroyed until *after* their
|
||||
// `close` callback runs. If someone finishes a test from the `close`
|
||||
// callback, we will not yet have seen the resource be destroyed here.
|
||||
await asyncSleep(100);
|
||||
if (activeHandles.size > 0) {
|
||||
// For some special objects such as `TLSWRAP`.
|
||||
// Ref: https://github.com/jestjs/jest/issues/11665
|
||||
runGC();
|
||||
await asyncSleep(0);
|
||||
}
|
||||
hook.disable();
|
||||
|
||||
// Get errors for every async resource still referenced at this moment
|
||||
const result = Array.from(activeHandles.values())
|
||||
.filter(({isActive}) => isActive())
|
||||
.map(({error}) => error);
|
||||
activeHandles.clear();
|
||||
return result;
|
||||
};
|
||||
}
|
||||
function formatHandleErrors(errors, config) {
|
||||
const stacks = new Set();
|
||||
return (
|
||||
errors
|
||||
.map(err =>
|
||||
(0, _jestMessageUtil().formatExecError)(
|
||||
err,
|
||||
config,
|
||||
{
|
||||
noStackTrace: false
|
||||
},
|
||||
undefined,
|
||||
true
|
||||
)
|
||||
)
|
||||
// E.g. timeouts might give multiple traces to the same line of code
|
||||
// This hairy filtering tries to remove entries with duplicate stack traces
|
||||
.filter(handle => {
|
||||
const ansiFree = (0, _stripAnsi().default)(handle);
|
||||
const match = ansiFree.match(/\s+at(.*)/);
|
||||
if (!match || match.length < 2) {
|
||||
return true;
|
||||
}
|
||||
const stack = ansiFree.substr(ansiFree.indexOf(match[1])).trim();
|
||||
if (stacks.has(stack)) {
|
||||
return false;
|
||||
}
|
||||
stacks.add(stack);
|
||||
return true;
|
||||
})
|
||||
);
|
||||
}
|
65
backend/apis/nodejs/node_modules/@jest/core/build/getChangedFilesPromise.js
generated
vendored
Normal file
65
backend/apis/nodejs/node_modules/@jest/core/build/getChangedFilesPromise.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getChangedFilesPromise;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestChangedFiles() {
|
||||
const data = require('jest-changed-files');
|
||||
_jestChangedFiles = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getChangedFilesPromise(globalConfig, configs) {
|
||||
if (globalConfig.onlyChanged) {
|
||||
const allRootsForAllProjects = configs.reduce((roots, config) => {
|
||||
if (config.roots) {
|
||||
roots.push(...config.roots);
|
||||
}
|
||||
return roots;
|
||||
}, []);
|
||||
return (0, _jestChangedFiles().getChangedFilesForRoots)(
|
||||
allRootsForAllProjects,
|
||||
{
|
||||
changedSince: globalConfig.changedSince,
|
||||
lastCommit: globalConfig.lastCommit,
|
||||
withAncestor: globalConfig.changedFilesWithAncestor
|
||||
}
|
||||
).catch(e => {
|
||||
const message = (0, _jestMessageUtil().formatExecError)(e, configs[0], {
|
||||
noStackTrace: true
|
||||
})
|
||||
.split('\n')
|
||||
.filter(line => !line.includes('Command failed:'))
|
||||
.join('\n');
|
||||
console.error(_chalk().default.red(`\n\n${message}`));
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
40
backend/apis/nodejs/node_modules/@jest/core/build/getConfigsOfProjectsToRun.js
generated
vendored
Normal file
40
backend/apis/nodejs/node_modules/@jest/core/build/getConfigsOfProjectsToRun.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getConfigsOfProjectsToRun;
|
||||
var _getProjectDisplayName = _interopRequireDefault(
|
||||
require('./getProjectDisplayName')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getConfigsOfProjectsToRun(projectConfigs, opts) {
|
||||
const projectFilter = createProjectFilter(opts);
|
||||
return projectConfigs.filter(config => {
|
||||
const name = (0, _getProjectDisplayName.default)(config);
|
||||
return projectFilter(name);
|
||||
});
|
||||
}
|
||||
function createProjectFilter(opts) {
|
||||
const {selectProjects, ignoreProjects} = opts;
|
||||
const always = () => true;
|
||||
const selected = selectProjects
|
||||
? name => name && selectProjects.includes(name)
|
||||
: always;
|
||||
const notIgnore = ignoreProjects
|
||||
? name => !(name && ignoreProjects.includes(name))
|
||||
: always;
|
||||
function test(name) {
|
||||
return selected(name) && notIgnore(name);
|
||||
}
|
||||
return test;
|
||||
}
|
80
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFound.js
generated
vendored
Normal file
80
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFound.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestFound;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestFound(testRunData, globalConfig, willExitWith0) {
|
||||
const testFiles = testRunData.reduce(
|
||||
(current, testRun) => current + (testRun.matches.total || 0),
|
||||
0
|
||||
);
|
||||
let dataMessage;
|
||||
if (globalConfig.runTestsByPath) {
|
||||
dataMessage = `Files: ${globalConfig.nonFlagArgs
|
||||
.map(p => `"${p}"`)
|
||||
.join(', ')}`;
|
||||
} else {
|
||||
dataMessage = `Pattern: ${_chalk().default.yellow(
|
||||
globalConfig.testPathPattern
|
||||
)} - 0 matches`;
|
||||
}
|
||||
if (willExitWith0) {
|
||||
return (
|
||||
`${_chalk().default.bold('No tests found, exiting with code 0')}\n` +
|
||||
`In ${_chalk().default.bold(globalConfig.rootDir)}` +
|
||||
'\n' +
|
||||
` ${(0, _jestUtil().pluralize)(
|
||||
'file',
|
||||
testFiles,
|
||||
's'
|
||||
)} checked across ${(0, _jestUtil().pluralize)(
|
||||
'project',
|
||||
testRunData.length,
|
||||
's'
|
||||
)}. Run with \`--verbose\` for more details.` +
|
||||
`\n${dataMessage}`
|
||||
);
|
||||
}
|
||||
return (
|
||||
`${_chalk().default.bold('No tests found, exiting with code 1')}\n` +
|
||||
'Run with `--passWithNoTests` to exit with code 0' +
|
||||
'\n' +
|
||||
`In ${_chalk().default.bold(globalConfig.rootDir)}` +
|
||||
'\n' +
|
||||
` ${(0, _jestUtil().pluralize)(
|
||||
'file',
|
||||
testFiles,
|
||||
's'
|
||||
)} checked across ${(0, _jestUtil().pluralize)(
|
||||
'project',
|
||||
testRunData.length,
|
||||
's'
|
||||
)}. Run with \`--verbose\` for more details.` +
|
||||
`\n${dataMessage}`
|
||||
);
|
||||
}
|
43
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundFailed.js
generated
vendored
Normal file
43
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundFailed.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestFoundFailed;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestFoundFailed(globalConfig) {
|
||||
let msg = _chalk().default.bold('No failed test found.');
|
||||
if (_jestUtil().isInteractive) {
|
||||
msg += _chalk().default.dim(
|
||||
`\n${
|
||||
globalConfig.watch
|
||||
? 'Press `f` to quit "only failed tests" mode.'
|
||||
: 'Run Jest without `--onlyFailures` or with `--all` to run all tests.'
|
||||
}`
|
||||
);
|
||||
}
|
||||
return msg;
|
||||
}
|
26
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundPassWithNoTests.js
generated
vendored
Normal file
26
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundPassWithNoTests.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestFoundPassWithNoTests;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestFoundPassWithNoTests() {
|
||||
return _chalk().default.bold('No tests found, exiting with code 0');
|
||||
}
|
48
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundRelatedToChangedFiles.js
generated
vendored
Normal file
48
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundRelatedToChangedFiles.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestFoundRelatedToChangedFiles;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestFoundRelatedToChangedFiles(globalConfig) {
|
||||
const ref = globalConfig.changedSince
|
||||
? `"${globalConfig.changedSince}"`
|
||||
: 'last commit';
|
||||
let msg = _chalk().default.bold(
|
||||
`No tests found related to files changed since ${ref}.`
|
||||
);
|
||||
if (_jestUtil().isInteractive) {
|
||||
msg += _chalk().default.dim(
|
||||
`\n${
|
||||
globalConfig.watch
|
||||
? 'Press `a` to run all tests, or run Jest with `--watchAll`.'
|
||||
: 'Run Jest without `-o` or with `--all` to run all tests.'
|
||||
}`
|
||||
);
|
||||
}
|
||||
return msg;
|
||||
}
|
91
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundVerbose.js
generated
vendored
Normal file
91
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestFoundVerbose.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestFoundVerbose;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestFoundVerbose(testRunData, globalConfig, willExitWith0) {
|
||||
const individualResults = testRunData.map(testRun => {
|
||||
const stats = testRun.matches.stats || {};
|
||||
const config = testRun.context.config;
|
||||
const statsMessage = Object.keys(stats)
|
||||
.map(key => {
|
||||
if (key === 'roots' && config.roots.length === 1) {
|
||||
return null;
|
||||
}
|
||||
const value = config[key];
|
||||
if (value) {
|
||||
const valueAsString = Array.isArray(value)
|
||||
? value.join(', ')
|
||||
: String(value);
|
||||
const matches = (0, _jestUtil().pluralize)(
|
||||
'match',
|
||||
stats[key] || 0,
|
||||
'es'
|
||||
);
|
||||
return ` ${key}: ${_chalk().default.yellow(
|
||||
valueAsString
|
||||
)} - ${matches}`;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(line => line)
|
||||
.join('\n');
|
||||
return testRun.matches.total
|
||||
? `In ${_chalk().default.bold(config.rootDir)}\n` +
|
||||
` ${(0, _jestUtil().pluralize)(
|
||||
'file',
|
||||
testRun.matches.total || 0,
|
||||
's'
|
||||
)} checked.\n${statsMessage}`
|
||||
: `No files found in ${config.rootDir}.\n` +
|
||||
"Make sure Jest's configuration does not exclude this directory." +
|
||||
'\nTo set up Jest, make sure a package.json file exists.\n' +
|
||||
'Jest Documentation: ' +
|
||||
'https://jestjs.io/docs/configuration';
|
||||
});
|
||||
let dataMessage;
|
||||
if (globalConfig.runTestsByPath) {
|
||||
dataMessage = `Files: ${globalConfig.nonFlagArgs
|
||||
.map(p => `"${p}"`)
|
||||
.join(', ')}`;
|
||||
} else {
|
||||
dataMessage = `Pattern: ${_chalk().default.yellow(
|
||||
globalConfig.testPathPattern
|
||||
)} - 0 matches`;
|
||||
}
|
||||
if (willExitWith0) {
|
||||
return `${_chalk().default.bold(
|
||||
'No tests found, exiting with code 0'
|
||||
)}\n${individualResults.join('\n')}\n${dataMessage}`;
|
||||
}
|
||||
return (
|
||||
`${_chalk().default.bold('No tests found, exiting with code 1')}\n` +
|
||||
'Run with `--passWithNoTests` to exit with code 0' +
|
||||
`\n${individualResults.join('\n')}\n${dataMessage}`
|
||||
);
|
||||
}
|
64
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestsFoundMessage.js
generated
vendored
Normal file
64
backend/apis/nodejs/node_modules/@jest/core/build/getNoTestsFoundMessage.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNoTestsFoundMessage;
|
||||
var _getNoTestFound = _interopRequireDefault(require('./getNoTestFound'));
|
||||
var _getNoTestFoundFailed = _interopRequireDefault(
|
||||
require('./getNoTestFoundFailed')
|
||||
);
|
||||
var _getNoTestFoundPassWithNoTests = _interopRequireDefault(
|
||||
require('./getNoTestFoundPassWithNoTests')
|
||||
);
|
||||
var _getNoTestFoundRelatedToChangedFiles = _interopRequireDefault(
|
||||
require('./getNoTestFoundRelatedToChangedFiles')
|
||||
);
|
||||
var _getNoTestFoundVerbose = _interopRequireDefault(
|
||||
require('./getNoTestFoundVerbose')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getNoTestsFoundMessage(testRunData, globalConfig) {
|
||||
const exitWith0 =
|
||||
globalConfig.passWithNoTests ||
|
||||
globalConfig.lastCommit ||
|
||||
globalConfig.onlyChanged;
|
||||
if (globalConfig.onlyFailures) {
|
||||
return {
|
||||
exitWith0,
|
||||
message: (0, _getNoTestFoundFailed.default)(globalConfig)
|
||||
};
|
||||
}
|
||||
if (globalConfig.onlyChanged) {
|
||||
return {
|
||||
exitWith0,
|
||||
message: (0, _getNoTestFoundRelatedToChangedFiles.default)(globalConfig)
|
||||
};
|
||||
}
|
||||
if (globalConfig.passWithNoTests) {
|
||||
return {
|
||||
exitWith0,
|
||||
message: (0, _getNoTestFoundPassWithNoTests.default)()
|
||||
};
|
||||
}
|
||||
return {
|
||||
exitWith0,
|
||||
message:
|
||||
testRunData.length === 1 || globalConfig.verbose
|
||||
? (0, _getNoTestFoundVerbose.default)(
|
||||
testRunData,
|
||||
globalConfig,
|
||||
exitWith0
|
||||
)
|
||||
: (0, _getNoTestFound.default)(testRunData, globalConfig, exitWith0)
|
||||
};
|
||||
}
|
16
backend/apis/nodejs/node_modules/@jest/core/build/getProjectDisplayName.js
generated
vendored
Normal file
16
backend/apis/nodejs/node_modules/@jest/core/build/getProjectDisplayName.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getProjectDisplayName;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getProjectDisplayName(projectConfig) {
|
||||
return projectConfig.displayName?.name || undefined;
|
||||
}
|
49
backend/apis/nodejs/node_modules/@jest/core/build/getProjectNamesMissingWarning.js
generated
vendored
Normal file
49
backend/apis/nodejs/node_modules/@jest/core/build/getProjectNamesMissingWarning.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getProjectNamesMissingWarning;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _getProjectDisplayName = _interopRequireDefault(
|
||||
require('./getProjectDisplayName')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getProjectNamesMissingWarning(projectConfigs, opts) {
|
||||
const numberOfProjectsWithoutAName = projectConfigs.filter(
|
||||
config => !(0, _getProjectDisplayName.default)(config)
|
||||
).length;
|
||||
if (numberOfProjectsWithoutAName === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const args = [];
|
||||
if (opts.selectProjects) {
|
||||
args.push('--selectProjects');
|
||||
}
|
||||
if (opts.ignoreProjects) {
|
||||
args.push('--ignoreProjects');
|
||||
}
|
||||
return _chalk().default.yellow(
|
||||
`You provided values for ${args.join(' and ')} but ${
|
||||
numberOfProjectsWithoutAName === 1
|
||||
? 'a project does not have a name'
|
||||
: `${numberOfProjectsWithoutAName} projects do not have a name`
|
||||
}.\n` +
|
||||
'Set displayName in the config of all projects in order to disable this warning.\n'
|
||||
);
|
||||
}
|
71
backend/apis/nodejs/node_modules/@jest/core/build/getSelectProjectsMessage.js
generated
vendored
Normal file
71
backend/apis/nodejs/node_modules/@jest/core/build/getSelectProjectsMessage.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getSelectProjectsMessage;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _getProjectDisplayName = _interopRequireDefault(
|
||||
require('./getProjectDisplayName')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function getSelectProjectsMessage(projectConfigs, opts) {
|
||||
if (projectConfigs.length === 0) {
|
||||
return getNoSelectionWarning(opts);
|
||||
}
|
||||
return getProjectsRunningMessage(projectConfigs);
|
||||
}
|
||||
function getNoSelectionWarning(opts) {
|
||||
if (opts.ignoreProjects && opts.selectProjects) {
|
||||
return _chalk().default.yellow(
|
||||
'You provided values for --selectProjects and --ignoreProjects, but no projects were found matching the selection.\n' +
|
||||
'Are you ignoring all the selected projects?\n'
|
||||
);
|
||||
} else if (opts.ignoreProjects) {
|
||||
return _chalk().default.yellow(
|
||||
'You provided values for --ignoreProjects, but no projects were found matching the selection.\n' +
|
||||
'Are you ignoring all projects?\n'
|
||||
);
|
||||
} else if (opts.selectProjects) {
|
||||
return _chalk().default.yellow(
|
||||
'You provided values for --selectProjects but no projects were found matching the selection.\n'
|
||||
);
|
||||
} else {
|
||||
return _chalk().default.yellow('No projects were found.\n');
|
||||
}
|
||||
}
|
||||
function getProjectsRunningMessage(projectConfigs) {
|
||||
if (projectConfigs.length === 1) {
|
||||
const name =
|
||||
(0, _getProjectDisplayName.default)(projectConfigs[0]) ??
|
||||
'<unnamed project>';
|
||||
return `Running one project: ${_chalk().default.bold(name)}\n`;
|
||||
}
|
||||
const projectsList = projectConfigs
|
||||
.map(getProjectNameListElement)
|
||||
.sort()
|
||||
.join('\n');
|
||||
return `Running ${projectConfigs.length} projects:\n${projectsList}\n`;
|
||||
}
|
||||
function getProjectNameListElement(projectConfig) {
|
||||
const name = (0, _getProjectDisplayName.default)(projectConfig);
|
||||
const elementContent = name
|
||||
? _chalk().default.bold(name)
|
||||
: '<unnamed project>';
|
||||
return `- ${elementContent}`;
|
||||
}
|
118
backend/apis/nodejs/node_modules/@jest/core/build/index.d.ts
generated
vendored
Normal file
118
backend/apis/nodejs/node_modules/@jest/core/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import {AggregatedResult} from '@jest/test-result';
|
||||
import {BaseReporter} from '@jest/reporters';
|
||||
import type {ChangedFiles} from 'jest-changed-files';
|
||||
import type {Config} from '@jest/types';
|
||||
import {Reporter} from '@jest/reporters';
|
||||
import {ReporterContext} from '@jest/reporters';
|
||||
import {Test} from '@jest/test-result';
|
||||
import type {TestContext} from '@jest/test-result';
|
||||
import type {TestRunnerContext} from 'jest-runner';
|
||||
import type {TestWatcher} from 'jest-watcher';
|
||||
|
||||
export declare function createTestScheduler(
|
||||
globalConfig: Config.GlobalConfig,
|
||||
context: TestSchedulerContext,
|
||||
): Promise<TestScheduler>;
|
||||
|
||||
declare type Filter = (testPaths: Array<string>) => Promise<{
|
||||
filtered: Array<FilterResult>;
|
||||
}>;
|
||||
|
||||
declare type FilterResult = {
|
||||
test: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export declare function getVersion(): string;
|
||||
|
||||
declare type ReporterConstructor = new (
|
||||
globalConfig: Config.GlobalConfig,
|
||||
reporterConfig: Record<string, unknown>,
|
||||
reporterContext: ReporterContext,
|
||||
) => BaseReporter;
|
||||
|
||||
export declare function runCLI(
|
||||
argv: Config.Argv,
|
||||
projects: Array<string>,
|
||||
): Promise<{
|
||||
results: AggregatedResult;
|
||||
globalConfig: Config.GlobalConfig;
|
||||
}>;
|
||||
|
||||
declare type SearchResult = {
|
||||
noSCM?: boolean;
|
||||
stats?: Stats;
|
||||
collectCoverageFrom?: Set<string>;
|
||||
tests: Array<Test>;
|
||||
total?: number;
|
||||
};
|
||||
|
||||
export declare class SearchSource {
|
||||
private readonly _context;
|
||||
private _dependencyResolver;
|
||||
private readonly _testPathCases;
|
||||
constructor(context: TestContext);
|
||||
private _getOrBuildDependencyResolver;
|
||||
private _filterTestPathsWithStats;
|
||||
private _getAllTestPaths;
|
||||
isTestFilePath(path: string): boolean;
|
||||
findMatchingTests(testPathPattern: string): SearchResult;
|
||||
findRelatedTests(
|
||||
allPaths: Set<string>,
|
||||
collectCoverage: boolean,
|
||||
): Promise<SearchResult>;
|
||||
findTestsByPaths(paths: Array<string>): SearchResult;
|
||||
findRelatedTestsFromPattern(
|
||||
paths: Array<string>,
|
||||
collectCoverage: boolean,
|
||||
): Promise<SearchResult>;
|
||||
findTestRelatedToChangedFiles(
|
||||
changedFilesInfo: ChangedFiles,
|
||||
collectCoverage: boolean,
|
||||
): Promise<SearchResult>;
|
||||
private _getTestPaths;
|
||||
filterPathsWin32(paths: Array<string>): Array<string>;
|
||||
getTestPaths(
|
||||
globalConfig: Config.GlobalConfig,
|
||||
changedFiles?: ChangedFiles,
|
||||
filter?: Filter,
|
||||
): Promise<SearchResult>;
|
||||
findRelatedSourcesFromTestsInChangedFiles(
|
||||
changedFilesInfo: ChangedFiles,
|
||||
): Promise<Array<string>>;
|
||||
}
|
||||
|
||||
declare type Stats = {
|
||||
roots: number;
|
||||
testMatch: number;
|
||||
testPathIgnorePatterns: number;
|
||||
testRegex: number;
|
||||
testPathPattern?: number;
|
||||
};
|
||||
|
||||
declare class TestScheduler {
|
||||
private readonly _context;
|
||||
private readonly _dispatcher;
|
||||
private readonly _globalConfig;
|
||||
constructor(globalConfig: Config.GlobalConfig, context: TestSchedulerContext);
|
||||
addReporter(reporter: Reporter): void;
|
||||
removeReporter(reporterConstructor: ReporterConstructor): void;
|
||||
scheduleTests(
|
||||
tests: Array<Test>,
|
||||
watcher: TestWatcher,
|
||||
): Promise<AggregatedResult>;
|
||||
private _partitionTests;
|
||||
_setupReporters(): Promise<void>;
|
||||
private _addCustomReporter;
|
||||
private _bailIfNeeded;
|
||||
}
|
||||
|
||||
declare type TestSchedulerContext = ReporterContext & TestRunnerContext;
|
||||
|
||||
export {};
|
36
backend/apis/nodejs/node_modules/@jest/core/build/index.js
generated
vendored
Normal file
36
backend/apis/nodejs/node_modules/@jest/core/build/index.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'SearchSource', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _SearchSource.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createTestScheduler', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _TestScheduler.createTestScheduler;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getVersion', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _version.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'runCLI', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _cli.runCLI;
|
||||
}
|
||||
});
|
||||
var _SearchSource = _interopRequireDefault(require('./SearchSource'));
|
||||
var _TestScheduler = require('./TestScheduler');
|
||||
var _cli = require('./cli');
|
||||
var _version = _interopRequireDefault(require('./version'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
52
backend/apis/nodejs/node_modules/@jest/core/build/lib/activeFiltersMessage.js
generated
vendored
Normal file
52
backend/apis/nodejs/node_modules/@jest/core/build/lib/activeFiltersMessage.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const activeFilters = globalConfig => {
|
||||
const {testNamePattern, testPathPattern} = globalConfig;
|
||||
if (testNamePattern || testPathPattern) {
|
||||
const filters = [
|
||||
testPathPattern
|
||||
? _chalk().default.dim('filename ') +
|
||||
_chalk().default.yellow(`/${testPathPattern}/`)
|
||||
: null,
|
||||
testNamePattern
|
||||
? _chalk().default.dim('test name ') +
|
||||
_chalk().default.yellow(`/${testNamePattern}/`)
|
||||
: null
|
||||
]
|
||||
.filter(_jestUtil().isNonNullable)
|
||||
.join(', ');
|
||||
const messages = `\n${_chalk().default.bold('Active Filters: ')}${filters}`;
|
||||
return messages;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
var _default = activeFilters;
|
||||
exports.default = _default;
|
31
backend/apis/nodejs/node_modules/@jest/core/build/lib/createContext.js
generated
vendored
Normal file
31
backend/apis/nodejs/node_modules/@jest/core/build/lib/createContext.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = createContext;
|
||||
function _jestRuntime() {
|
||||
const data = _interopRequireDefault(require('jest-runtime'));
|
||||
_jestRuntime = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function createContext(config, {hasteFS, moduleMap}) {
|
||||
return {
|
||||
config,
|
||||
hasteFS,
|
||||
moduleMap,
|
||||
resolver: _jestRuntime().default.createResolver(config, moduleMap)
|
||||
};
|
||||
}
|
65
backend/apis/nodejs/node_modules/@jest/core/build/lib/handleDeprecationWarnings.js
generated
vendored
Normal file
65
backend/apis/nodejs/node_modules/@jest/core/build/lib/handleDeprecationWarnings.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = handleDeprecationWarnings;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function handleDeprecationWarnings(pipe, stdin = process.stdin) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof stdin.setRawMode === 'function') {
|
||||
const messages = [
|
||||
_chalk().default.red('There are deprecation warnings.\n'),
|
||||
`${_chalk().default.dim(' \u203A Press ')}Enter${_chalk().default.dim(
|
||||
' to continue.'
|
||||
)}`,
|
||||
`${_chalk().default.dim(' \u203A Press ')}Esc${_chalk().default.dim(
|
||||
' to exit.'
|
||||
)}`
|
||||
];
|
||||
pipe.write(messages.join('\n'));
|
||||
stdin.setRawMode(true);
|
||||
stdin.resume();
|
||||
stdin.setEncoding('utf8');
|
||||
// this is a string since we set encoding above
|
||||
stdin.on('data', key => {
|
||||
if (key === _jestWatcher().KEYS.ENTER) {
|
||||
resolve();
|
||||
} else if (
|
||||
[
|
||||
_jestWatcher().KEYS.ESCAPE,
|
||||
_jestWatcher().KEYS.CONTROL_C,
|
||||
_jestWatcher().KEYS.CONTROL_D
|
||||
].indexOf(key) !== -1
|
||||
) {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
26
backend/apis/nodejs/node_modules/@jest/core/build/lib/isValidPath.js
generated
vendored
Normal file
26
backend/apis/nodejs/node_modules/@jest/core/build/lib/isValidPath.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = isValidPath;
|
||||
function _jestSnapshot() {
|
||||
const data = require('jest-snapshot');
|
||||
_jestSnapshot = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function isValidPath(globalConfig, filePath) {
|
||||
return (
|
||||
!filePath.includes(globalConfig.coverageDirectory) &&
|
||||
!(0, _jestSnapshot().isSnapshotPath)(filePath)
|
||||
);
|
||||
}
|
24
backend/apis/nodejs/node_modules/@jest/core/build/lib/logDebugMessages.js
generated
vendored
Normal file
24
backend/apis/nodejs/node_modules/@jest/core/build/lib/logDebugMessages.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = logDebugMessages;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const VERSION = require('../../package.json').version;
|
||||
|
||||
// if the output here changes, update `getConfig` in e2e/runJest.ts
|
||||
function logDebugMessages(globalConfig, configs, outputStream) {
|
||||
const output = {
|
||||
configs,
|
||||
globalConfig,
|
||||
version: VERSION
|
||||
};
|
||||
outputStream.write(`${JSON.stringify(output, null, ' ')}\n`);
|
||||
}
|
95
backend/apis/nodejs/node_modules/@jest/core/build/lib/updateGlobalConfig.js
generated
vendored
Normal file
95
backend/apis/nodejs/node_modules/@jest/core/build/lib/updateGlobalConfig.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = updateGlobalConfig;
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
_jestRegexUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function updateGlobalConfig(globalConfig, options = {}) {
|
||||
const newConfig = {
|
||||
...globalConfig
|
||||
};
|
||||
if (options.mode === 'watch') {
|
||||
newConfig.watch = true;
|
||||
newConfig.watchAll = false;
|
||||
} else if (options.mode === 'watchAll') {
|
||||
newConfig.watch = false;
|
||||
newConfig.watchAll = true;
|
||||
}
|
||||
if (options.testNamePattern !== undefined) {
|
||||
newConfig.testNamePattern = options.testNamePattern || '';
|
||||
}
|
||||
if (options.testPathPattern !== undefined) {
|
||||
newConfig.testPathPattern =
|
||||
(0, _jestRegexUtil().replacePathSepForRegex)(options.testPathPattern) ||
|
||||
'';
|
||||
}
|
||||
newConfig.onlyChanged =
|
||||
!newConfig.watchAll &&
|
||||
!newConfig.testNamePattern &&
|
||||
!newConfig.testPathPattern;
|
||||
if (typeof options.bail === 'boolean') {
|
||||
newConfig.bail = options.bail ? 1 : 0;
|
||||
} else if (options.bail !== undefined) {
|
||||
newConfig.bail = options.bail;
|
||||
}
|
||||
if (options.changedSince !== undefined) {
|
||||
newConfig.changedSince = options.changedSince;
|
||||
}
|
||||
if (options.collectCoverage !== undefined) {
|
||||
newConfig.collectCoverage = options.collectCoverage || false;
|
||||
}
|
||||
if (options.collectCoverageFrom !== undefined) {
|
||||
newConfig.collectCoverageFrom = options.collectCoverageFrom;
|
||||
}
|
||||
if (options.coverageDirectory !== undefined) {
|
||||
newConfig.coverageDirectory = options.coverageDirectory;
|
||||
}
|
||||
if (options.coverageReporters !== undefined) {
|
||||
newConfig.coverageReporters = options.coverageReporters;
|
||||
}
|
||||
if (options.findRelatedTests !== undefined) {
|
||||
newConfig.findRelatedTests = options.findRelatedTests;
|
||||
}
|
||||
if (options.nonFlagArgs !== undefined) {
|
||||
newConfig.nonFlagArgs = options.nonFlagArgs;
|
||||
}
|
||||
if (options.noSCM) {
|
||||
newConfig.noSCM = true;
|
||||
}
|
||||
if (options.notify !== undefined) {
|
||||
newConfig.notify = options.notify || false;
|
||||
}
|
||||
if (options.notifyMode !== undefined) {
|
||||
newConfig.notifyMode = options.notifyMode;
|
||||
}
|
||||
if (options.onlyFailures !== undefined) {
|
||||
newConfig.onlyFailures = options.onlyFailures || false;
|
||||
}
|
||||
if (options.passWithNoTests !== undefined) {
|
||||
newConfig.passWithNoTests = true;
|
||||
}
|
||||
if (options.reporters !== undefined) {
|
||||
newConfig.reporters = options.reporters;
|
||||
}
|
||||
if (options.updateSnapshot !== undefined) {
|
||||
newConfig.updateSnapshot = options.updateSnapshot;
|
||||
}
|
||||
if (options.verbose !== undefined) {
|
||||
newConfig.verbose = options.verbose || false;
|
||||
}
|
||||
return Object.freeze(newConfig);
|
||||
}
|
56
backend/apis/nodejs/node_modules/@jest/core/build/lib/watchPluginsHelpers.js
generated
vendored
Normal file
56
backend/apis/nodejs/node_modules/@jest/core/build/lib/watchPluginsHelpers.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.getSortedUsageRows = exports.filterInteractivePlugins = void 0;
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const filterInteractivePlugins = (watchPlugins, globalConfig) => {
|
||||
const usageInfos = watchPlugins.map(
|
||||
p => p.getUsageInfo && p.getUsageInfo(globalConfig)
|
||||
);
|
||||
return watchPlugins.filter((_plugin, i) => {
|
||||
const usageInfo = usageInfos[i];
|
||||
if (usageInfo) {
|
||||
const {key} = usageInfo;
|
||||
return !usageInfos.slice(i + 1).some(u => !!u && key === u.key);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
exports.filterInteractivePlugins = filterInteractivePlugins;
|
||||
const getSortedUsageRows = (watchPlugins, globalConfig) =>
|
||||
filterInteractivePlugins(watchPlugins, globalConfig)
|
||||
.sort((a, b) => {
|
||||
if (a.isInternal && b.isInternal) {
|
||||
// internal plugins in the order we specify them
|
||||
return 0;
|
||||
}
|
||||
if (a.isInternal !== b.isInternal) {
|
||||
// external plugins afterwards
|
||||
return a.isInternal ? -1 : 1;
|
||||
}
|
||||
const usageInfoA = a.getUsageInfo && a.getUsageInfo(globalConfig);
|
||||
const usageInfoB = b.getUsageInfo && b.getUsageInfo(globalConfig);
|
||||
if (usageInfoA && usageInfoB) {
|
||||
// external plugins in alphabetical order
|
||||
return usageInfoA.key.localeCompare(usageInfoB.key);
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
.map(p => p.getUsageInfo && p.getUsageInfo(globalConfig))
|
||||
.filter(_jestUtil().isNonNullable);
|
||||
exports.getSortedUsageRows = getSortedUsageRows;
|
96
backend/apis/nodejs/node_modules/@jest/core/build/plugins/FailedTestsInteractive.js
generated
vendored
Normal file
96
backend/apis/nodejs/node_modules/@jest/core/build/plugins/FailedTestsInteractive.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _FailedTestsInteractiveMode = _interopRequireDefault(
|
||||
require('../FailedTestsInteractiveMode')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class FailedTestsInteractivePlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
_failedTestAssertions;
|
||||
_manager = new _FailedTestsInteractiveMode.default(this._stdout);
|
||||
apply(hooks) {
|
||||
hooks.onTestRunComplete(results => {
|
||||
this._failedTestAssertions = this.getFailedTestAssertions(results);
|
||||
if (this._manager.isActive()) this._manager.updateWithResults(results);
|
||||
});
|
||||
}
|
||||
getUsageInfo() {
|
||||
if (this._failedTestAssertions?.length) {
|
||||
return {
|
||||
key: 'i',
|
||||
prompt: 'run failing tests interactively'
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
onKey(key) {
|
||||
if (this._manager.isActive()) {
|
||||
this._manager.put(key);
|
||||
}
|
||||
}
|
||||
run(_, updateConfigAndRun) {
|
||||
return new Promise(resolve => {
|
||||
if (
|
||||
!this._failedTestAssertions ||
|
||||
this._failedTestAssertions.length === 0
|
||||
) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
this._manager.run(this._failedTestAssertions, failure => {
|
||||
updateConfigAndRun({
|
||||
mode: 'watch',
|
||||
testNamePattern: failure ? `^${failure.fullName}$` : '',
|
||||
testPathPattern: failure?.path || ''
|
||||
});
|
||||
if (!this._manager.isActive()) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
getFailedTestAssertions(results) {
|
||||
const failedTestPaths = [];
|
||||
if (
|
||||
// skip if no failed tests
|
||||
results.numFailedTests === 0 ||
|
||||
// skip if missing test results
|
||||
!results.testResults ||
|
||||
// skip if unmatched snapshots are present
|
||||
results.snapshot.unmatched
|
||||
) {
|
||||
return failedTestPaths;
|
||||
}
|
||||
results.testResults.forEach(testResult => {
|
||||
testResult.testResults.forEach(result => {
|
||||
if (result.status === 'failed') {
|
||||
failedTestPaths.push({
|
||||
fullName: result.fullName,
|
||||
path: testResult.testFilePath
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
return failedTestPaths;
|
||||
}
|
||||
}
|
||||
exports.default = FailedTestsInteractivePlugin;
|
42
backend/apis/nodejs/node_modules/@jest/core/build/plugins/Quit.js
generated
vendored
Normal file
42
backend/apis/nodejs/node_modules/@jest/core/build/plugins/Quit.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class QuitPlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
isInternal;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.isInternal = true;
|
||||
}
|
||||
async run() {
|
||||
if (typeof this._stdin.setRawMode === 'function') {
|
||||
this._stdin.setRawMode(false);
|
||||
}
|
||||
this._stdout.write('\n');
|
||||
process.exit(0);
|
||||
}
|
||||
getUsageInfo() {
|
||||
return {
|
||||
key: 'q',
|
||||
prompt: 'quit watch mode'
|
||||
};
|
||||
}
|
||||
}
|
||||
var _default = QuitPlugin;
|
||||
exports.default = _default;
|
70
backend/apis/nodejs/node_modules/@jest/core/build/plugins/TestNamePattern.js
generated
vendored
Normal file
70
backend/apis/nodejs/node_modules/@jest/core/build/plugins/TestNamePattern.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _TestNamePatternPrompt = _interopRequireDefault(
|
||||
require('../TestNamePatternPrompt')
|
||||
);
|
||||
var _activeFiltersMessage = _interopRequireDefault(
|
||||
require('../lib/activeFiltersMessage')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class TestNamePatternPlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
_prompt;
|
||||
isInternal;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._prompt = new (_jestWatcher().Prompt)();
|
||||
this.isInternal = true;
|
||||
}
|
||||
getUsageInfo() {
|
||||
return {
|
||||
key: 't',
|
||||
prompt: 'filter by a test name regex pattern'
|
||||
};
|
||||
}
|
||||
onKey(key) {
|
||||
this._prompt.put(key);
|
||||
}
|
||||
run(globalConfig, updateConfigAndRun) {
|
||||
return new Promise((res, rej) => {
|
||||
const testNamePatternPrompt = new _TestNamePatternPrompt.default(
|
||||
this._stdout,
|
||||
this._prompt
|
||||
);
|
||||
testNamePatternPrompt.run(
|
||||
value => {
|
||||
updateConfigAndRun({
|
||||
mode: 'watch',
|
||||
testNamePattern: value
|
||||
});
|
||||
res();
|
||||
},
|
||||
rej,
|
||||
{
|
||||
header: (0, _activeFiltersMessage.default)(globalConfig)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
var _default = TestNamePatternPlugin;
|
||||
exports.default = _default;
|
70
backend/apis/nodejs/node_modules/@jest/core/build/plugins/TestPathPattern.js
generated
vendored
Normal file
70
backend/apis/nodejs/node_modules/@jest/core/build/plugins/TestPathPattern.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _TestPathPatternPrompt = _interopRequireDefault(
|
||||
require('../TestPathPatternPrompt')
|
||||
);
|
||||
var _activeFiltersMessage = _interopRequireDefault(
|
||||
require('../lib/activeFiltersMessage')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class TestPathPatternPlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
_prompt;
|
||||
isInternal;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._prompt = new (_jestWatcher().Prompt)();
|
||||
this.isInternal = true;
|
||||
}
|
||||
getUsageInfo() {
|
||||
return {
|
||||
key: 'p',
|
||||
prompt: 'filter by a filename regex pattern'
|
||||
};
|
||||
}
|
||||
onKey(key) {
|
||||
this._prompt.put(key);
|
||||
}
|
||||
run(globalConfig, updateConfigAndRun) {
|
||||
return new Promise((res, rej) => {
|
||||
const testPathPatternPrompt = new _TestPathPatternPrompt.default(
|
||||
this._stdout,
|
||||
this._prompt
|
||||
);
|
||||
testPathPatternPrompt.run(
|
||||
value => {
|
||||
updateConfigAndRun({
|
||||
mode: 'watch',
|
||||
testPathPattern: value
|
||||
});
|
||||
res();
|
||||
},
|
||||
rej,
|
||||
{
|
||||
header: (0, _activeFiltersMessage.default)(globalConfig)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
var _default = TestPathPatternPlugin;
|
||||
exports.default = _default;
|
51
backend/apis/nodejs/node_modules/@jest/core/build/plugins/UpdateSnapshots.js
generated
vendored
Normal file
51
backend/apis/nodejs/node_modules/@jest/core/build/plugins/UpdateSnapshots.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class UpdateSnapshotsPlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
_hasSnapshotFailure;
|
||||
isInternal;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.isInternal = true;
|
||||
this._hasSnapshotFailure = false;
|
||||
}
|
||||
run(_globalConfig, updateConfigAndRun) {
|
||||
updateConfigAndRun({
|
||||
updateSnapshot: 'all'
|
||||
});
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
apply(hooks) {
|
||||
hooks.onTestRunComplete(results => {
|
||||
this._hasSnapshotFailure = results.snapshot.failure;
|
||||
});
|
||||
}
|
||||
getUsageInfo() {
|
||||
if (this._hasSnapshotFailure) {
|
||||
return {
|
||||
key: 'u',
|
||||
prompt: 'update failing snapshots'
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var _default = UpdateSnapshotsPlugin;
|
||||
exports.default = _default;
|
99
backend/apis/nodejs/node_modules/@jest/core/build/plugins/UpdateSnapshotsInteractive.js
generated
vendored
Normal file
99
backend/apis/nodejs/node_modules/@jest/core/build/plugins/UpdateSnapshotsInteractive.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _SnapshotInteractiveMode = _interopRequireDefault(
|
||||
require('../SnapshotInteractiveMode')
|
||||
);
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 */
|
||||
|
||||
class UpdateSnapshotInteractivePlugin extends _jestWatcher().BaseWatchPlugin {
|
||||
_snapshotInteractiveMode = new _SnapshotInteractiveMode.default(this._stdout);
|
||||
_failedSnapshotTestAssertions = [];
|
||||
isInternal = true;
|
||||
getFailedSnapshotTestAssertions(testResults) {
|
||||
const failedTestPaths = [];
|
||||
if (testResults.numFailedTests === 0 || !testResults.testResults) {
|
||||
return failedTestPaths;
|
||||
}
|
||||
testResults.testResults.forEach(testResult => {
|
||||
if (testResult.snapshot && testResult.snapshot.unmatched) {
|
||||
testResult.testResults.forEach(result => {
|
||||
if (result.status === 'failed') {
|
||||
failedTestPaths.push({
|
||||
fullName: result.fullName,
|
||||
path: testResult.testFilePath
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return failedTestPaths;
|
||||
}
|
||||
apply(hooks) {
|
||||
hooks.onTestRunComplete(results => {
|
||||
this._failedSnapshotTestAssertions =
|
||||
this.getFailedSnapshotTestAssertions(results);
|
||||
if (this._snapshotInteractiveMode.isActive()) {
|
||||
this._snapshotInteractiveMode.updateWithResults(results);
|
||||
}
|
||||
});
|
||||
}
|
||||
onKey(key) {
|
||||
if (this._snapshotInteractiveMode.isActive()) {
|
||||
this._snapshotInteractiveMode.put(key);
|
||||
}
|
||||
}
|
||||
run(_globalConfig, updateConfigAndRun) {
|
||||
if (this._failedSnapshotTestAssertions.length) {
|
||||
return new Promise(res => {
|
||||
this._snapshotInteractiveMode.run(
|
||||
this._failedSnapshotTestAssertions,
|
||||
(assertion, shouldUpdateSnapshot) => {
|
||||
updateConfigAndRun({
|
||||
mode: 'watch',
|
||||
testNamePattern: assertion ? `^${assertion.fullName}$` : '',
|
||||
testPathPattern: assertion ? assertion.path : '',
|
||||
updateSnapshot: shouldUpdateSnapshot ? 'all' : 'none'
|
||||
});
|
||||
if (!this._snapshotInteractiveMode.isActive()) {
|
||||
res();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
getUsageInfo() {
|
||||
if (this._failedSnapshotTestAssertions?.length > 0) {
|
||||
return {
|
||||
key: 'i',
|
||||
prompt: 'update failing snapshots interactively'
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var _default = UpdateSnapshotInteractivePlugin;
|
||||
exports.default = _default;
|
133
backend/apis/nodejs/node_modules/@jest/core/build/runGlobalHook.js
generated
vendored
Normal file
133
backend/apis/nodejs/node_modules/@jest/core/build/runGlobalHook.js
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = runGlobalHook;
|
||||
function util() {
|
||||
const data = _interopRequireWildcard(require('util'));
|
||||
util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _transform() {
|
||||
const data = require('@jest/transform');
|
||||
_transform = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _prettyFormat() {
|
||||
const data = _interopRequireDefault(require('pretty-format'));
|
||||
_prettyFormat = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
async function runGlobalHook({allTests, globalConfig, moduleName}) {
|
||||
const globalModulePaths = new Set(
|
||||
allTests.map(test => test.context.config[moduleName])
|
||||
);
|
||||
if (globalConfig[moduleName]) {
|
||||
globalModulePaths.add(globalConfig[moduleName]);
|
||||
}
|
||||
if (globalModulePaths.size > 0) {
|
||||
for (const modulePath of globalModulePaths) {
|
||||
if (!modulePath) {
|
||||
continue;
|
||||
}
|
||||
const correctConfig = allTests.find(
|
||||
t => t.context.config[moduleName] === modulePath
|
||||
);
|
||||
const projectConfig = correctConfig
|
||||
? correctConfig.context.config
|
||||
: // Fallback to first config
|
||||
allTests[0].context.config;
|
||||
const transformer = await (0, _transform().createScriptTransformer)(
|
||||
projectConfig
|
||||
);
|
||||
try {
|
||||
await transformer.requireAndTranspileModule(
|
||||
modulePath,
|
||||
async globalModule => {
|
||||
if (typeof globalModule !== 'function') {
|
||||
throw new TypeError(
|
||||
`${moduleName} file must export a function at ${modulePath}`
|
||||
);
|
||||
}
|
||||
await globalModule(globalConfig, projectConfig);
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
if (
|
||||
util().types.isNativeError(error) &&
|
||||
(Object.getOwnPropertyDescriptor(error, 'message')?.writable ||
|
||||
Object.getOwnPropertyDescriptor(
|
||||
Object.getPrototypeOf(error),
|
||||
'message'
|
||||
)?.writable)
|
||||
) {
|
||||
error.message = `Jest: Got error running ${moduleName} - ${modulePath}, reason: ${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
throw new Error(
|
||||
`Jest: Got error running ${moduleName} - ${modulePath}, reason: ${(0,
|
||||
_prettyFormat().default)(error, {
|
||||
maxDepth: 3
|
||||
})}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
391
backend/apis/nodejs/node_modules/@jest/core/build/runJest.js
generated
vendored
Normal file
391
backend/apis/nodejs/node_modules/@jest/core/build/runJest.js
generated
vendored
Normal file
@ -0,0 +1,391 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = runJest;
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _perf_hooks() {
|
||||
const data = require('perf_hooks');
|
||||
_perf_hooks = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _console() {
|
||||
const data = require('@jest/console');
|
||||
_console = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _testResult() {
|
||||
const data = require('@jest/test-result');
|
||||
_testResult = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestResolve() {
|
||||
const data = _interopRequireDefault(require('jest-resolve'));
|
||||
_jestResolve = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _SearchSource = _interopRequireDefault(require('./SearchSource'));
|
||||
var _TestScheduler = require('./TestScheduler');
|
||||
var _collectHandles = _interopRequireDefault(require('./collectHandles'));
|
||||
var _getNoTestsFoundMessage = _interopRequireDefault(
|
||||
require('./getNoTestsFoundMessage')
|
||||
);
|
||||
var _runGlobalHook = _interopRequireDefault(require('./runGlobalHook'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const getTestPaths = async (
|
||||
globalConfig,
|
||||
source,
|
||||
outputStream,
|
||||
changedFiles,
|
||||
jestHooks,
|
||||
filter
|
||||
) => {
|
||||
const data = await source.getTestPaths(globalConfig, changedFiles, filter);
|
||||
if (!data.tests.length && globalConfig.onlyChanged && data.noSCM) {
|
||||
new (_console().CustomConsole)(outputStream, outputStream).log(
|
||||
'Jest can only find uncommitted changed files in a git or hg ' +
|
||||
'repository. If you make your project a git or hg ' +
|
||||
'repository (`git init` or `hg init`), Jest will be able ' +
|
||||
'to only run tests related to files changed since the last ' +
|
||||
'commit.'
|
||||
);
|
||||
}
|
||||
const shouldTestArray = await Promise.all(
|
||||
data.tests.map(test =>
|
||||
jestHooks.shouldRunTestSuite({
|
||||
config: test.context.config,
|
||||
duration: test.duration,
|
||||
testPath: test.path
|
||||
})
|
||||
)
|
||||
);
|
||||
const filteredTests = data.tests.filter((_test, i) => shouldTestArray[i]);
|
||||
return {
|
||||
...data,
|
||||
allTests: filteredTests.length,
|
||||
tests: filteredTests
|
||||
};
|
||||
};
|
||||
const processResults = async (runResults, options) => {
|
||||
const {
|
||||
outputFile,
|
||||
json: isJSON,
|
||||
onComplete,
|
||||
outputStream,
|
||||
testResultsProcessor,
|
||||
collectHandles
|
||||
} = options;
|
||||
if (collectHandles) {
|
||||
runResults.openHandles = await collectHandles();
|
||||
} else {
|
||||
runResults.openHandles = [];
|
||||
}
|
||||
if (testResultsProcessor) {
|
||||
const processor = await (0, _jestUtil().requireOrImportModule)(
|
||||
testResultsProcessor
|
||||
);
|
||||
runResults = await processor(runResults);
|
||||
}
|
||||
if (isJSON) {
|
||||
if (outputFile) {
|
||||
const cwd = (0, _jestUtil().tryRealpath)(process.cwd());
|
||||
const filePath = path().resolve(cwd, outputFile);
|
||||
fs().writeFileSync(
|
||||
filePath,
|
||||
`${JSON.stringify((0, _testResult().formatTestResults)(runResults))}\n`
|
||||
);
|
||||
outputStream.write(
|
||||
`Test results written to: ${path().relative(cwd, filePath)}\n`
|
||||
);
|
||||
} else {
|
||||
process.stdout.write(
|
||||
`${JSON.stringify((0, _testResult().formatTestResults)(runResults))}\n`
|
||||
);
|
||||
}
|
||||
}
|
||||
onComplete?.(runResults);
|
||||
};
|
||||
const testSchedulerContext = {
|
||||
firstRun: true,
|
||||
previousSuccess: true
|
||||
};
|
||||
async function runJest({
|
||||
contexts,
|
||||
globalConfig,
|
||||
outputStream,
|
||||
testWatcher,
|
||||
jestHooks = new (_jestWatcher().JestHook)().getEmitter(),
|
||||
startRun,
|
||||
changedFilesPromise,
|
||||
onComplete,
|
||||
failedTestsCache,
|
||||
filter
|
||||
}) {
|
||||
// Clear cache for required modules - there might be different resolutions
|
||||
// from Jest's config loading to running the tests
|
||||
_jestResolve().default.clearDefaultResolverCache();
|
||||
const Sequencer = await (0, _jestUtil().requireOrImportModule)(
|
||||
globalConfig.testSequencer
|
||||
);
|
||||
const sequencer = new Sequencer();
|
||||
let allTests = [];
|
||||
if (changedFilesPromise && globalConfig.watch) {
|
||||
const {repos} = await changedFilesPromise;
|
||||
const noSCM = Object.keys(repos).every(scm => repos[scm].size === 0);
|
||||
if (noSCM) {
|
||||
process.stderr.write(
|
||||
`\n${_chalk().default.bold(
|
||||
'--watch'
|
||||
)} is not supported without git/hg, please use --watchAll\n`
|
||||
);
|
||||
(0, _exit().default)(1);
|
||||
}
|
||||
}
|
||||
const searchSources = contexts.map(
|
||||
context => new _SearchSource.default(context)
|
||||
);
|
||||
_perf_hooks().performance.mark('jest/getTestPaths:start');
|
||||
const testRunData = await Promise.all(
|
||||
contexts.map(async (context, index) => {
|
||||
const searchSource = searchSources[index];
|
||||
const matches = await getTestPaths(
|
||||
globalConfig,
|
||||
searchSource,
|
||||
outputStream,
|
||||
changedFilesPromise && (await changedFilesPromise),
|
||||
jestHooks,
|
||||
filter
|
||||
);
|
||||
allTests = allTests.concat(matches.tests);
|
||||
return {
|
||||
context,
|
||||
matches
|
||||
};
|
||||
})
|
||||
);
|
||||
_perf_hooks().performance.mark('jest/getTestPaths:end');
|
||||
if (globalConfig.shard) {
|
||||
if (typeof sequencer.shard !== 'function') {
|
||||
throw new Error(
|
||||
`Shard ${globalConfig.shard.shardIndex}/${globalConfig.shard.shardCount} requested, but test sequencer ${Sequencer.name} in ${globalConfig.testSequencer} has no shard method.`
|
||||
);
|
||||
}
|
||||
allTests = await sequencer.shard(allTests, globalConfig.shard);
|
||||
}
|
||||
allTests = await sequencer.sort(allTests);
|
||||
if (globalConfig.listTests) {
|
||||
const testsPaths = Array.from(new Set(allTests.map(test => test.path)));
|
||||
/* eslint-disable no-console */
|
||||
if (globalConfig.json) {
|
||||
console.log(JSON.stringify(testsPaths));
|
||||
} else {
|
||||
console.log(testsPaths.join('\n'));
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
onComplete &&
|
||||
onComplete((0, _testResult().makeEmptyAggregatedTestResult)());
|
||||
return;
|
||||
}
|
||||
if (globalConfig.onlyFailures) {
|
||||
if (failedTestsCache) {
|
||||
allTests = failedTestsCache.filterTests(allTests);
|
||||
} else {
|
||||
allTests = await sequencer.allFailedTests(allTests);
|
||||
}
|
||||
}
|
||||
const hasTests = allTests.length > 0;
|
||||
if (!hasTests) {
|
||||
const {exitWith0, message: noTestsFoundMessage} = (0,
|
||||
_getNoTestsFoundMessage.default)(testRunData, globalConfig);
|
||||
if (exitWith0) {
|
||||
new (_console().CustomConsole)(outputStream, outputStream).log(
|
||||
noTestsFoundMessage
|
||||
);
|
||||
} else {
|
||||
new (_console().CustomConsole)(outputStream, outputStream).error(
|
||||
noTestsFoundMessage
|
||||
);
|
||||
(0, _exit().default)(1);
|
||||
}
|
||||
} else if (
|
||||
allTests.length === 1 &&
|
||||
globalConfig.silent !== true &&
|
||||
globalConfig.verbose !== false
|
||||
) {
|
||||
const newConfig = {
|
||||
...globalConfig,
|
||||
verbose: true
|
||||
};
|
||||
globalConfig = Object.freeze(newConfig);
|
||||
}
|
||||
let collectHandles;
|
||||
if (globalConfig.detectOpenHandles) {
|
||||
collectHandles = (0, _collectHandles.default)();
|
||||
}
|
||||
if (hasTests) {
|
||||
_perf_hooks().performance.mark('jest/globalSetup:start');
|
||||
await (0, _runGlobalHook.default)({
|
||||
allTests,
|
||||
globalConfig,
|
||||
moduleName: 'globalSetup'
|
||||
});
|
||||
_perf_hooks().performance.mark('jest/globalSetup:end');
|
||||
}
|
||||
if (changedFilesPromise) {
|
||||
const changedFilesInfo = await changedFilesPromise;
|
||||
if (changedFilesInfo.changedFiles) {
|
||||
testSchedulerContext.changedFiles = changedFilesInfo.changedFiles;
|
||||
const sourcesRelatedToTestsInChangedFilesArray = (
|
||||
await Promise.all(
|
||||
contexts.map(async (_, index) => {
|
||||
const searchSource = searchSources[index];
|
||||
return searchSource.findRelatedSourcesFromTestsInChangedFiles(
|
||||
changedFilesInfo
|
||||
);
|
||||
})
|
||||
)
|
||||
).reduce((total, paths) => total.concat(paths), []);
|
||||
testSchedulerContext.sourcesRelatedToTestsInChangedFiles = new Set(
|
||||
sourcesRelatedToTestsInChangedFilesArray
|
||||
);
|
||||
}
|
||||
}
|
||||
const scheduler = await (0, _TestScheduler.createTestScheduler)(
|
||||
globalConfig,
|
||||
{
|
||||
startRun,
|
||||
...testSchedulerContext
|
||||
}
|
||||
);
|
||||
|
||||
// @ts-expect-error - second arg is unsupported (but harmless) in Node 14
|
||||
_perf_hooks().performance.mark('jest/scheduleAndRun:start', {
|
||||
detail: {
|
||||
numTests: allTests.length
|
||||
}
|
||||
});
|
||||
const results = await scheduler.scheduleTests(allTests, testWatcher);
|
||||
_perf_hooks().performance.mark('jest/scheduleAndRun:end');
|
||||
_perf_hooks().performance.mark('jest/cacheResults:start');
|
||||
sequencer.cacheResults(allTests, results);
|
||||
_perf_hooks().performance.mark('jest/cacheResults:end');
|
||||
if (hasTests) {
|
||||
_perf_hooks().performance.mark('jest/globalTeardown:start');
|
||||
await (0, _runGlobalHook.default)({
|
||||
allTests,
|
||||
globalConfig,
|
||||
moduleName: 'globalTeardown'
|
||||
});
|
||||
_perf_hooks().performance.mark('jest/globalTeardown:end');
|
||||
}
|
||||
_perf_hooks().performance.mark('jest/processResults:start');
|
||||
await processResults(results, {
|
||||
collectHandles,
|
||||
json: globalConfig.json,
|
||||
onComplete,
|
||||
outputFile: globalConfig.outputFile,
|
||||
outputStream,
|
||||
testResultsProcessor: globalConfig.testResultsProcessor
|
||||
});
|
||||
_perf_hooks().performance.mark('jest/processResults:end');
|
||||
}
|
57
backend/apis/nodejs/node_modules/@jest/core/build/testSchedulerHelper.js
generated
vendored
Normal file
57
backend/apis/nodejs/node_modules/@jest/core/build/testSchedulerHelper.js
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.shouldRunInBand = shouldRunInBand;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const SLOW_TEST_TIME = 1000;
|
||||
function shouldRunInBand(
|
||||
tests,
|
||||
timings,
|
||||
{
|
||||
detectOpenHandles,
|
||||
maxWorkers,
|
||||
runInBand,
|
||||
watch,
|
||||
watchAll,
|
||||
workerIdleMemoryLimit
|
||||
}
|
||||
) {
|
||||
// If user asked for run in band, respect that.
|
||||
// detectOpenHandles makes no sense without runInBand, because it cannot detect leaks in workers
|
||||
if (runInBand || detectOpenHandles) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are using watch/watchAll mode, don't schedule anything in the main
|
||||
* thread to keep the TTY responsive and to prevent watch mode crashes caused
|
||||
* by leaks (improper test teardown).
|
||||
*/
|
||||
if (watch || watchAll) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, run in band if we only have one test or one worker available.
|
||||
* Also, if we are confident from previous runs that the tests will finish
|
||||
* quickly we also run in band to reduce the overhead of spawning workers.
|
||||
*/
|
||||
const areFastTests = timings.every(timing => timing < SLOW_TEST_TIME);
|
||||
const oneWorkerOrLess = maxWorkers <= 1;
|
||||
const oneTestOrLess = tests.length <= 1;
|
||||
return (
|
||||
// When specifying a memory limit, workers should be used
|
||||
!workerIdleMemoryLimit &&
|
||||
(oneWorkerOrLess ||
|
||||
oneTestOrLess ||
|
||||
(tests.length <= 20 && timings.length > 0 && areFastTests))
|
||||
);
|
||||
}
|
1
backend/apis/nodejs/node_modules/@jest/core/build/types.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/@jest/core/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
18
backend/apis/nodejs/node_modules/@jest/core/build/version.js
generated
vendored
Normal file
18
backend/apis/nodejs/node_modules/@jest/core/build/version.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getVersion;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// Cannot be `import` as it's not under TS root dir
|
||||
const {version: VERSION} = require('../package.json');
|
||||
function getVersion() {
|
||||
return VERSION;
|
||||
}
|
666
backend/apis/nodejs/node_modules/@jest/core/build/watch.js
generated
vendored
Normal file
666
backend/apis/nodejs/node_modules/@jest/core/build/watch.js
generated
vendored
Normal file
@ -0,0 +1,666 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = watch;
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _ansiEscapes() {
|
||||
const data = _interopRequireDefault(require('ansi-escapes'));
|
||||
_ansiEscapes = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestValidate() {
|
||||
const data = require('jest-validate');
|
||||
_jestValidate = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWatcher() {
|
||||
const data = require('jest-watcher');
|
||||
_jestWatcher = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _FailedTestsCache = _interopRequireDefault(require('./FailedTestsCache'));
|
||||
var _SearchSource = _interopRequireDefault(require('./SearchSource'));
|
||||
var _getChangedFilesPromise = _interopRequireDefault(
|
||||
require('./getChangedFilesPromise')
|
||||
);
|
||||
var _activeFiltersMessage = _interopRequireDefault(
|
||||
require('./lib/activeFiltersMessage')
|
||||
);
|
||||
var _createContext = _interopRequireDefault(require('./lib/createContext'));
|
||||
var _isValidPath = _interopRequireDefault(require('./lib/isValidPath'));
|
||||
var _updateGlobalConfig = _interopRequireDefault(
|
||||
require('./lib/updateGlobalConfig')
|
||||
);
|
||||
var _watchPluginsHelpers = require('./lib/watchPluginsHelpers');
|
||||
var _FailedTestsInteractive = _interopRequireDefault(
|
||||
require('./plugins/FailedTestsInteractive')
|
||||
);
|
||||
var _Quit = _interopRequireDefault(require('./plugins/Quit'));
|
||||
var _TestNamePattern = _interopRequireDefault(
|
||||
require('./plugins/TestNamePattern')
|
||||
);
|
||||
var _TestPathPattern = _interopRequireDefault(
|
||||
require('./plugins/TestPathPattern')
|
||||
);
|
||||
var _UpdateSnapshots = _interopRequireDefault(
|
||||
require('./plugins/UpdateSnapshots')
|
||||
);
|
||||
var _UpdateSnapshotsInteractive = _interopRequireDefault(
|
||||
require('./plugins/UpdateSnapshotsInteractive')
|
||||
);
|
||||
var _runJest = _interopRequireDefault(require('./runJest'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {print: preRunMessagePrint} = _jestUtil().preRunMessage;
|
||||
let hasExitListener = false;
|
||||
const INTERNAL_PLUGINS = [
|
||||
_FailedTestsInteractive.default,
|
||||
_TestPathPattern.default,
|
||||
_TestNamePattern.default,
|
||||
_UpdateSnapshots.default,
|
||||
_UpdateSnapshotsInteractive.default,
|
||||
_Quit.default
|
||||
];
|
||||
const RESERVED_KEY_PLUGINS = new Map([
|
||||
[
|
||||
_UpdateSnapshots.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'updating snapshots',
|
||||
key: 'u'
|
||||
}
|
||||
],
|
||||
[
|
||||
_UpdateSnapshotsInteractive.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'updating snapshots interactively',
|
||||
key: 'i'
|
||||
}
|
||||
],
|
||||
[
|
||||
_Quit.default,
|
||||
{
|
||||
forbiddenOverwriteMessage: 'quitting watch mode'
|
||||
}
|
||||
]
|
||||
]);
|
||||
async function watch(
|
||||
initialGlobalConfig,
|
||||
contexts,
|
||||
outputStream,
|
||||
hasteMapInstances,
|
||||
stdin = process.stdin,
|
||||
hooks = new (_jestWatcher().JestHook)(),
|
||||
filter
|
||||
) {
|
||||
// `globalConfig` will be constantly updated and reassigned as a result of
|
||||
// watch mode interactions.
|
||||
let globalConfig = initialGlobalConfig;
|
||||
let activePlugin;
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: globalConfig.watch ? 'watch' : 'watchAll',
|
||||
passWithNoTests: true
|
||||
});
|
||||
const updateConfigAndRun = ({
|
||||
bail,
|
||||
changedSince,
|
||||
collectCoverage,
|
||||
collectCoverageFrom,
|
||||
coverageDirectory,
|
||||
coverageReporters,
|
||||
findRelatedTests,
|
||||
mode,
|
||||
nonFlagArgs,
|
||||
notify,
|
||||
notifyMode,
|
||||
onlyFailures,
|
||||
reporters,
|
||||
testNamePattern,
|
||||
testPathPattern,
|
||||
updateSnapshot,
|
||||
verbose
|
||||
} = {}) => {
|
||||
const previousUpdateSnapshot = globalConfig.updateSnapshot;
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
bail,
|
||||
changedSince,
|
||||
collectCoverage,
|
||||
collectCoverageFrom,
|
||||
coverageDirectory,
|
||||
coverageReporters,
|
||||
findRelatedTests,
|
||||
mode,
|
||||
nonFlagArgs,
|
||||
notify,
|
||||
notifyMode,
|
||||
onlyFailures,
|
||||
reporters,
|
||||
testNamePattern,
|
||||
testPathPattern,
|
||||
updateSnapshot,
|
||||
verbose
|
||||
});
|
||||
startRun(globalConfig);
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
// updateSnapshot is not sticky after a run.
|
||||
updateSnapshot:
|
||||
previousUpdateSnapshot === 'all' ? 'none' : previousUpdateSnapshot
|
||||
});
|
||||
};
|
||||
const watchPlugins = INTERNAL_PLUGINS.map(
|
||||
InternalPlugin =>
|
||||
new InternalPlugin({
|
||||
stdin,
|
||||
stdout: outputStream
|
||||
})
|
||||
);
|
||||
watchPlugins.forEach(plugin => {
|
||||
const hookSubscriber = hooks.getSubscriber();
|
||||
if (plugin.apply) {
|
||||
plugin.apply(hookSubscriber);
|
||||
}
|
||||
});
|
||||
if (globalConfig.watchPlugins != null) {
|
||||
const watchPluginKeys = new Map();
|
||||
for (const plugin of watchPlugins) {
|
||||
const reservedInfo = RESERVED_KEY_PLUGINS.get(plugin.constructor) || {};
|
||||
const key = reservedInfo.key || getPluginKey(plugin, globalConfig);
|
||||
if (!key) {
|
||||
continue;
|
||||
}
|
||||
const {forbiddenOverwriteMessage} = reservedInfo;
|
||||
watchPluginKeys.set(key, {
|
||||
forbiddenOverwriteMessage,
|
||||
overwritable: forbiddenOverwriteMessage == null,
|
||||
plugin
|
||||
});
|
||||
}
|
||||
for (const pluginWithConfig of globalConfig.watchPlugins) {
|
||||
let plugin;
|
||||
try {
|
||||
const ThirdPartyPlugin = await (0, _jestUtil().requireOrImportModule)(
|
||||
pluginWithConfig.path
|
||||
);
|
||||
plugin = new ThirdPartyPlugin({
|
||||
config: pluginWithConfig.config,
|
||||
stdin,
|
||||
stdout: outputStream
|
||||
});
|
||||
} catch (error) {
|
||||
const errorWithContext = new Error(
|
||||
`Failed to initialize watch plugin "${_chalk().default.bold(
|
||||
(0, _slash().default)(
|
||||
path().relative(process.cwd(), pluginWithConfig.path)
|
||||
)
|
||||
)}":\n\n${(0, _jestMessageUtil().formatExecError)(
|
||||
error,
|
||||
contexts[0].config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
);
|
||||
delete errorWithContext.stack;
|
||||
return Promise.reject(errorWithContext);
|
||||
}
|
||||
checkForConflicts(watchPluginKeys, plugin, globalConfig);
|
||||
const hookSubscriber = hooks.getSubscriber();
|
||||
if (plugin.apply) {
|
||||
plugin.apply(hookSubscriber);
|
||||
}
|
||||
watchPlugins.push(plugin);
|
||||
}
|
||||
}
|
||||
const failedTestsCache = new _FailedTestsCache.default();
|
||||
let searchSources = contexts.map(context => ({
|
||||
context,
|
||||
searchSource: new _SearchSource.default(context)
|
||||
}));
|
||||
let isRunning = false;
|
||||
let testWatcher;
|
||||
let shouldDisplayWatchUsage = true;
|
||||
let isWatchUsageDisplayed = false;
|
||||
const emitFileChange = () => {
|
||||
if (hooks.isUsed('onFileChange')) {
|
||||
const projects = searchSources.map(({context, searchSource}) => ({
|
||||
config: context.config,
|
||||
testPaths: searchSource.findMatchingTests('').tests.map(t => t.path)
|
||||
}));
|
||||
hooks.getEmitter().onFileChange({
|
||||
projects
|
||||
});
|
||||
}
|
||||
};
|
||||
emitFileChange();
|
||||
hasteMapInstances.forEach((hasteMapInstance, index) => {
|
||||
hasteMapInstance.on('change', ({eventsQueue, hasteFS, moduleMap}) => {
|
||||
const validPaths = eventsQueue.filter(({filePath}) =>
|
||||
(0, _isValidPath.default)(globalConfig, filePath)
|
||||
);
|
||||
if (validPaths.length) {
|
||||
const context = (contexts[index] = (0, _createContext.default)(
|
||||
contexts[index].config,
|
||||
{
|
||||
hasteFS,
|
||||
moduleMap
|
||||
}
|
||||
));
|
||||
activePlugin = null;
|
||||
searchSources = searchSources.slice();
|
||||
searchSources[index] = {
|
||||
context,
|
||||
searchSource: new _SearchSource.default(context)
|
||||
};
|
||||
emitFileChange();
|
||||
startRun(globalConfig);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!hasExitListener) {
|
||||
hasExitListener = true;
|
||||
process.on('exit', () => {
|
||||
if (activePlugin) {
|
||||
outputStream.write(_ansiEscapes().default.cursorDown());
|
||||
outputStream.write(_ansiEscapes().default.eraseDown);
|
||||
}
|
||||
});
|
||||
}
|
||||
const startRun = globalConfig => {
|
||||
if (isRunning) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
testWatcher = new (_jestWatcher().TestWatcher)({
|
||||
isWatchMode: true
|
||||
});
|
||||
_jestUtil().isInteractive &&
|
||||
outputStream.write(_jestUtil().specialChars.CLEAR);
|
||||
preRunMessagePrint(outputStream);
|
||||
isRunning = true;
|
||||
const configs = contexts.map(context => context.config);
|
||||
const changedFilesPromise = (0, _getChangedFilesPromise.default)(
|
||||
globalConfig,
|
||||
configs
|
||||
);
|
||||
return (0, _runJest.default)({
|
||||
changedFilesPromise,
|
||||
contexts,
|
||||
failedTestsCache,
|
||||
filter,
|
||||
globalConfig,
|
||||
jestHooks: hooks.getEmitter(),
|
||||
onComplete: results => {
|
||||
isRunning = false;
|
||||
hooks.getEmitter().onTestRunComplete(results);
|
||||
|
||||
// Create a new testWatcher instance so that re-runs won't be blocked.
|
||||
// The old instance that was passed to Jest will still be interrupted
|
||||
// and prevent test runs from the previous run.
|
||||
testWatcher = new (_jestWatcher().TestWatcher)({
|
||||
isWatchMode: true
|
||||
});
|
||||
|
||||
// Do not show any Watch Usage related stuff when running in a
|
||||
// non-interactive environment
|
||||
if (_jestUtil().isInteractive) {
|
||||
if (shouldDisplayWatchUsage) {
|
||||
outputStream.write(usage(globalConfig, watchPlugins));
|
||||
shouldDisplayWatchUsage = false; // hide Watch Usage after first run
|
||||
isWatchUsageDisplayed = true;
|
||||
} else {
|
||||
outputStream.write(showToggleUsagePrompt());
|
||||
shouldDisplayWatchUsage = false;
|
||||
isWatchUsageDisplayed = false;
|
||||
}
|
||||
} else {
|
||||
outputStream.write('\n');
|
||||
}
|
||||
failedTestsCache.setTestResults(results.testResults);
|
||||
},
|
||||
outputStream,
|
||||
startRun,
|
||||
testWatcher
|
||||
}).catch(error =>
|
||||
// Errors thrown inside `runJest`, e.g. by resolvers, are caught here for
|
||||
// continuous watch mode execution. We need to reprint them to the
|
||||
// terminal and give just a little bit of extra space so they fit below
|
||||
// `preRunMessagePrint` message nicely.
|
||||
console.error(
|
||||
`\n\n${(0, _jestMessageUtil().formatExecError)(
|
||||
error,
|
||||
contexts[0].config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
)
|
||||
);
|
||||
};
|
||||
const onKeypress = key => {
|
||||
if (
|
||||
key === _jestWatcher().KEYS.CONTROL_C ||
|
||||
key === _jestWatcher().KEYS.CONTROL_D
|
||||
) {
|
||||
if (typeof stdin.setRawMode === 'function') {
|
||||
stdin.setRawMode(false);
|
||||
}
|
||||
outputStream.write('\n');
|
||||
(0, _exit().default)(0);
|
||||
return;
|
||||
}
|
||||
if (activePlugin != null && activePlugin.onKey) {
|
||||
// if a plugin is activate, Jest should let it handle keystrokes, so ignore
|
||||
// them here
|
||||
activePlugin.onKey(key);
|
||||
return;
|
||||
}
|
||||
|
||||
// Abort test run
|
||||
const pluginKeys = (0, _watchPluginsHelpers.getSortedUsageRows)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).map(usage => Number(usage.key).toString(16));
|
||||
if (
|
||||
isRunning &&
|
||||
testWatcher &&
|
||||
['q', _jestWatcher().KEYS.ENTER, 'a', 'o', 'f']
|
||||
.concat(pluginKeys)
|
||||
.includes(key)
|
||||
) {
|
||||
testWatcher.setState({
|
||||
interrupted: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
const matchingWatchPlugin = (0,
|
||||
_watchPluginsHelpers.filterInteractivePlugins)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).find(plugin => getPluginKey(plugin, globalConfig) === key);
|
||||
if (matchingWatchPlugin != null) {
|
||||
if (isRunning) {
|
||||
testWatcher.setState({
|
||||
interrupted: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
// "activate" the plugin, which has jest ignore keystrokes so the plugin
|
||||
// can handle them
|
||||
activePlugin = matchingWatchPlugin;
|
||||
if (activePlugin.run) {
|
||||
activePlugin.run(globalConfig, updateConfigAndRun).then(
|
||||
shouldRerun => {
|
||||
activePlugin = null;
|
||||
if (shouldRerun) {
|
||||
updateConfigAndRun();
|
||||
}
|
||||
},
|
||||
() => {
|
||||
activePlugin = null;
|
||||
onCancelPatternPrompt();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
activePlugin = null;
|
||||
}
|
||||
}
|
||||
switch (key) {
|
||||
case _jestWatcher().KEYS.ENTER:
|
||||
startRun(globalConfig);
|
||||
break;
|
||||
case 'a':
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: 'watchAll',
|
||||
testNamePattern: '',
|
||||
testPathPattern: ''
|
||||
});
|
||||
startRun(globalConfig);
|
||||
break;
|
||||
case 'c':
|
||||
updateConfigAndRun({
|
||||
mode: 'watch',
|
||||
testNamePattern: '',
|
||||
testPathPattern: ''
|
||||
});
|
||||
break;
|
||||
case 'f':
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
onlyFailures: !globalConfig.onlyFailures
|
||||
});
|
||||
startRun(globalConfig);
|
||||
break;
|
||||
case 'o':
|
||||
globalConfig = (0, _updateGlobalConfig.default)(globalConfig, {
|
||||
mode: 'watch',
|
||||
testNamePattern: '',
|
||||
testPathPattern: ''
|
||||
});
|
||||
startRun(globalConfig);
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
case 'w':
|
||||
if (!shouldDisplayWatchUsage && !isWatchUsageDisplayed) {
|
||||
outputStream.write(_ansiEscapes().default.cursorUp());
|
||||
outputStream.write(_ansiEscapes().default.eraseDown);
|
||||
outputStream.write(usage(globalConfig, watchPlugins));
|
||||
isWatchUsageDisplayed = true;
|
||||
shouldDisplayWatchUsage = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
const onCancelPatternPrompt = () => {
|
||||
outputStream.write(_ansiEscapes().default.cursorHide);
|
||||
outputStream.write(_jestUtil().specialChars.CLEAR);
|
||||
outputStream.write(usage(globalConfig, watchPlugins));
|
||||
outputStream.write(_ansiEscapes().default.cursorShow);
|
||||
};
|
||||
if (typeof stdin.setRawMode === 'function') {
|
||||
stdin.setRawMode(true);
|
||||
stdin.resume();
|
||||
stdin.setEncoding('utf8');
|
||||
stdin.on('data', onKeypress);
|
||||
}
|
||||
startRun(globalConfig);
|
||||
return Promise.resolve();
|
||||
}
|
||||
const checkForConflicts = (watchPluginKeys, plugin, globalConfig) => {
|
||||
const key = getPluginKey(plugin, globalConfig);
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
const conflictor = watchPluginKeys.get(key);
|
||||
if (!conflictor || conflictor.overwritable) {
|
||||
watchPluginKeys.set(key, {
|
||||
overwritable: false,
|
||||
plugin
|
||||
});
|
||||
return;
|
||||
}
|
||||
let error;
|
||||
if (conflictor.forbiddenOverwriteMessage) {
|
||||
error = `
|
||||
Watch plugin ${_chalk().default.bold.red(
|
||||
getPluginIdentifier(plugin)
|
||||
)} attempted to register key ${_chalk().default.bold.red(`<${key}>`)},
|
||||
that is reserved internally for ${_chalk().default.bold.red(
|
||||
conflictor.forbiddenOverwriteMessage
|
||||
)}.
|
||||
Please change the configuration key for this plugin.`.trim();
|
||||
} else {
|
||||
const plugins = [conflictor.plugin, plugin]
|
||||
.map(p => _chalk().default.bold.red(getPluginIdentifier(p)))
|
||||
.join(' and ');
|
||||
error = `
|
||||
Watch plugins ${plugins} both attempted to register key ${_chalk().default.bold.red(
|
||||
`<${key}>`
|
||||
)}.
|
||||
Please change the key configuration for one of the conflicting plugins to avoid overlap.`.trim();
|
||||
}
|
||||
throw new (_jestValidate().ValidationError)(
|
||||
'Watch plugin configuration error',
|
||||
error
|
||||
);
|
||||
};
|
||||
const getPluginIdentifier = plugin =>
|
||||
// This breaks as `displayName` is not defined as a static, but since
|
||||
// WatchPlugin is an interface, and it is my understanding interface
|
||||
// static fields are not definable anymore, no idea how to circumvent
|
||||
// this :-(
|
||||
// @ts-expect-error: leave `displayName` be.
|
||||
plugin.constructor.displayName || plugin.constructor.name;
|
||||
const getPluginKey = (plugin, globalConfig) => {
|
||||
if (typeof plugin.getUsageInfo === 'function') {
|
||||
return (
|
||||
plugin.getUsageInfo(globalConfig) || {
|
||||
key: null
|
||||
}
|
||||
).key;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const usage = (globalConfig, watchPlugins, delimiter = '\n') => {
|
||||
const messages = [
|
||||
(0, _activeFiltersMessage.default)(globalConfig),
|
||||
globalConfig.testPathPattern || globalConfig.testNamePattern
|
||||
? `${_chalk().default.dim(' \u203A Press ')}c${_chalk().default.dim(
|
||||
' to clear filters.'
|
||||
)}`
|
||||
: null,
|
||||
`\n${_chalk().default.bold('Watch Usage')}`,
|
||||
globalConfig.watch
|
||||
? `${_chalk().default.dim(' \u203A Press ')}a${_chalk().default.dim(
|
||||
' to run all tests.'
|
||||
)}`
|
||||
: null,
|
||||
globalConfig.onlyFailures
|
||||
? `${_chalk().default.dim(' \u203A Press ')}f${_chalk().default.dim(
|
||||
' to quit "only failed tests" mode.'
|
||||
)}`
|
||||
: `${_chalk().default.dim(' \u203A Press ')}f${_chalk().default.dim(
|
||||
' to run only failed tests.'
|
||||
)}`,
|
||||
(globalConfig.watchAll ||
|
||||
globalConfig.testPathPattern ||
|
||||
globalConfig.testNamePattern) &&
|
||||
!globalConfig.noSCM
|
||||
? `${_chalk().default.dim(' \u203A Press ')}o${_chalk().default.dim(
|
||||
' to only run tests related to changed files.'
|
||||
)}`
|
||||
: null,
|
||||
...(0, _watchPluginsHelpers.getSortedUsageRows)(
|
||||
watchPlugins,
|
||||
globalConfig
|
||||
).map(
|
||||
plugin =>
|
||||
`${_chalk().default.dim(' \u203A Press')} ${
|
||||
plugin.key
|
||||
} ${_chalk().default.dim(`to ${plugin.prompt}.`)}`
|
||||
),
|
||||
`${_chalk().default.dim(' \u203A Press ')}Enter${_chalk().default.dim(
|
||||
' to trigger a test run.'
|
||||
)}`
|
||||
];
|
||||
return `${messages.filter(message => !!message).join(delimiter)}\n`;
|
||||
};
|
||||
const showToggleUsagePrompt = () =>
|
||||
'\n' +
|
||||
`${_chalk().default.bold('Watch Usage: ')}${_chalk().default.dim(
|
||||
'Press '
|
||||
)}w${_chalk().default.dim(' to show more.')}`;
|
102
backend/apis/nodejs/node_modules/@jest/core/package.json
generated
vendored
Normal file
102
backend/apis/nodejs/node_modules/@jest/core/package.json
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
{
|
||||
"name": "@jest/core",
|
||||
"description": "Delightful JavaScript Testing.",
|
||||
"version": "29.7.0",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/console": "^29.7.0",
|
||||
"@jest/reporters": "^29.7.0",
|
||||
"@jest/test-result": "^29.7.0",
|
||||
"@jest/transform": "^29.7.0",
|
||||
"@jest/types": "^29.6.3",
|
||||
"@types/node": "*",
|
||||
"ansi-escapes": "^4.2.1",
|
||||
"chalk": "^4.0.0",
|
||||
"ci-info": "^3.2.0",
|
||||
"exit": "^0.1.2",
|
||||
"graceful-fs": "^4.2.9",
|
||||
"jest-changed-files": "^29.7.0",
|
||||
"jest-config": "^29.7.0",
|
||||
"jest-haste-map": "^29.7.0",
|
||||
"jest-message-util": "^29.7.0",
|
||||
"jest-regex-util": "^29.6.3",
|
||||
"jest-resolve": "^29.7.0",
|
||||
"jest-resolve-dependencies": "^29.7.0",
|
||||
"jest-runner": "^29.7.0",
|
||||
"jest-runtime": "^29.7.0",
|
||||
"jest-snapshot": "^29.7.0",
|
||||
"jest-util": "^29.7.0",
|
||||
"jest-validate": "^29.7.0",
|
||||
"jest-watcher": "^29.7.0",
|
||||
"micromatch": "^4.0.4",
|
||||
"pretty-format": "^29.7.0",
|
||||
"slash": "^3.0.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-sequencer": "^29.7.0",
|
||||
"@jest/test-utils": "^29.7.0",
|
||||
"@types/exit": "^0.1.30",
|
||||
"@types/graceful-fs": "^4.1.3",
|
||||
"@types/micromatch": "^4.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"node-notifier": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-core"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jestjs/jest/issues"
|
||||
},
|
||||
"homepage": "https://jestjs.io/",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"ava",
|
||||
"babel",
|
||||
"coverage",
|
||||
"easy",
|
||||
"expect",
|
||||
"facebook",
|
||||
"immersive",
|
||||
"instant",
|
||||
"jasmine",
|
||||
"jest",
|
||||
"jsdom",
|
||||
"mocha",
|
||||
"mocking",
|
||||
"painless",
|
||||
"qunit",
|
||||
"runner",
|
||||
"sandboxed",
|
||||
"snapshot",
|
||||
"tap",
|
||||
"tape",
|
||||
"test",
|
||||
"testing",
|
||||
"typescript",
|
||||
"watch"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/environment/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/environment/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
418
backend/apis/nodejs/node_modules/@jest/environment/build/index.d.ts
generated
vendored
Normal file
418
backend/apis/nodejs/node_modules/@jest/environment/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,418 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 {Circus} from '@jest/types';
|
||||
import type {Config} from '@jest/types';
|
||||
import type {Context} from 'vm';
|
||||
import type {Global} from '@jest/types';
|
||||
import type {LegacyFakeTimers} from '@jest/fake-timers';
|
||||
import type {Mocked} from 'jest-mock';
|
||||
import type {ModernFakeTimers} from '@jest/fake-timers';
|
||||
import type {ModuleMocker} from 'jest-mock';
|
||||
|
||||
export declare type EnvironmentContext = {
|
||||
console: Console;
|
||||
docblockPragmas: Record<string, string | Array<string>>;
|
||||
testPath: string;
|
||||
};
|
||||
|
||||
export declare interface Jest {
|
||||
/**
|
||||
* Advances all timers by `msToRun` milliseconds. All pending "macro-tasks"
|
||||
* that have been queued via `setTimeout()` or `setInterval()`, and would be
|
||||
* executed within this time frame will be executed.
|
||||
*/
|
||||
advanceTimersByTime(msToRun: number): void;
|
||||
/**
|
||||
* Advances all timers by `msToRun` milliseconds, firing callbacks if necessary.
|
||||
*
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
advanceTimersByTimeAsync(msToRun: number): Promise<void>;
|
||||
/**
|
||||
* Advances all timers by the needed milliseconds so that only the next
|
||||
* timeouts/intervals will run. Optionally, you can provide steps, so it will
|
||||
* run steps amount of next timeouts/intervals.
|
||||
*/
|
||||
advanceTimersToNextTimer(steps?: number): void;
|
||||
/**
|
||||
* Advances the clock to the the moment of the first scheduled timer, firing it.
|
||||
* Optionally, you can provide steps, so it will run steps amount of
|
||||
* next timeouts/intervals.
|
||||
*
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
advanceTimersToNextTimerAsync(steps?: number): Promise<void>;
|
||||
/**
|
||||
* Disables automatic mocking in the module loader.
|
||||
*/
|
||||
autoMockOff(): Jest;
|
||||
/**
|
||||
* Enables automatic mocking in the module loader.
|
||||
*/
|
||||
autoMockOn(): Jest;
|
||||
/**
|
||||
* Clears the `mock.calls`, `mock.instances`, `mock.contexts` and `mock.results` properties of
|
||||
* all mocks. Equivalent to calling `.mockClear()` on every mocked function.
|
||||
*/
|
||||
clearAllMocks(): Jest;
|
||||
/**
|
||||
* Removes any pending timers from the timer system. If any timers have been
|
||||
* scheduled, they will be cleared and will never have the opportunity to
|
||||
* execute in the future.
|
||||
*/
|
||||
clearAllTimers(): void;
|
||||
/**
|
||||
* Given the name of a module, use the automatic mocking system to generate a
|
||||
* mocked version of the module for you.
|
||||
*
|
||||
* This is useful when you want to create a manual mock that extends the
|
||||
* automatic mock's behavior.
|
||||
*/
|
||||
createMockFromModule<T = unknown>(moduleName: string): Mocked<T>;
|
||||
/**
|
||||
* Indicates that the module system should never return a mocked version of
|
||||
* the specified module and its dependencies.
|
||||
*/
|
||||
deepUnmock(moduleName: string): Jest;
|
||||
/**
|
||||
* Disables automatic mocking in the module loader.
|
||||
*
|
||||
* After this method is called, all `require()`s will return the real
|
||||
* versions of each module (rather than a mocked version).
|
||||
*/
|
||||
disableAutomock(): Jest;
|
||||
/**
|
||||
* When using `babel-jest`, calls to `jest.mock()` will automatically be hoisted
|
||||
* to the top of the code block. Use this method if you want to explicitly
|
||||
* avoid this behavior.
|
||||
*/
|
||||
doMock<T = unknown>(
|
||||
moduleName: string,
|
||||
moduleFactory?: () => T,
|
||||
options?: {
|
||||
virtual?: boolean;
|
||||
},
|
||||
): Jest;
|
||||
/**
|
||||
* When using `babel-jest`, calls to `jest.unmock()` will automatically be hoisted
|
||||
* to the top of the code block. Use this method if you want to explicitly
|
||||
* avoid this behavior.
|
||||
*/
|
||||
dontMock(moduleName: string): Jest;
|
||||
/**
|
||||
* Enables automatic mocking in the module loader.
|
||||
*/
|
||||
enableAutomock(): Jest;
|
||||
/**
|
||||
* Creates a mock function. Optionally takes a mock implementation.
|
||||
*/
|
||||
fn: ModuleMocker['fn'];
|
||||
/**
|
||||
* Given the name of a module, use the automatic mocking system to generate a
|
||||
* mocked version of the module for you.
|
||||
*
|
||||
* This is useful when you want to create a manual mock that extends the
|
||||
* automatic mock's behavior.
|
||||
*
|
||||
* @deprecated Use `jest.createMockFromModule()` instead
|
||||
*/
|
||||
genMockFromModule<T = unknown>(moduleName: string): Mocked<T>;
|
||||
/**
|
||||
* When mocking time, `Date.now()` will also be mocked. If you for some reason
|
||||
* need access to the real current time, you can invoke this function.
|
||||
*
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
getRealSystemTime(): number;
|
||||
/**
|
||||
* Retrieves the seed value. It will be randomly generated for each test run
|
||||
* or can be manually set via the `--seed` CLI argument.
|
||||
*/
|
||||
getSeed(): number;
|
||||
/**
|
||||
* Returns the number of fake timers still left to run.
|
||||
*/
|
||||
getTimerCount(): number;
|
||||
/**
|
||||
* Returns `true` if test environment has been torn down.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* if (jest.isEnvironmentTornDown()) {
|
||||
* // The Jest environment has been torn down, so stop doing work
|
||||
* return;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
isEnvironmentTornDown(): boolean;
|
||||
/**
|
||||
* Determines if the given function is a mocked function.
|
||||
*/
|
||||
isMockFunction: ModuleMocker['isMockFunction'];
|
||||
/**
|
||||
* `jest.isolateModules()` goes a step further than `jest.resetModules()` and
|
||||
* creates a sandbox registry for the modules that are loaded inside the callback
|
||||
* function. This is useful to isolate specific modules for every test so that
|
||||
* local module state doesn't conflict between tests.
|
||||
*/
|
||||
isolateModules(fn: () => void): Jest;
|
||||
/**
|
||||
* `jest.isolateModulesAsync()` is the equivalent of `jest.isolateModules()`, but for
|
||||
* async functions to be wrapped. The caller is expected to `await` the completion of
|
||||
* `isolateModulesAsync`.
|
||||
*/
|
||||
isolateModulesAsync(fn: () => Promise<void>): Promise<void>;
|
||||
/**
|
||||
* Mocks a module with an auto-mocked version when it is being required.
|
||||
*/
|
||||
mock<T = unknown>(
|
||||
moduleName: string,
|
||||
moduleFactory?: () => T,
|
||||
options?: {
|
||||
virtual?: boolean;
|
||||
},
|
||||
): Jest;
|
||||
/**
|
||||
* Mocks a module with the provided module factory when it is being imported.
|
||||
*/
|
||||
unstable_mockModule<T = unknown>(
|
||||
moduleName: string,
|
||||
moduleFactory: () => T | Promise<T>,
|
||||
options?: {
|
||||
virtual?: boolean;
|
||||
},
|
||||
): Jest;
|
||||
/**
|
||||
* Wraps types of the `source` object and its deep members with type definitions
|
||||
* of Jest mock function. Pass `{shallow: true}` option to disable the deeply
|
||||
* mocked behavior.
|
||||
*/
|
||||
mocked: ModuleMocker['mocked'];
|
||||
/**
|
||||
* Returns the current time in ms of the fake timer clock.
|
||||
*/
|
||||
now(): number;
|
||||
/**
|
||||
* Replaces property on an object with another value.
|
||||
*
|
||||
* @remarks
|
||||
* For mocking functions or 'get' or 'set' accessors, use `jest.spyOn()` instead.
|
||||
*/
|
||||
replaceProperty: ModuleMocker['replaceProperty'];
|
||||
/**
|
||||
* Returns the actual module instead of a mock, bypassing all checks on
|
||||
* whether the module should receive a mock implementation or not.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* jest.mock('../myModule', () => {
|
||||
* // Require the original module to not be mocked...
|
||||
* const originalModule = jest.requireActual('../myModule');
|
||||
*
|
||||
* return {
|
||||
* __esModule: true, // Use it when dealing with esModules
|
||||
* ...originalModule,
|
||||
* getRandom: jest.fn().mockReturnValue(10),
|
||||
* };
|
||||
* });
|
||||
*
|
||||
* const getRandom = require('../myModule').getRandom;
|
||||
*
|
||||
* getRandom(); // Always returns 10
|
||||
* ```
|
||||
*/
|
||||
requireActual<T = unknown>(moduleName: string): T;
|
||||
/**
|
||||
* Returns a mock module instead of the actual module, bypassing all checks
|
||||
* on whether the module should be required normally or not.
|
||||
*/
|
||||
requireMock<T = unknown>(moduleName: string): T;
|
||||
/**
|
||||
* Resets the state of all mocks. Equivalent to calling `.mockReset()` on
|
||||
* every mocked function.
|
||||
*/
|
||||
resetAllMocks(): Jest;
|
||||
/**
|
||||
* Resets the module registry - the cache of all required modules. This is
|
||||
* useful to isolate modules where local state might conflict between tests.
|
||||
*/
|
||||
resetModules(): Jest;
|
||||
/**
|
||||
* Restores all mocks and replaced properties back to their original value.
|
||||
* Equivalent to calling `.mockRestore()` on every mocked function
|
||||
* and `.restore()` on every replaced property.
|
||||
*
|
||||
* Beware that `jest.restoreAllMocks()` only works when the mock was created
|
||||
* with `jest.spyOn()`; other mocks will require you to manually restore them.
|
||||
*/
|
||||
restoreAllMocks(): Jest;
|
||||
/**
|
||||
* Runs failed tests n-times until they pass or until the max number of
|
||||
* retries is exhausted.
|
||||
*
|
||||
* If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused
|
||||
* the test to fail to the console, providing visibility on why a retry occurred.
|
||||
* retries is exhausted.
|
||||
*
|
||||
* @remarks
|
||||
* Only available with `jest-circus` runner.
|
||||
*/
|
||||
retryTimes(
|
||||
numRetries: number,
|
||||
options?: {
|
||||
logErrorsBeforeRetry?: boolean;
|
||||
},
|
||||
): Jest;
|
||||
/**
|
||||
* Exhausts tasks queued by `setImmediate()`.
|
||||
*
|
||||
* @remarks
|
||||
* Only available when using legacy fake timers implementation.
|
||||
*/
|
||||
runAllImmediates(): void;
|
||||
/**
|
||||
* Exhausts the micro-task queue (usually interfaced in node via
|
||||
* `process.nextTick()`).
|
||||
*/
|
||||
runAllTicks(): void;
|
||||
/**
|
||||
* Exhausts the macro-task queue (i.e., all tasks queued by `setTimeout()`
|
||||
* and `setInterval()`).
|
||||
*/
|
||||
runAllTimers(): void;
|
||||
/**
|
||||
* Exhausts the macro-task queue (i.e., all tasks queued by `setTimeout()`
|
||||
* and `setInterval()`).
|
||||
*
|
||||
* @remarks
|
||||
* If new timers are added while it is executing they will be run as well.
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
runAllTimersAsync(): Promise<void>;
|
||||
/**
|
||||
* Executes only the macro-tasks that are currently pending (i.e., only the
|
||||
* tasks that have been queued by `setTimeout()` or `setInterval()` up to this
|
||||
* point). If any of the currently pending macro-tasks schedule new
|
||||
* macro-tasks, those new tasks will not be executed by this call.
|
||||
*/
|
||||
runOnlyPendingTimers(): void;
|
||||
/**
|
||||
* Executes only the macro-tasks that are currently pending (i.e., only the
|
||||
* tasks that have been queued by `setTimeout()` or `setInterval()` up to this
|
||||
* point). If any of the currently pending macro-tasks schedule new
|
||||
* macro-tasks, those new tasks will not be executed by this call.
|
||||
*
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
runOnlyPendingTimersAsync(): Promise<void>;
|
||||
/**
|
||||
* Explicitly supplies the mock object that the module system should return
|
||||
* for the specified module.
|
||||
*
|
||||
* @remarks
|
||||
* It is recommended to use `jest.mock()` instead. The `jest.mock()` API's second
|
||||
* argument is a module factory instead of the expected exported module object.
|
||||
*/
|
||||
setMock(moduleName: string, moduleExports: unknown): Jest;
|
||||
/**
|
||||
* Set the current system time used by fake timers. Simulates a user changing
|
||||
* the system clock while your program is running. It affects the current time,
|
||||
* but it does not in itself cause e.g. timers to fire; they will fire exactly
|
||||
* as they would have done without the call to `jest.setSystemTime()`.
|
||||
*
|
||||
* @remarks
|
||||
* Not available when using legacy fake timers implementation.
|
||||
*/
|
||||
setSystemTime(now?: number | Date): void;
|
||||
/**
|
||||
* Set the default timeout interval for tests and before/after hooks in
|
||||
* milliseconds.
|
||||
*
|
||||
* @remarks
|
||||
* The default timeout interval is 5 seconds if this method is not called.
|
||||
*/
|
||||
setTimeout(timeout: number): Jest;
|
||||
/**
|
||||
* Creates a mock function similar to `jest.fn()` but also tracks calls to
|
||||
* `object[methodName]`.
|
||||
*
|
||||
* Optional third argument of `accessType` can be either 'get' or 'set', which
|
||||
* proves to be useful when you want to spy on a getter or a setter, respectively.
|
||||
*
|
||||
* @remarks
|
||||
* By default, `jest.spyOn()` also calls the spied method. This is different
|
||||
* behavior from most other test libraries.
|
||||
*/
|
||||
spyOn: ModuleMocker['spyOn'];
|
||||
/**
|
||||
* Indicates that the module system should never return a mocked version of
|
||||
* the specified module from `require()` (e.g. that it should always return the
|
||||
* real module).
|
||||
*/
|
||||
unmock(moduleName: string): Jest;
|
||||
/**
|
||||
* Instructs Jest to use fake versions of the global date, performance,
|
||||
* time and timer APIs. Fake timers implementation is backed by
|
||||
* [`@sinonjs/fake-timers`](https://github.com/sinonjs/fake-timers).
|
||||
*
|
||||
* @remarks
|
||||
* Calling `jest.useFakeTimers()` once again in the same test file would reinstall
|
||||
* fake timers using the provided options.
|
||||
*/
|
||||
useFakeTimers(
|
||||
fakeTimersConfig?: Config.FakeTimersConfig | Config.LegacyFakeTimersConfig,
|
||||
): Jest;
|
||||
/**
|
||||
* Instructs Jest to restore the original implementations of the global date,
|
||||
* performance, time and timer APIs.
|
||||
*/
|
||||
useRealTimers(): Jest;
|
||||
}
|
||||
|
||||
export declare class JestEnvironment<Timer = unknown> {
|
||||
constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
|
||||
global: Global.Global;
|
||||
fakeTimers: LegacyFakeTimers<Timer> | null;
|
||||
fakeTimersModern: ModernFakeTimers | null;
|
||||
moduleMocker: ModuleMocker | null;
|
||||
getVmContext(): Context | null;
|
||||
setup(): Promise<void>;
|
||||
teardown(): Promise<void>;
|
||||
handleTestEvent?: Circus.EventHandler;
|
||||
exportConditions?: () => Array<string>;
|
||||
}
|
||||
|
||||
export declare interface JestEnvironmentConfig {
|
||||
projectConfig: Config.ProjectConfig;
|
||||
globalConfig: Config.GlobalConfig;
|
||||
}
|
||||
|
||||
export declare interface JestImportMeta extends ImportMeta {
|
||||
jest: Jest;
|
||||
}
|
||||
|
||||
export declare type Module = NodeModule;
|
||||
|
||||
export declare type ModuleWrapper = (
|
||||
this: Module['exports'],
|
||||
module: Module,
|
||||
exports: Module['exports'],
|
||||
require: Module['require'],
|
||||
__dirname: string,
|
||||
__filename: Module['filename'],
|
||||
jest?: Jest,
|
||||
...sandboxInjectedGlobals: Array<Global.Global[keyof Global.Global]>
|
||||
) => unknown;
|
||||
|
||||
export {};
|
1
backend/apis/nodejs/node_modules/@jest/environment/build/index.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/@jest/environment/build/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
32
backend/apis/nodejs/node_modules/@jest/environment/package.json
generated
vendored
Normal file
32
backend/apis/nodejs/node_modules/@jest/environment/package.json
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@jest/environment",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-environment"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/fake-timers": "^29.7.0",
|
||||
"@jest/types": "^29.6.3",
|
||||
"@types/node": "*",
|
||||
"jest-mock": "^29.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/expect-utils/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/expect-utils/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
5
backend/apis/nodejs/node_modules/@jest/expect-utils/README.md
generated
vendored
Normal file
5
backend/apis/nodejs/node_modules/@jest/expect-utils/README.md
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# `@jest/expect-utils`
|
||||
|
||||
This module exports some utils for the `expect` function used in [Jest](https://jestjs.io/).
|
||||
|
||||
You probably don't want to use this package directly. E.g. if you're writing [custom matcher](https://jestjs.io/docs/expect#expectextendmatchers), you should use the injected [`this.equals`](https://jestjs.io/docs/expect#thisequalsa-b).
|
66
backend/apis/nodejs/node_modules/@jest/expect-utils/build/immutableUtils.js
generated
vendored
Normal file
66
backend/apis/nodejs/node_modules/@jest/expect-utils/build/immutableUtils.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.isImmutableList = isImmutableList;
|
||||
exports.isImmutableOrderedKeyed = isImmutableOrderedKeyed;
|
||||
exports.isImmutableOrderedSet = isImmutableOrderedSet;
|
||||
exports.isImmutableRecord = isImmutableRecord;
|
||||
exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
|
||||
exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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/immutable-js/immutable-js/tree/main/src/predicates
|
||||
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
||||
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
||||
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
||||
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
||||
const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
|
||||
function isObjectLiteral(source) {
|
||||
return source != null && typeof source === 'object' && !Array.isArray(source);
|
||||
}
|
||||
function isImmutableUnorderedKeyed(source) {
|
||||
return Boolean(
|
||||
source &&
|
||||
isObjectLiteral(source) &&
|
||||
source[IS_KEYED_SENTINEL] &&
|
||||
!source[IS_ORDERED_SENTINEL]
|
||||
);
|
||||
}
|
||||
function isImmutableUnorderedSet(source) {
|
||||
return Boolean(
|
||||
source &&
|
||||
isObjectLiteral(source) &&
|
||||
source[IS_SET_SENTINEL] &&
|
||||
!source[IS_ORDERED_SENTINEL]
|
||||
);
|
||||
}
|
||||
function isImmutableList(source) {
|
||||
return Boolean(source && isObjectLiteral(source) && source[IS_LIST_SENTINEL]);
|
||||
}
|
||||
function isImmutableOrderedKeyed(source) {
|
||||
return Boolean(
|
||||
source &&
|
||||
isObjectLiteral(source) &&
|
||||
source[IS_KEYED_SENTINEL] &&
|
||||
source[IS_ORDERED_SENTINEL]
|
||||
);
|
||||
}
|
||||
function isImmutableOrderedSet(source) {
|
||||
return Boolean(
|
||||
source &&
|
||||
isObjectLiteral(source) &&
|
||||
source[IS_SET_SENTINEL] &&
|
||||
source[IS_ORDERED_SENTINEL]
|
||||
);
|
||||
}
|
||||
function isImmutableRecord(source) {
|
||||
return Boolean(source && isObjectLiteral(source) && source[IS_RECORD_SYMBOL]);
|
||||
}
|
94
backend/apis/nodejs/node_modules/@jest/expect-utils/build/index.d.ts
generated
vendored
Normal file
94
backend/apis/nodejs/node_modules/@jest/expect-utils/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare const arrayBufferEquality: (
|
||||
a: unknown,
|
||||
b: unknown,
|
||||
) => boolean | undefined;
|
||||
|
||||
export declare function emptyObject(obj: unknown): boolean;
|
||||
|
||||
export declare const equals: EqualsFunction;
|
||||
|
||||
export declare type EqualsFunction = (
|
||||
a: unknown,
|
||||
b: unknown,
|
||||
customTesters?: Array<Tester>,
|
||||
strictCheck?: boolean,
|
||||
) => boolean;
|
||||
|
||||
export declare const getObjectKeys: (object: object) => Array<string | symbol>;
|
||||
|
||||
export declare const getObjectSubset: (
|
||||
object: any,
|
||||
subset: any,
|
||||
customTesters?: Array<Tester>,
|
||||
seenReferences?: WeakMap<object, boolean>,
|
||||
) => any;
|
||||
|
||||
declare type GetPath = {
|
||||
hasEndProp?: boolean;
|
||||
endPropIsDefined?: boolean;
|
||||
lastTraversedObject: unknown;
|
||||
traversedPath: Array<string>;
|
||||
value?: unknown;
|
||||
};
|
||||
|
||||
export declare const getPath: (
|
||||
object: Record<string, any>,
|
||||
propertyPath: string | Array<string>,
|
||||
) => GetPath;
|
||||
|
||||
export declare function isA<T>(typeName: string, value: unknown): value is T;
|
||||
|
||||
export declare const isError: (value: unknown) => value is Error;
|
||||
|
||||
export declare const isOneline: (
|
||||
expected: unknown,
|
||||
received: unknown,
|
||||
) => boolean;
|
||||
|
||||
export declare const iterableEquality: (
|
||||
a: any,
|
||||
b: any,
|
||||
customTesters?: Array<Tester>,
|
||||
aStack?: Array<any>,
|
||||
bStack?: Array<any>,
|
||||
) => boolean | undefined;
|
||||
|
||||
export declare const partition: <T>(
|
||||
items: T[],
|
||||
predicate: (arg: T) => boolean,
|
||||
) => [T[], T[]];
|
||||
|
||||
export declare const pathAsArray: (propertyPath: string) => Array<any>;
|
||||
|
||||
export declare const sparseArrayEquality: (
|
||||
a: unknown,
|
||||
b: unknown,
|
||||
customTesters?: Array<Tester>,
|
||||
) => boolean | undefined;
|
||||
|
||||
export declare const subsetEquality: (
|
||||
object: unknown,
|
||||
subset: unknown,
|
||||
customTesters?: Array<Tester>,
|
||||
) => boolean | undefined;
|
||||
|
||||
export declare type Tester = (
|
||||
this: TesterContext,
|
||||
a: any,
|
||||
b: any,
|
||||
customTesters: Array<Tester>,
|
||||
) => boolean | undefined;
|
||||
|
||||
export declare interface TesterContext {
|
||||
equals: EqualsFunction;
|
||||
}
|
||||
|
||||
export declare const typeEquality: (a: any, b: any) => boolean | undefined;
|
||||
|
||||
export {};
|
34
backend/apis/nodejs/node_modules/@jest/expect-utils/build/index.js
generated
vendored
Normal file
34
backend/apis/nodejs/node_modules/@jest/expect-utils/build/index.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
equals: true,
|
||||
isA: true
|
||||
};
|
||||
Object.defineProperty(exports, 'equals', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _jasmineUtils.equals;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isA', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _jasmineUtils.isA;
|
||||
}
|
||||
});
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
var _utils = require('./utils');
|
||||
Object.keys(_utils).forEach(function (key) {
|
||||
if (key === 'default' || key === '__esModule') return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _utils[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils[key];
|
||||
}
|
||||
});
|
||||
});
|
218
backend/apis/nodejs/node_modules/@jest/expect-utils/build/jasmineUtils.js
generated
vendored
Normal file
218
backend/apis/nodejs/node_modules/@jest/expect-utils/build/jasmineUtils.js
generated
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.equals = void 0;
|
||||
exports.isA = isA;
|
||||
/*
|
||||
Copyright (c) 2008-2016 Pivotal Labs
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
// Extracted out of jasmine 2.5.2
|
||||
const equals = (a, b, customTesters, strictCheck) => {
|
||||
customTesters = customTesters || [];
|
||||
return eq(a, b, [], [], customTesters, strictCheck);
|
||||
};
|
||||
exports.equals = equals;
|
||||
function isAsymmetric(obj) {
|
||||
return !!obj && isA('Function', obj.asymmetricMatch);
|
||||
}
|
||||
function asymmetricMatch(a, b) {
|
||||
const asymmetricA = isAsymmetric(a);
|
||||
const asymmetricB = isAsymmetric(b);
|
||||
if (asymmetricA && asymmetricB) {
|
||||
return undefined;
|
||||
}
|
||||
if (asymmetricA) {
|
||||
return a.asymmetricMatch(b);
|
||||
}
|
||||
if (asymmetricB) {
|
||||
return b.asymmetricMatch(a);
|
||||
}
|
||||
}
|
||||
|
||||
// Equality function lovingly adapted from isEqual in
|
||||
// [Underscore](http://underscorejs.org)
|
||||
function eq(a, b, aStack, bStack, customTesters, strictCheck) {
|
||||
let result = true;
|
||||
const asymmetricResult = asymmetricMatch(a, b);
|
||||
if (asymmetricResult !== undefined) {
|
||||
return asymmetricResult;
|
||||
}
|
||||
const testerContext = {
|
||||
equals
|
||||
};
|
||||
for (let i = 0; i < customTesters.length; i++) {
|
||||
const customTesterResult = customTesters[i].call(
|
||||
testerContext,
|
||||
a,
|
||||
b,
|
||||
customTesters
|
||||
);
|
||||
if (customTesterResult !== undefined) {
|
||||
return customTesterResult;
|
||||
}
|
||||
}
|
||||
if (a instanceof Error && b instanceof Error) {
|
||||
return a.message == b.message;
|
||||
}
|
||||
if (Object.is(a, b)) {
|
||||
return true;
|
||||
}
|
||||
// A strict comparison is necessary because `null == undefined`.
|
||||
if (a === null || b === null) {
|
||||
return a === b;
|
||||
}
|
||||
const className = Object.prototype.toString.call(a);
|
||||
if (className != Object.prototype.toString.call(b)) {
|
||||
return false;
|
||||
}
|
||||
switch (className) {
|
||||
case '[object Boolean]':
|
||||
case '[object String]':
|
||||
case '[object Number]':
|
||||
if (typeof a !== typeof b) {
|
||||
// One is a primitive, one a `new Primitive()`
|
||||
return false;
|
||||
} else if (typeof a !== 'object' && typeof b !== 'object') {
|
||||
// both are proper primitives
|
||||
return Object.is(a, b);
|
||||
} else {
|
||||
// both are `new Primitive()`s
|
||||
return Object.is(a.valueOf(), b.valueOf());
|
||||
}
|
||||
case '[object Date]':
|
||||
// Coerce dates to numeric primitive values. Dates are compared by their
|
||||
// millisecond representations. Note that invalid dates with millisecond representations
|
||||
// of `NaN` are not equivalent.
|
||||
return +a == +b;
|
||||
// RegExps are compared by their source patterns and flags.
|
||||
case '[object RegExp]':
|
||||
return a.source === b.source && a.flags === b.flags;
|
||||
}
|
||||
if (typeof a !== 'object' || typeof b !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use DOM3 method isEqualNode (IE>=9)
|
||||
if (isDomNode(a) && isDomNode(b)) {
|
||||
return a.isEqualNode(b);
|
||||
}
|
||||
|
||||
// Used to detect circular references.
|
||||
let length = aStack.length;
|
||||
while (length--) {
|
||||
// Linear search. Performance is inversely proportional to the number of
|
||||
// unique nested structures.
|
||||
// circular references at same depth are equal
|
||||
// circular reference is not equal to non-circular one
|
||||
if (aStack[length] === a) {
|
||||
return bStack[length] === b;
|
||||
} else if (bStack[length] === b) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Add the first object to the stack of traversed objects.
|
||||
aStack.push(a);
|
||||
bStack.push(b);
|
||||
// Recursively compare objects and arrays.
|
||||
// Compare array lengths to determine if a deep comparison is necessary.
|
||||
if (strictCheck && className == '[object Array]' && a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Deep compare objects.
|
||||
const aKeys = keys(a, hasKey);
|
||||
let key;
|
||||
const bKeys = keys(b, hasKey);
|
||||
// Add keys corresponding to asymmetric matchers if they miss in non strict check mode
|
||||
if (!strictCheck) {
|
||||
for (let index = 0; index !== bKeys.length; ++index) {
|
||||
key = bKeys[index];
|
||||
if ((isAsymmetric(b[key]) || b[key] === undefined) && !hasKey(a, key)) {
|
||||
aKeys.push(key);
|
||||
}
|
||||
}
|
||||
for (let index = 0; index !== aKeys.length; ++index) {
|
||||
key = aKeys[index];
|
||||
if ((isAsymmetric(a[key]) || a[key] === undefined) && !hasKey(b, key)) {
|
||||
bKeys.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
||||
let size = aKeys.length;
|
||||
if (bKeys.length !== size) {
|
||||
return false;
|
||||
}
|
||||
while (size--) {
|
||||
key = aKeys[size];
|
||||
|
||||
// Deep compare each member
|
||||
if (strictCheck)
|
||||
result =
|
||||
hasKey(b, key) &&
|
||||
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
||||
else
|
||||
result =
|
||||
(hasKey(b, key) || isAsymmetric(a[key]) || a[key] === undefined) &&
|
||||
eq(a[key], b[key], aStack, bStack, customTesters, strictCheck);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Remove the first object from the stack of traversed objects.
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
return result;
|
||||
}
|
||||
function keys(obj, hasKey) {
|
||||
const keys = [];
|
||||
for (const key in obj) {
|
||||
if (hasKey(obj, key)) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys.concat(
|
||||
Object.getOwnPropertySymbols(obj).filter(
|
||||
symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable
|
||||
)
|
||||
);
|
||||
}
|
||||
function hasKey(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
function isA(typeName, value) {
|
||||
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
|
||||
}
|
||||
function isDomNode(obj) {
|
||||
return (
|
||||
obj !== null &&
|
||||
typeof obj === 'object' &&
|
||||
typeof obj.nodeType === 'number' &&
|
||||
typeof obj.nodeName === 'string' &&
|
||||
typeof obj.isEqualNode === 'function'
|
||||
);
|
||||
}
|
1
backend/apis/nodejs/node_modules/@jest/expect-utils/build/types.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/@jest/expect-utils/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
462
backend/apis/nodejs/node_modules/@jest/expect-utils/build/utils.js
generated
vendored
Normal file
462
backend/apis/nodejs/node_modules/@jest/expect-utils/build/utils.js
generated
vendored
Normal file
@ -0,0 +1,462 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.arrayBufferEquality = void 0;
|
||||
exports.emptyObject = emptyObject;
|
||||
exports.typeEquality =
|
||||
exports.subsetEquality =
|
||||
exports.sparseArrayEquality =
|
||||
exports.pathAsArray =
|
||||
exports.partition =
|
||||
exports.iterableEquality =
|
||||
exports.isOneline =
|
||||
exports.isError =
|
||||
exports.getPath =
|
||||
exports.getObjectSubset =
|
||||
exports.getObjectKeys =
|
||||
void 0;
|
||||
var _jestGetType = require('jest-get-type');
|
||||
var _immutableUtils = require('./immutableUtils');
|
||||
var _jasmineUtils = require('./jasmineUtils');
|
||||
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
|
||||
*/
|
||||
const hasPropertyInObject = (object, key) => {
|
||||
const shouldTerminate =
|
||||
!object || typeof object !== 'object' || object === Object.prototype;
|
||||
if (shouldTerminate) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
Object.prototype.hasOwnProperty.call(object, key) ||
|
||||
hasPropertyInObject(Object.getPrototypeOf(object), key)
|
||||
);
|
||||
};
|
||||
|
||||
// Retrieves an object's keys for evaluation by getObjectSubset. This evaluates
|
||||
// the prototype chain for string keys but not for symbols. (Otherwise, it
|
||||
// could find values such as a Set or Map's Symbol.toStringTag, with unexpected
|
||||
// results.)
|
||||
const getObjectKeys = object => [
|
||||
...Object.keys(object),
|
||||
...Object.getOwnPropertySymbols(object)
|
||||
];
|
||||
exports.getObjectKeys = getObjectKeys;
|
||||
const getPath = (object, propertyPath) => {
|
||||
if (!Array.isArray(propertyPath)) {
|
||||
propertyPath = pathAsArray(propertyPath);
|
||||
}
|
||||
if (propertyPath.length) {
|
||||
const lastProp = propertyPath.length === 1;
|
||||
const prop = propertyPath[0];
|
||||
const newObject = object[prop];
|
||||
if (!lastProp && (newObject === null || newObject === undefined)) {
|
||||
// This is not the last prop in the chain. If we keep recursing it will
|
||||
// hit a `can't access property X of undefined | null`. At this point we
|
||||
// know that the chain has broken and we can return right away.
|
||||
return {
|
||||
hasEndProp: false,
|
||||
lastTraversedObject: object,
|
||||
traversedPath: []
|
||||
};
|
||||
}
|
||||
const result = getPath(newObject, propertyPath.slice(1));
|
||||
if (result.lastTraversedObject === null) {
|
||||
result.lastTraversedObject = object;
|
||||
}
|
||||
result.traversedPath.unshift(prop);
|
||||
if (lastProp) {
|
||||
// Does object have the property with an undefined value?
|
||||
// Although primitive values support bracket notation (above)
|
||||
// they would throw TypeError for in operator (below).
|
||||
result.endPropIsDefined =
|
||||
!(0, _jestGetType.isPrimitive)(object) && prop in object;
|
||||
result.hasEndProp = newObject !== undefined || result.endPropIsDefined;
|
||||
if (!result.hasEndProp) {
|
||||
result.traversedPath.shift();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return {
|
||||
lastTraversedObject: null,
|
||||
traversedPath: [],
|
||||
value: object
|
||||
};
|
||||
};
|
||||
|
||||
// Strip properties from object that are not present in the subset. Useful for
|
||||
// printing the diff for toMatchObject() without adding unrelated noise.
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
exports.getPath = getPath;
|
||||
const getObjectSubset = (
|
||||
object,
|
||||
subset,
|
||||
customTesters = [],
|
||||
seenReferences = new WeakMap()
|
||||
) => {
|
||||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
|
||||
if (Array.isArray(object)) {
|
||||
if (Array.isArray(subset) && subset.length === object.length) {
|
||||
// The map method returns correct subclass of subset.
|
||||
return subset.map((sub, i) =>
|
||||
getObjectSubset(object[i], sub, customTesters)
|
||||
);
|
||||
}
|
||||
} else if (object instanceof Date) {
|
||||
return object;
|
||||
} else if (isObject(object) && isObject(subset)) {
|
||||
if (
|
||||
(0, _jasmineUtils.equals)(object, subset, [
|
||||
...customTesters,
|
||||
iterableEquality,
|
||||
subsetEquality
|
||||
])
|
||||
) {
|
||||
// Avoid unnecessary copy which might return Object instead of subclass.
|
||||
return subset;
|
||||
}
|
||||
const trimmed = {};
|
||||
seenReferences.set(object, trimmed);
|
||||
getObjectKeys(object)
|
||||
.filter(key => hasPropertyInObject(subset, key))
|
||||
.forEach(key => {
|
||||
trimmed[key] = seenReferences.has(object[key])
|
||||
? seenReferences.get(object[key])
|
||||
: getObjectSubset(
|
||||
object[key],
|
||||
subset[key],
|
||||
customTesters,
|
||||
seenReferences
|
||||
);
|
||||
});
|
||||
if (getObjectKeys(trimmed).length > 0) {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
exports.getObjectSubset = getObjectSubset;
|
||||
const IteratorSymbol = Symbol.iterator;
|
||||
const hasIterator = object => !!(object != null && object[IteratorSymbol]);
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
const iterableEquality = (
|
||||
a,
|
||||
b,
|
||||
customTesters = [] /* eslint-enable @typescript-eslint/explicit-module-boundary-types */,
|
||||
aStack = [],
|
||||
bStack = []
|
||||
) => {
|
||||
if (
|
||||
typeof a !== 'object' ||
|
||||
typeof b !== 'object' ||
|
||||
Array.isArray(a) ||
|
||||
Array.isArray(b) ||
|
||||
!hasIterator(a) ||
|
||||
!hasIterator(b)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
if (a.constructor !== b.constructor) {
|
||||
return false;
|
||||
}
|
||||
let length = aStack.length;
|
||||
while (length--) {
|
||||
// Linear search. Performance is inversely proportional to the number of
|
||||
// unique nested structures.
|
||||
// circular references at same depth are equal
|
||||
// circular reference is not equal to non-circular one
|
||||
if (aStack[length] === a) {
|
||||
return bStack[length] === b;
|
||||
}
|
||||
}
|
||||
aStack.push(a);
|
||||
bStack.push(b);
|
||||
const iterableEqualityWithStack = (a, b) =>
|
||||
iterableEquality(
|
||||
a,
|
||||
b,
|
||||
[...filteredCustomTesters],
|
||||
[...aStack],
|
||||
[...bStack]
|
||||
);
|
||||
|
||||
// Replace any instance of iterableEquality with the new
|
||||
// iterableEqualityWithStack so we can do circular detection
|
||||
const filteredCustomTesters = [
|
||||
...customTesters.filter(t => t !== iterableEquality),
|
||||
iterableEqualityWithStack
|
||||
];
|
||||
if (a.size !== undefined) {
|
||||
if (a.size !== b.size) {
|
||||
return false;
|
||||
} else if (
|
||||
(0, _jasmineUtils.isA)('Set', a) ||
|
||||
(0, _immutableUtils.isImmutableUnorderedSet)(a)
|
||||
) {
|
||||
let allFound = true;
|
||||
for (const aValue of a) {
|
||||
if (!b.has(aValue)) {
|
||||
let has = false;
|
||||
for (const bValue of b) {
|
||||
const isEqual = (0, _jasmineUtils.equals)(
|
||||
aValue,
|
||||
bValue,
|
||||
filteredCustomTesters
|
||||
);
|
||||
if (isEqual === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the first value from the stack of traversed values.
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
return allFound;
|
||||
} else if (
|
||||
(0, _jasmineUtils.isA)('Map', a) ||
|
||||
(0, _immutableUtils.isImmutableUnorderedKeyed)(a)
|
||||
) {
|
||||
let allFound = true;
|
||||
for (const aEntry of a) {
|
||||
if (
|
||||
!b.has(aEntry[0]) ||
|
||||
!(0, _jasmineUtils.equals)(
|
||||
aEntry[1],
|
||||
b.get(aEntry[0]),
|
||||
filteredCustomTesters
|
||||
)
|
||||
) {
|
||||
let has = false;
|
||||
for (const bEntry of b) {
|
||||
const matchedKey = (0, _jasmineUtils.equals)(
|
||||
aEntry[0],
|
||||
bEntry[0],
|
||||
filteredCustomTesters
|
||||
);
|
||||
let matchedValue = false;
|
||||
if (matchedKey === true) {
|
||||
matchedValue = (0, _jasmineUtils.equals)(
|
||||
aEntry[1],
|
||||
bEntry[1],
|
||||
filteredCustomTesters
|
||||
);
|
||||
}
|
||||
if (matchedValue === true) {
|
||||
has = true;
|
||||
}
|
||||
}
|
||||
if (has === false) {
|
||||
allFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the first value from the stack of traversed values.
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
return allFound;
|
||||
}
|
||||
}
|
||||
const bIterator = b[IteratorSymbol]();
|
||||
for (const aValue of a) {
|
||||
const nextB = bIterator.next();
|
||||
if (
|
||||
nextB.done ||
|
||||
!(0, _jasmineUtils.equals)(aValue, nextB.value, filteredCustomTesters)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!bIterator.next().done) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!(0, _immutableUtils.isImmutableList)(a) &&
|
||||
!(0, _immutableUtils.isImmutableOrderedKeyed)(a) &&
|
||||
!(0, _immutableUtils.isImmutableOrderedSet)(a) &&
|
||||
!(0, _immutableUtils.isImmutableRecord)(a)
|
||||
) {
|
||||
const aEntries = Object.entries(a);
|
||||
const bEntries = Object.entries(b);
|
||||
if (!(0, _jasmineUtils.equals)(aEntries, bEntries)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the first value from the stack of traversed values.
|
||||
aStack.pop();
|
||||
bStack.pop();
|
||||
return true;
|
||||
};
|
||||
exports.iterableEquality = iterableEquality;
|
||||
const isObject = a => a !== null && typeof a === 'object';
|
||||
const isObjectWithKeys = a =>
|
||||
isObject(a) &&
|
||||
!(a instanceof Error) &&
|
||||
!(a instanceof Array) &&
|
||||
!(a instanceof Date);
|
||||
const subsetEquality = (object, subset, customTesters = []) => {
|
||||
const filteredCustomTesters = customTesters.filter(t => t !== subsetEquality);
|
||||
|
||||
// subsetEquality needs to keep track of the references
|
||||
// it has already visited to avoid infinite loops in case
|
||||
// there are circular references in the subset passed to it.
|
||||
const subsetEqualityWithContext =
|
||||
(seenReferences = new WeakMap()) =>
|
||||
(object, subset) => {
|
||||
if (!isObjectWithKeys(subset)) {
|
||||
return undefined;
|
||||
}
|
||||
return getObjectKeys(subset).every(key => {
|
||||
if (isObjectWithKeys(subset[key])) {
|
||||
if (seenReferences.has(subset[key])) {
|
||||
return (0, _jasmineUtils.equals)(
|
||||
object[key],
|
||||
subset[key],
|
||||
filteredCustomTesters
|
||||
);
|
||||
}
|
||||
seenReferences.set(subset[key], true);
|
||||
}
|
||||
const result =
|
||||
object != null &&
|
||||
hasPropertyInObject(object, key) &&
|
||||
(0, _jasmineUtils.equals)(object[key], subset[key], [
|
||||
...filteredCustomTesters,
|
||||
subsetEqualityWithContext(seenReferences)
|
||||
]);
|
||||
// The main goal of using seenReference is to avoid circular node on tree.
|
||||
// It will only happen within a parent and its child, not a node and nodes next to it (same level)
|
||||
// We should keep the reference for a parent and its child only
|
||||
// Thus we should delete the reference immediately so that it doesn't interfere
|
||||
// other nodes within the same level on tree.
|
||||
seenReferences.delete(subset[key]);
|
||||
return result;
|
||||
});
|
||||
};
|
||||
return subsetEqualityWithContext()(object, subset);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
exports.subsetEquality = subsetEquality;
|
||||
const typeEquality = (a, b) => {
|
||||
if (
|
||||
a == null ||
|
||||
b == null ||
|
||||
a.constructor === b.constructor ||
|
||||
// Since Jest globals are different from Node globals,
|
||||
// constructors are different even between arrays when comparing properties of mock objects.
|
||||
// Both of them should be able to compare correctly when they are array-to-array.
|
||||
// https://github.com/jestjs/jest/issues/2549
|
||||
(Array.isArray(a) && Array.isArray(b))
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.typeEquality = typeEquality;
|
||||
const arrayBufferEquality = (a, b) => {
|
||||
if (!(a instanceof ArrayBuffer) || !(b instanceof ArrayBuffer)) {
|
||||
return undefined;
|
||||
}
|
||||
const dataViewA = new DataView(a);
|
||||
const dataViewB = new DataView(b);
|
||||
|
||||
// Buffers are not equal when they do not have the same byte length
|
||||
if (dataViewA.byteLength !== dataViewB.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if every byte value is equal to each other
|
||||
for (let i = 0; i < dataViewA.byteLength; i++) {
|
||||
if (dataViewA.getUint8(i) !== dataViewB.getUint8(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
exports.arrayBufferEquality = arrayBufferEquality;
|
||||
const sparseArrayEquality = (a, b, customTesters = []) => {
|
||||
if (!Array.isArray(a) || !Array.isArray(b)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// A sparse array [, , 1] will have keys ["2"] whereas [undefined, undefined, 1] will have keys ["0", "1", "2"]
|
||||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
return (
|
||||
(0, _jasmineUtils.equals)(
|
||||
a,
|
||||
b,
|
||||
customTesters.filter(t => t !== sparseArrayEquality),
|
||||
true
|
||||
) && (0, _jasmineUtils.equals)(aKeys, bKeys)
|
||||
);
|
||||
};
|
||||
exports.sparseArrayEquality = sparseArrayEquality;
|
||||
const partition = (items, predicate) => {
|
||||
const result = [[], []];
|
||||
items.forEach(item => result[predicate(item) ? 0 : 1].push(item));
|
||||
return result;
|
||||
};
|
||||
exports.partition = partition;
|
||||
const pathAsArray = propertyPath => {
|
||||
const properties = [];
|
||||
if (propertyPath === '') {
|
||||
properties.push('');
|
||||
return properties;
|
||||
}
|
||||
|
||||
// will match everything that's not a dot or a bracket, and "" for consecutive dots.
|
||||
const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g');
|
||||
|
||||
// Because the regex won't match a dot in the beginning of the path, if present.
|
||||
if (propertyPath[0] === '.') {
|
||||
properties.push('');
|
||||
}
|
||||
propertyPath.replace(pattern, match => {
|
||||
properties.push(match);
|
||||
return match;
|
||||
});
|
||||
return properties;
|
||||
};
|
||||
|
||||
// Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
|
||||
exports.pathAsArray = pathAsArray;
|
||||
const isError = value => {
|
||||
switch (Object.prototype.toString.call(value)) {
|
||||
case '[object Error]':
|
||||
case '[object Exception]':
|
||||
case '[object DOMException]':
|
||||
return true;
|
||||
default:
|
||||
return value instanceof Error;
|
||||
}
|
||||
};
|
||||
exports.isError = isError;
|
||||
function emptyObject(obj) {
|
||||
return obj && typeof obj === 'object' ? !Object.keys(obj).length : false;
|
||||
}
|
||||
const MULTILINE_REGEXP = /[\r\n]/;
|
||||
const isOneline = (expected, received) =>
|
||||
typeof expected === 'string' &&
|
||||
typeof received === 'string' &&
|
||||
(!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
|
||||
exports.isOneline = isOneline;
|
35
backend/apis/nodejs/node_modules/@jest/expect-utils/package.json
generated
vendored
Normal file
35
backend/apis/nodejs/node_modules/@jest/expect-utils/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@jest/expect-utils",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/expect-utils"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-get-type": "^29.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsd/typescript": "^5.0.4",
|
||||
"immutable": "^4.0.0",
|
||||
"jest-matcher-utils": "^29.7.0",
|
||||
"tsd-lite": "^0.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/expect/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/expect/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
5
backend/apis/nodejs/node_modules/@jest/expect/README.md
generated
vendored
Normal file
5
backend/apis/nodejs/node_modules/@jest/expect/README.md
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# @jest/expect
|
||||
|
||||
This package extends `expect` library with `jest-snapshot` matchers. It exports `jestExpect` object, which can be used as standalone replacement of `expect`.
|
||||
|
||||
The `jestExpect` function used in [Jest](https://jestjs.io/). You can find its documentation [on Jest's website](https://jestjs.io/docs/expect).
|
68
backend/apis/nodejs/node_modules/@jest/expect/build/index.d.ts
generated
vendored
Normal file
68
backend/apis/nodejs/node_modules/@jest/expect/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type {addSerializer} from 'jest-snapshot';
|
||||
import {AsymmetricMatchers} from 'expect';
|
||||
import type {BaseExpect} from 'expect';
|
||||
import {MatcherContext} from 'expect';
|
||||
import {MatcherFunction} from 'expect';
|
||||
import {MatcherFunctionWithContext} from 'expect';
|
||||
import {Matchers} from 'expect';
|
||||
import {MatcherState} from 'expect';
|
||||
import {MatcherUtils} from 'expect';
|
||||
import type {SnapshotMatchers} from 'jest-snapshot';
|
||||
|
||||
export {AsymmetricMatchers};
|
||||
|
||||
declare type Inverse<Matchers> = {
|
||||
/**
|
||||
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
|
||||
*/
|
||||
not: Matchers;
|
||||
};
|
||||
|
||||
export declare type JestExpect = {
|
||||
<T = unknown>(actual: T): JestMatchers<void, T> &
|
||||
Inverse<JestMatchers<void, T>> &
|
||||
PromiseMatchers<T>;
|
||||
addSnapshotSerializer: typeof addSerializer;
|
||||
} & BaseExpect &
|
||||
AsymmetricMatchers &
|
||||
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
|
||||
|
||||
export declare const jestExpect: JestExpect;
|
||||
|
||||
declare type JestMatchers<R extends void | Promise<void>, T> = Matchers<R, T> &
|
||||
SnapshotMatchers<R, T>;
|
||||
|
||||
export {MatcherContext};
|
||||
|
||||
export {MatcherFunction};
|
||||
|
||||
export {MatcherFunctionWithContext};
|
||||
|
||||
export {Matchers};
|
||||
|
||||
export {MatcherState};
|
||||
|
||||
export {MatcherUtils};
|
||||
|
||||
declare type PromiseMatchers<T = unknown> = {
|
||||
/**
|
||||
* Unwraps the reason of a rejected promise so any other matcher can be chained.
|
||||
* If the promise is fulfilled the assertion fails.
|
||||
*/
|
||||
rejects: JestMatchers<Promise<void>, T> &
|
||||
Inverse<JestMatchers<Promise<void>, T>>;
|
||||
/**
|
||||
* Unwraps the value of a fulfilled promise so any other matcher can be chained.
|
||||
* If the promise is rejected the assertion fails.
|
||||
*/
|
||||
resolves: JestMatchers<Promise<void>, T> &
|
||||
Inverse<JestMatchers<Promise<void>, T>>;
|
||||
};
|
||||
|
||||
export {};
|
40
backend/apis/nodejs/node_modules/@jest/expect/build/index.js
generated
vendored
Normal file
40
backend/apis/nodejs/node_modules/@jest/expect/build/index.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.jestExpect = void 0;
|
||||
function _expect() {
|
||||
const data = require('expect');
|
||||
_expect = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestSnapshot() {
|
||||
const data = require('jest-snapshot');
|
||||
_jestSnapshot = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function createJestExpect() {
|
||||
_expect().expect.extend({
|
||||
toMatchInlineSnapshot: _jestSnapshot().toMatchInlineSnapshot,
|
||||
toMatchSnapshot: _jestSnapshot().toMatchSnapshot,
|
||||
toThrowErrorMatchingInlineSnapshot:
|
||||
_jestSnapshot().toThrowErrorMatchingInlineSnapshot,
|
||||
toThrowErrorMatchingSnapshot: _jestSnapshot().toThrowErrorMatchingSnapshot
|
||||
});
|
||||
_expect().expect.addSnapshotSerializer = _jestSnapshot().addSerializer;
|
||||
return _expect().expect;
|
||||
}
|
||||
const jestExpect = createJestExpect();
|
||||
exports.jestExpect = jestExpect;
|
1
backend/apis/nodejs/node_modules/@jest/expect/build/types.js
generated
vendored
Normal file
1
backend/apis/nodejs/node_modules/@jest/expect/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
34
backend/apis/nodejs/node_modules/@jest/expect/package.json
generated
vendored
Normal file
34
backend/apis/nodejs/node_modules/@jest/expect/package.json
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@jest/expect",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-expect"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"expect": "^29.7.0",
|
||||
"jest-snapshot": "^29.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsd/typescript": "^5.0.4",
|
||||
"tsd-lite": "^0.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/fake-timers/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/fake-timers/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
110
backend/apis/nodejs/node_modules/@jest/fake-timers/build/index.d.ts
generated
vendored
Normal file
110
backend/apis/nodejs/node_modules/@jest/fake-timers/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type {Config} from '@jest/types';
|
||||
import type {ModuleMocker} from 'jest-mock';
|
||||
import {StackTraceConfig} from 'jest-message-util';
|
||||
|
||||
declare type Callback = (...args: Array<unknown>) => void;
|
||||
|
||||
export declare class LegacyFakeTimers<TimerRef = unknown> {
|
||||
private _cancelledTicks;
|
||||
private readonly _config;
|
||||
private _disposed;
|
||||
private _fakeTimerAPIs;
|
||||
private _fakingTime;
|
||||
private _global;
|
||||
private _immediates;
|
||||
private readonly _maxLoops;
|
||||
private readonly _moduleMocker;
|
||||
private _now;
|
||||
private _ticks;
|
||||
private readonly _timerAPIs;
|
||||
private _timers;
|
||||
private _uuidCounter;
|
||||
private readonly _timerConfig;
|
||||
constructor({
|
||||
global,
|
||||
moduleMocker,
|
||||
timerConfig,
|
||||
config,
|
||||
maxLoops,
|
||||
}: {
|
||||
global: typeof globalThis;
|
||||
moduleMocker: ModuleMocker;
|
||||
timerConfig: TimerConfig<TimerRef>;
|
||||
config: StackTraceConfig;
|
||||
maxLoops?: number;
|
||||
});
|
||||
clearAllTimers(): void;
|
||||
dispose(): void;
|
||||
reset(): void;
|
||||
now(): number;
|
||||
runAllTicks(): void;
|
||||
runAllImmediates(): void;
|
||||
private _runImmediate;
|
||||
runAllTimers(): void;
|
||||
runOnlyPendingTimers(): void;
|
||||
advanceTimersToNextTimer(steps?: number): void;
|
||||
advanceTimersByTime(msToRun: number): void;
|
||||
runWithRealTimers(cb: Callback): void;
|
||||
useRealTimers(): void;
|
||||
useFakeTimers(): void;
|
||||
getTimerCount(): number;
|
||||
private _checkFakeTimers;
|
||||
private _createMocks;
|
||||
private _fakeClearTimer;
|
||||
private _fakeClearImmediate;
|
||||
private _fakeNextTick;
|
||||
private _fakeRequestAnimationFrame;
|
||||
private _fakeSetImmediate;
|
||||
private _fakeSetInterval;
|
||||
private _fakeSetTimeout;
|
||||
private _getNextTimerHandleAndExpiry;
|
||||
private _runTimerHandle;
|
||||
}
|
||||
|
||||
export declare class ModernFakeTimers {
|
||||
private _clock;
|
||||
private readonly _config;
|
||||
private _fakingTime;
|
||||
private readonly _global;
|
||||
private readonly _fakeTimers;
|
||||
constructor({
|
||||
global,
|
||||
config,
|
||||
}: {
|
||||
global: typeof globalThis;
|
||||
config: Config.ProjectConfig;
|
||||
});
|
||||
clearAllTimers(): void;
|
||||
dispose(): void;
|
||||
runAllTimers(): void;
|
||||
runAllTimersAsync(): Promise<void>;
|
||||
runOnlyPendingTimers(): void;
|
||||
runOnlyPendingTimersAsync(): Promise<void>;
|
||||
advanceTimersToNextTimer(steps?: number): void;
|
||||
advanceTimersToNextTimerAsync(steps?: number): Promise<void>;
|
||||
advanceTimersByTime(msToRun: number): void;
|
||||
advanceTimersByTimeAsync(msToRun: number): Promise<void>;
|
||||
runAllTicks(): void;
|
||||
useRealTimers(): void;
|
||||
useFakeTimers(fakeTimersConfig?: Config.FakeTimersConfig): void;
|
||||
reset(): void;
|
||||
setSystemTime(now?: number | Date): void;
|
||||
getRealSystemTime(): number;
|
||||
now(): number;
|
||||
getTimerCount(): number;
|
||||
private _checkFakeTimers;
|
||||
private _toSinonFakeTimersConfig;
|
||||
}
|
||||
|
||||
declare type TimerConfig<Ref> = {
|
||||
idToRef: (id: number) => Ref;
|
||||
refToId: (ref: Ref) => number | void;
|
||||
};
|
||||
|
||||
export {};
|
22
backend/apis/nodejs/node_modules/@jest/fake-timers/build/index.js
generated
vendored
Normal file
22
backend/apis/nodejs/node_modules/@jest/fake-timers/build/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'LegacyFakeTimers', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _legacyFakeTimers.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'ModernFakeTimers', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _modernFakeTimers.default;
|
||||
}
|
||||
});
|
||||
var _legacyFakeTimers = _interopRequireDefault(require('./legacyFakeTimers'));
|
||||
var _modernFakeTimers = _interopRequireDefault(require('./modernFakeTimers'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
545
backend/apis/nodejs/node_modules/@jest/fake-timers/build/legacyFakeTimers.js
generated
vendored
Normal file
545
backend/apis/nodejs/node_modules/@jest/fake-timers/build/legacyFakeTimers.js
generated
vendored
Normal file
@ -0,0 +1,545 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _util() {
|
||||
const data = require('util');
|
||||
_util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 */
|
||||
|
||||
const MS_IN_A_YEAR = 31536000000;
|
||||
class FakeTimers {
|
||||
_cancelledTicks;
|
||||
_config;
|
||||
_disposed;
|
||||
_fakeTimerAPIs;
|
||||
_fakingTime = false;
|
||||
_global;
|
||||
_immediates;
|
||||
_maxLoops;
|
||||
_moduleMocker;
|
||||
_now;
|
||||
_ticks;
|
||||
_timerAPIs;
|
||||
_timers;
|
||||
_uuidCounter;
|
||||
_timerConfig;
|
||||
constructor({global, moduleMocker, timerConfig, config, maxLoops}) {
|
||||
this._global = global;
|
||||
this._timerConfig = timerConfig;
|
||||
this._config = config;
|
||||
this._maxLoops = maxLoops || 100000;
|
||||
this._uuidCounter = 1;
|
||||
this._moduleMocker = moduleMocker;
|
||||
|
||||
// Store original timer APIs for future reference
|
||||
this._timerAPIs = {
|
||||
cancelAnimationFrame: global.cancelAnimationFrame,
|
||||
clearImmediate: global.clearImmediate,
|
||||
clearInterval: global.clearInterval,
|
||||
clearTimeout: global.clearTimeout,
|
||||
nextTick: global.process && global.process.nextTick,
|
||||
requestAnimationFrame: global.requestAnimationFrame,
|
||||
setImmediate: global.setImmediate,
|
||||
setInterval: global.setInterval,
|
||||
setTimeout: global.setTimeout
|
||||
};
|
||||
this._disposed = false;
|
||||
this.reset();
|
||||
}
|
||||
clearAllTimers() {
|
||||
this._immediates = [];
|
||||
this._timers.clear();
|
||||
}
|
||||
dispose() {
|
||||
this._disposed = true;
|
||||
this.clearAllTimers();
|
||||
}
|
||||
reset() {
|
||||
this._cancelledTicks = {};
|
||||
this._now = 0;
|
||||
this._ticks = [];
|
||||
this._immediates = [];
|
||||
this._timers = new Map();
|
||||
}
|
||||
now() {
|
||||
if (this._fakingTime) {
|
||||
return this._now;
|
||||
}
|
||||
return Date.now();
|
||||
}
|
||||
runAllTicks() {
|
||||
this._checkFakeTimers();
|
||||
// Only run a generous number of ticks and then bail.
|
||||
// This is just to help avoid recursive loops
|
||||
let i;
|
||||
for (i = 0; i < this._maxLoops; i++) {
|
||||
const tick = this._ticks.shift();
|
||||
if (tick === undefined) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(this._cancelledTicks, tick.uuid)
|
||||
) {
|
||||
// Callback may throw, so update the map prior calling.
|
||||
this._cancelledTicks[tick.uuid] = true;
|
||||
tick.callback();
|
||||
}
|
||||
}
|
||||
if (i === this._maxLoops) {
|
||||
throw new Error(
|
||||
`Ran ${this._maxLoops} ticks, and there are still more! ` +
|
||||
"Assuming we've hit an infinite recursion and bailing out..."
|
||||
);
|
||||
}
|
||||
}
|
||||
runAllImmediates() {
|
||||
this._checkFakeTimers();
|
||||
// Only run a generous number of immediates and then bail.
|
||||
let i;
|
||||
for (i = 0; i < this._maxLoops; i++) {
|
||||
const immediate = this._immediates.shift();
|
||||
if (immediate === undefined) {
|
||||
break;
|
||||
}
|
||||
this._runImmediate(immediate);
|
||||
}
|
||||
if (i === this._maxLoops) {
|
||||
throw new Error(
|
||||
`Ran ${this._maxLoops} immediates, and there are still more! Assuming ` +
|
||||
"we've hit an infinite recursion and bailing out..."
|
||||
);
|
||||
}
|
||||
}
|
||||
_runImmediate(immediate) {
|
||||
try {
|
||||
immediate.callback();
|
||||
} finally {
|
||||
this._fakeClearImmediate(immediate.uuid);
|
||||
}
|
||||
}
|
||||
runAllTimers() {
|
||||
this._checkFakeTimers();
|
||||
this.runAllTicks();
|
||||
this.runAllImmediates();
|
||||
|
||||
// Only run a generous number of timers and then bail.
|
||||
// This is just to help avoid recursive loops
|
||||
let i;
|
||||
for (i = 0; i < this._maxLoops; i++) {
|
||||
const nextTimerHandleAndExpiry = this._getNextTimerHandleAndExpiry();
|
||||
|
||||
// If there are no more timer handles, stop!
|
||||
if (nextTimerHandleAndExpiry === null) {
|
||||
break;
|
||||
}
|
||||
const [nextTimerHandle, expiry] = nextTimerHandleAndExpiry;
|
||||
this._now = expiry;
|
||||
this._runTimerHandle(nextTimerHandle);
|
||||
|
||||
// Some of the immediate calls could be enqueued
|
||||
// during the previous handling of the timers, we should
|
||||
// run them as well.
|
||||
if (this._immediates.length) {
|
||||
this.runAllImmediates();
|
||||
}
|
||||
if (this._ticks.length) {
|
||||
this.runAllTicks();
|
||||
}
|
||||
}
|
||||
if (i === this._maxLoops) {
|
||||
throw new Error(
|
||||
`Ran ${this._maxLoops} timers, and there are still more! ` +
|
||||
"Assuming we've hit an infinite recursion and bailing out..."
|
||||
);
|
||||
}
|
||||
}
|
||||
runOnlyPendingTimers() {
|
||||
// We need to hold the current shape of `this._timers` because existing
|
||||
// timers can add new ones to the map and hence would run more than necessary.
|
||||
// See https://github.com/jestjs/jest/pull/4608 for details
|
||||
const timerEntries = Array.from(this._timers.entries());
|
||||
this._checkFakeTimers();
|
||||
this._immediates.forEach(this._runImmediate, this);
|
||||
timerEntries
|
||||
.sort(([, left], [, right]) => left.expiry - right.expiry)
|
||||
.forEach(([timerHandle, timer]) => {
|
||||
this._now = timer.expiry;
|
||||
this._runTimerHandle(timerHandle);
|
||||
});
|
||||
}
|
||||
advanceTimersToNextTimer(steps = 1) {
|
||||
if (steps < 1) {
|
||||
return;
|
||||
}
|
||||
const nextExpiry = Array.from(this._timers.values()).reduce(
|
||||
(minExpiry, timer) => {
|
||||
if (minExpiry === null || timer.expiry < minExpiry) return timer.expiry;
|
||||
return minExpiry;
|
||||
},
|
||||
null
|
||||
);
|
||||
if (nextExpiry !== null) {
|
||||
this.advanceTimersByTime(nextExpiry - this._now);
|
||||
this.advanceTimersToNextTimer(steps - 1);
|
||||
}
|
||||
}
|
||||
advanceTimersByTime(msToRun) {
|
||||
this._checkFakeTimers();
|
||||
// Only run a generous number of timers and then bail.
|
||||
// This is just to help avoid recursive loops
|
||||
let i;
|
||||
for (i = 0; i < this._maxLoops; i++) {
|
||||
const timerHandleAndExpiry = this._getNextTimerHandleAndExpiry();
|
||||
|
||||
// If there are no more timer handles, stop!
|
||||
if (timerHandleAndExpiry === null) {
|
||||
break;
|
||||
}
|
||||
const [timerHandle, nextTimerExpiry] = timerHandleAndExpiry;
|
||||
if (this._now + msToRun < nextTimerExpiry) {
|
||||
// There are no timers between now and the target we're running to
|
||||
break;
|
||||
} else {
|
||||
msToRun -= nextTimerExpiry - this._now;
|
||||
this._now = nextTimerExpiry;
|
||||
this._runTimerHandle(timerHandle);
|
||||
}
|
||||
}
|
||||
|
||||
// Advance the clock by whatever time we still have left to run
|
||||
this._now += msToRun;
|
||||
if (i === this._maxLoops) {
|
||||
throw new Error(
|
||||
`Ran ${this._maxLoops} timers, and there are still more! ` +
|
||||
"Assuming we've hit an infinite recursion and bailing out..."
|
||||
);
|
||||
}
|
||||
}
|
||||
runWithRealTimers(cb) {
|
||||
const prevClearImmediate = this._global.clearImmediate;
|
||||
const prevClearInterval = this._global.clearInterval;
|
||||
const prevClearTimeout = this._global.clearTimeout;
|
||||
const prevNextTick = this._global.process.nextTick;
|
||||
const prevSetImmediate = this._global.setImmediate;
|
||||
const prevSetInterval = this._global.setInterval;
|
||||
const prevSetTimeout = this._global.setTimeout;
|
||||
this.useRealTimers();
|
||||
let cbErr = null;
|
||||
let errThrown = false;
|
||||
try {
|
||||
cb();
|
||||
} catch (e) {
|
||||
errThrown = true;
|
||||
cbErr = e;
|
||||
}
|
||||
this._global.clearImmediate = prevClearImmediate;
|
||||
this._global.clearInterval = prevClearInterval;
|
||||
this._global.clearTimeout = prevClearTimeout;
|
||||
this._global.process.nextTick = prevNextTick;
|
||||
this._global.setImmediate = prevSetImmediate;
|
||||
this._global.setInterval = prevSetInterval;
|
||||
this._global.setTimeout = prevSetTimeout;
|
||||
if (errThrown) {
|
||||
throw cbErr;
|
||||
}
|
||||
}
|
||||
useRealTimers() {
|
||||
const global = this._global;
|
||||
if (typeof global.cancelAnimationFrame === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'cancelAnimationFrame',
|
||||
this._timerAPIs.cancelAnimationFrame
|
||||
);
|
||||
}
|
||||
if (typeof global.clearImmediate === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearImmediate',
|
||||
this._timerAPIs.clearImmediate
|
||||
);
|
||||
}
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearInterval',
|
||||
this._timerAPIs.clearInterval
|
||||
);
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearTimeout',
|
||||
this._timerAPIs.clearTimeout
|
||||
);
|
||||
if (typeof global.requestAnimationFrame === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'requestAnimationFrame',
|
||||
this._timerAPIs.requestAnimationFrame
|
||||
);
|
||||
}
|
||||
if (typeof global.setImmediate === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setImmediate',
|
||||
this._timerAPIs.setImmediate
|
||||
);
|
||||
}
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setInterval',
|
||||
this._timerAPIs.setInterval
|
||||
);
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setTimeout',
|
||||
this._timerAPIs.setTimeout
|
||||
);
|
||||
global.process.nextTick = this._timerAPIs.nextTick;
|
||||
this._fakingTime = false;
|
||||
}
|
||||
useFakeTimers() {
|
||||
this._createMocks();
|
||||
const global = this._global;
|
||||
if (typeof global.cancelAnimationFrame === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'cancelAnimationFrame',
|
||||
this._fakeTimerAPIs.cancelAnimationFrame
|
||||
);
|
||||
}
|
||||
if (typeof global.clearImmediate === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearImmediate',
|
||||
this._fakeTimerAPIs.clearImmediate
|
||||
);
|
||||
}
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearInterval',
|
||||
this._fakeTimerAPIs.clearInterval
|
||||
);
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'clearTimeout',
|
||||
this._fakeTimerAPIs.clearTimeout
|
||||
);
|
||||
if (typeof global.requestAnimationFrame === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'requestAnimationFrame',
|
||||
this._fakeTimerAPIs.requestAnimationFrame
|
||||
);
|
||||
}
|
||||
if (typeof global.setImmediate === 'function') {
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setImmediate',
|
||||
this._fakeTimerAPIs.setImmediate
|
||||
);
|
||||
}
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setInterval',
|
||||
this._fakeTimerAPIs.setInterval
|
||||
);
|
||||
(0, _jestUtil().setGlobal)(
|
||||
global,
|
||||
'setTimeout',
|
||||
this._fakeTimerAPIs.setTimeout
|
||||
);
|
||||
global.process.nextTick = this._fakeTimerAPIs.nextTick;
|
||||
this._fakingTime = true;
|
||||
}
|
||||
getTimerCount() {
|
||||
this._checkFakeTimers();
|
||||
return this._timers.size + this._immediates.length + this._ticks.length;
|
||||
}
|
||||
_checkFakeTimers() {
|
||||
if (!this._fakingTime) {
|
||||
this._global.console.warn(
|
||||
'A function to advance timers was called but the timers APIs are not mocked ' +
|
||||
'with fake timers. Call `jest.useFakeTimers({legacyFakeTimers: true})` ' +
|
||||
'in this test file or enable fake timers for all tests by setting ' +
|
||||
"{'enableGlobally': true, 'legacyFakeTimers': true} in " +
|
||||
`Jest configuration file.\nStack Trace:\n${(0,
|
||||
_jestMessageUtil().formatStackTrace)(
|
||||
new Error().stack,
|
||||
this._config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
_createMocks() {
|
||||
const fn = implementation => this._moduleMocker.fn(implementation);
|
||||
const promisifiableFakeSetTimeout = fn(this._fakeSetTimeout.bind(this));
|
||||
// @ts-expect-error: no index
|
||||
promisifiableFakeSetTimeout[_util().promisify.custom] = (delay, arg) =>
|
||||
new Promise(resolve => promisifiableFakeSetTimeout(resolve, delay, arg));
|
||||
this._fakeTimerAPIs = {
|
||||
cancelAnimationFrame: fn(this._fakeClearTimer.bind(this)),
|
||||
clearImmediate: fn(this._fakeClearImmediate.bind(this)),
|
||||
clearInterval: fn(this._fakeClearTimer.bind(this)),
|
||||
clearTimeout: fn(this._fakeClearTimer.bind(this)),
|
||||
nextTick: fn(this._fakeNextTick.bind(this)),
|
||||
requestAnimationFrame: fn(this._fakeRequestAnimationFrame.bind(this)),
|
||||
setImmediate: fn(this._fakeSetImmediate.bind(this)),
|
||||
setInterval: fn(this._fakeSetInterval.bind(this)),
|
||||
setTimeout: promisifiableFakeSetTimeout
|
||||
};
|
||||
}
|
||||
_fakeClearTimer(timerRef) {
|
||||
const uuid = this._timerConfig.refToId(timerRef);
|
||||
if (uuid) {
|
||||
this._timers.delete(String(uuid));
|
||||
}
|
||||
}
|
||||
_fakeClearImmediate(uuid) {
|
||||
this._immediates = this._immediates.filter(
|
||||
immediate => immediate.uuid !== uuid
|
||||
);
|
||||
}
|
||||
_fakeNextTick(callback, ...args) {
|
||||
if (this._disposed) {
|
||||
return;
|
||||
}
|
||||
const uuid = String(this._uuidCounter++);
|
||||
this._ticks.push({
|
||||
callback: () => callback.apply(null, args),
|
||||
uuid
|
||||
});
|
||||
const cancelledTicks = this._cancelledTicks;
|
||||
this._timerAPIs.nextTick(() => {
|
||||
if (!Object.prototype.hasOwnProperty.call(cancelledTicks, uuid)) {
|
||||
// Callback may throw, so update the map prior calling.
|
||||
cancelledTicks[uuid] = true;
|
||||
callback.apply(null, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
_fakeRequestAnimationFrame(callback) {
|
||||
return this._fakeSetTimeout(() => {
|
||||
// TODO: Use performance.now() once it's mocked
|
||||
callback(this._now);
|
||||
}, 1000 / 60);
|
||||
}
|
||||
_fakeSetImmediate(callback, ...args) {
|
||||
if (this._disposed) {
|
||||
return null;
|
||||
}
|
||||
const uuid = String(this._uuidCounter++);
|
||||
this._immediates.push({
|
||||
callback: () => callback.apply(null, args),
|
||||
uuid
|
||||
});
|
||||
this._timerAPIs.setImmediate(() => {
|
||||
if (!this._disposed) {
|
||||
if (this._immediates.find(x => x.uuid === uuid)) {
|
||||
try {
|
||||
callback.apply(null, args);
|
||||
} finally {
|
||||
this._fakeClearImmediate(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return uuid;
|
||||
}
|
||||
_fakeSetInterval(callback, intervalDelay, ...args) {
|
||||
if (this._disposed) {
|
||||
return null;
|
||||
}
|
||||
if (intervalDelay == null) {
|
||||
intervalDelay = 0;
|
||||
}
|
||||
const uuid = this._uuidCounter++;
|
||||
this._timers.set(String(uuid), {
|
||||
callback: () => callback.apply(null, args),
|
||||
expiry: this._now + intervalDelay,
|
||||
interval: intervalDelay,
|
||||
type: 'interval'
|
||||
});
|
||||
return this._timerConfig.idToRef(uuid);
|
||||
}
|
||||
_fakeSetTimeout(callback, delay, ...args) {
|
||||
if (this._disposed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
delay = Number(delay) | 0;
|
||||
const uuid = this._uuidCounter++;
|
||||
this._timers.set(String(uuid), {
|
||||
callback: () => callback.apply(null, args),
|
||||
expiry: this._now + delay,
|
||||
interval: undefined,
|
||||
type: 'timeout'
|
||||
});
|
||||
return this._timerConfig.idToRef(uuid);
|
||||
}
|
||||
_getNextTimerHandleAndExpiry() {
|
||||
let nextTimerHandle = null;
|
||||
let soonestTime = MS_IN_A_YEAR;
|
||||
this._timers.forEach((timer, uuid) => {
|
||||
if (timer.expiry < soonestTime) {
|
||||
soonestTime = timer.expiry;
|
||||
nextTimerHandle = uuid;
|
||||
}
|
||||
});
|
||||
if (nextTimerHandle === null) {
|
||||
return null;
|
||||
}
|
||||
return [nextTimerHandle, soonestTime];
|
||||
}
|
||||
_runTimerHandle(timerHandle) {
|
||||
const timer = this._timers.get(timerHandle);
|
||||
if (!timer) {
|
||||
// Timer has been cleared - we'll hit this when a timer is cleared within
|
||||
// another timer in runOnlyPendingTimers
|
||||
return;
|
||||
}
|
||||
switch (timer.type) {
|
||||
case 'timeout':
|
||||
this._timers.delete(timerHandle);
|
||||
timer.callback();
|
||||
break;
|
||||
case 'interval':
|
||||
timer.expiry = this._now + (timer.interval || 0);
|
||||
timer.callback();
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected timer type: ${timer.type}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = FakeTimers;
|
191
backend/apis/nodejs/node_modules/@jest/fake-timers/build/modernFakeTimers.js
generated
vendored
Normal file
191
backend/apis/nodejs/node_modules/@jest/fake-timers/build/modernFakeTimers.js
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _fakeTimers() {
|
||||
const data = require('@sinonjs/fake-timers');
|
||||
_fakeTimers = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
class FakeTimers {
|
||||
_clock;
|
||||
_config;
|
||||
_fakingTime;
|
||||
_global;
|
||||
_fakeTimers;
|
||||
constructor({global, config}) {
|
||||
this._global = global;
|
||||
this._config = config;
|
||||
this._fakingTime = false;
|
||||
this._fakeTimers = (0, _fakeTimers().withGlobal)(global);
|
||||
}
|
||||
clearAllTimers() {
|
||||
if (this._fakingTime) {
|
||||
this._clock.reset();
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
this.useRealTimers();
|
||||
}
|
||||
runAllTimers() {
|
||||
if (this._checkFakeTimers()) {
|
||||
this._clock.runAll();
|
||||
}
|
||||
}
|
||||
async runAllTimersAsync() {
|
||||
if (this._checkFakeTimers()) {
|
||||
await this._clock.runAllAsync();
|
||||
}
|
||||
}
|
||||
runOnlyPendingTimers() {
|
||||
if (this._checkFakeTimers()) {
|
||||
this._clock.runToLast();
|
||||
}
|
||||
}
|
||||
async runOnlyPendingTimersAsync() {
|
||||
if (this._checkFakeTimers()) {
|
||||
await this._clock.runToLastAsync();
|
||||
}
|
||||
}
|
||||
advanceTimersToNextTimer(steps = 1) {
|
||||
if (this._checkFakeTimers()) {
|
||||
for (let i = steps; i > 0; i--) {
|
||||
this._clock.next();
|
||||
// Fire all timers at this point: https://github.com/sinonjs/fake-timers/issues/250
|
||||
this._clock.tick(0);
|
||||
if (this._clock.countTimers() === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async advanceTimersToNextTimerAsync(steps = 1) {
|
||||
if (this._checkFakeTimers()) {
|
||||
for (let i = steps; i > 0; i--) {
|
||||
await this._clock.nextAsync();
|
||||
// Fire all timers at this point: https://github.com/sinonjs/fake-timers/issues/250
|
||||
await this._clock.tickAsync(0);
|
||||
if (this._clock.countTimers() === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
advanceTimersByTime(msToRun) {
|
||||
if (this._checkFakeTimers()) {
|
||||
this._clock.tick(msToRun);
|
||||
}
|
||||
}
|
||||
async advanceTimersByTimeAsync(msToRun) {
|
||||
if (this._checkFakeTimers()) {
|
||||
await this._clock.tickAsync(msToRun);
|
||||
}
|
||||
}
|
||||
runAllTicks() {
|
||||
if (this._checkFakeTimers()) {
|
||||
// @ts-expect-error - doesn't exist?
|
||||
this._clock.runMicrotasks();
|
||||
}
|
||||
}
|
||||
useRealTimers() {
|
||||
if (this._fakingTime) {
|
||||
this._clock.uninstall();
|
||||
this._fakingTime = false;
|
||||
}
|
||||
}
|
||||
useFakeTimers(fakeTimersConfig) {
|
||||
if (this._fakingTime) {
|
||||
this._clock.uninstall();
|
||||
}
|
||||
this._clock = this._fakeTimers.install(
|
||||
this._toSinonFakeTimersConfig(fakeTimersConfig)
|
||||
);
|
||||
this._fakingTime = true;
|
||||
}
|
||||
reset() {
|
||||
if (this._checkFakeTimers()) {
|
||||
const {now} = this._clock;
|
||||
this._clock.reset();
|
||||
this._clock.setSystemTime(now);
|
||||
}
|
||||
}
|
||||
setSystemTime(now) {
|
||||
if (this._checkFakeTimers()) {
|
||||
this._clock.setSystemTime(now);
|
||||
}
|
||||
}
|
||||
getRealSystemTime() {
|
||||
return Date.now();
|
||||
}
|
||||
now() {
|
||||
if (this._fakingTime) {
|
||||
return this._clock.now;
|
||||
}
|
||||
return Date.now();
|
||||
}
|
||||
getTimerCount() {
|
||||
if (this._checkFakeTimers()) {
|
||||
return this._clock.countTimers();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
_checkFakeTimers() {
|
||||
if (!this._fakingTime) {
|
||||
this._global.console.warn(
|
||||
'A function to advance timers was called but the timers APIs are not replaced ' +
|
||||
'with fake timers. Call `jest.useFakeTimers()` in this test file or enable ' +
|
||||
"fake timers for all tests by setting 'fakeTimers': {'enableGlobally': true} " +
|
||||
`in Jest configuration file.\nStack Trace:\n${(0,
|
||||
_jestMessageUtil().formatStackTrace)(
|
||||
new Error().stack,
|
||||
this._config,
|
||||
{
|
||||
noStackTrace: false
|
||||
}
|
||||
)}`
|
||||
);
|
||||
}
|
||||
return this._fakingTime;
|
||||
}
|
||||
_toSinonFakeTimersConfig(fakeTimersConfig = {}) {
|
||||
fakeTimersConfig = {
|
||||
...this._config.fakeTimers,
|
||||
...fakeTimersConfig
|
||||
};
|
||||
const advanceTimeDelta =
|
||||
typeof fakeTimersConfig.advanceTimers === 'number'
|
||||
? fakeTimersConfig.advanceTimers
|
||||
: undefined;
|
||||
const toFake = new Set(Object.keys(this._fakeTimers.timers));
|
||||
fakeTimersConfig.doNotFake?.forEach(nameOfFakeableAPI => {
|
||||
toFake.delete(nameOfFakeableAPI);
|
||||
});
|
||||
return {
|
||||
advanceTimeDelta,
|
||||
loopLimit: fakeTimersConfig.timerLimit || 100_000,
|
||||
now: fakeTimersConfig.now ?? Date.now(),
|
||||
shouldAdvanceTime: Boolean(fakeTimersConfig.advanceTimers),
|
||||
shouldClearNativeTimers: true,
|
||||
toFake: Array.from(toFake)
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.default = FakeTimers;
|
38
backend/apis/nodejs/node_modules/@jest/fake-timers/package.json
generated
vendored
Normal file
38
backend/apis/nodejs/node_modules/@jest/fake-timers/package.json
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@jest/fake-timers",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-fake-timers"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/types": "^29.6.3",
|
||||
"@sinonjs/fake-timers": "^10.0.2",
|
||||
"@types/node": "*",
|
||||
"jest-message-util": "^29.7.0",
|
||||
"jest-mock": "^29.7.0",
|
||||
"jest-util": "^29.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "^29.7.0",
|
||||
"@types/sinonjs__fake-timers": "^8.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/globals/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/globals/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
71
backend/apis/nodejs/node_modules/@jest/globals/build/index.d.ts
generated
vendored
Normal file
71
backend/apis/nodejs/node_modules/@jest/globals/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { Jest } from '@jest/environment';
|
||||
import type { JestExpect } from '@jest/expect';
|
||||
import type { Global } from '@jest/types';
|
||||
import type { ClassLike, FunctionLike, Mock as JestMock, Mocked as JestMocked, MockedClass as JestMockedClass, MockedFunction as JestMockedFunction, MockedObject as JestMockedObject, Replaced as JestReplaced, Spied as JestSpied, SpiedClass as JestSpiedClass, SpiedFunction as JestSpiedFunction, SpiedGetter as JestSpiedGetter, SpiedSetter as JestSpiedSetter, UnknownFunction } from 'jest-mock';
|
||||
export declare const expect: JestExpect;
|
||||
export declare const it: Global.GlobalAdditions['it'];
|
||||
export declare const test: Global.GlobalAdditions['test'];
|
||||
export declare const fit: Global.GlobalAdditions['fit'];
|
||||
export declare const xit: Global.GlobalAdditions['xit'];
|
||||
export declare const xtest: Global.GlobalAdditions['xtest'];
|
||||
export declare const describe: Global.GlobalAdditions['describe'];
|
||||
export declare const xdescribe: Global.GlobalAdditions['xdescribe'];
|
||||
export declare const fdescribe: Global.GlobalAdditions['fdescribe'];
|
||||
export declare const beforeAll: Global.GlobalAdditions['beforeAll'];
|
||||
export declare const beforeEach: Global.GlobalAdditions['beforeEach'];
|
||||
export declare const afterEach: Global.GlobalAdditions['afterEach'];
|
||||
export declare const afterAll: Global.GlobalAdditions['afterAll'];
|
||||
declare const jest: Jest;
|
||||
declare namespace jest {
|
||||
/**
|
||||
* Constructs the type of a mock function, e.g. the return type of `jest.fn()`.
|
||||
*/
|
||||
type Mock<T extends FunctionLike = UnknownFunction> = JestMock<T>;
|
||||
/**
|
||||
* Wraps a class, function or object type with Jest mock type definitions.
|
||||
*/
|
||||
type Mocked<T extends object> = JestMocked<T>;
|
||||
/**
|
||||
* Wraps a class type with Jest mock type definitions.
|
||||
*/
|
||||
type MockedClass<T extends ClassLike> = JestMockedClass<T>;
|
||||
/**
|
||||
* Wraps a function type with Jest mock type definitions.
|
||||
*/
|
||||
type MockedFunction<T extends FunctionLike> = JestMockedFunction<T>;
|
||||
/**
|
||||
* Wraps an object type with Jest mock type definitions.
|
||||
*/
|
||||
type MockedObject<T extends object> = JestMockedObject<T>;
|
||||
/**
|
||||
* Constructs the type of a replaced property.
|
||||
*/
|
||||
type Replaced<T> = JestReplaced<T>;
|
||||
/**
|
||||
* Constructs the type of a spied class or function.
|
||||
*/
|
||||
type Spied<T extends ClassLike | FunctionLike> = JestSpied<T>;
|
||||
/**
|
||||
* Constructs the type of a spied class.
|
||||
*/
|
||||
type SpiedClass<T extends ClassLike> = JestSpiedClass<T>;
|
||||
/**
|
||||
* Constructs the type of a spied function.
|
||||
*/
|
||||
type SpiedFunction<T extends FunctionLike> = JestSpiedFunction<T>;
|
||||
/**
|
||||
* Constructs the type of a spied getter.
|
||||
*/
|
||||
type SpiedGetter<T> = JestSpiedGetter<T>;
|
||||
/**
|
||||
* Constructs the type of a spied setter.
|
||||
*/
|
||||
type SpiedSetter<T> = JestSpiedSetter<T>;
|
||||
}
|
||||
export { jest };
|
14
backend/apis/nodejs/node_modules/@jest/globals/build/index.js
generated
vendored
Normal file
14
backend/apis/nodejs/node_modules/@jest/globals/build/index.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
||||
throw new Error(
|
||||
'Do not import `@jest/globals` outside of the Jest test environment'
|
||||
);
|
32
backend/apis/nodejs/node_modules/@jest/globals/package.json
generated
vendored
Normal file
32
backend/apis/nodejs/node_modules/@jest/globals/package.json
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@jest/globals",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-globals"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/environment": "^29.7.0",
|
||||
"@jest/expect": "^29.7.0",
|
||||
"@jest/types": "^29.6.3",
|
||||
"jest-mock": "^29.7.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
21
backend/apis/nodejs/node_modules/@jest/reporters/LICENSE
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/@jest/reporters/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and 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.
|
BIN
backend/apis/nodejs/node_modules/@jest/reporters/assets/jest_logo.png
generated
vendored
Normal file
BIN
backend/apis/nodejs/node_modules/@jest/reporters/assets/jest_logo.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
48
backend/apis/nodejs/node_modules/@jest/reporters/build/BaseReporter.js
generated
vendored
Normal file
48
backend/apis/nodejs/node_modules/@jest/reporters/build/BaseReporter.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {remove: preRunMessageRemove} = _jestUtil().preRunMessage;
|
||||
class BaseReporter {
|
||||
_error;
|
||||
log(message) {
|
||||
process.stderr.write(`${message}\n`);
|
||||
}
|
||||
onRunStart(_results, _options) {
|
||||
preRunMessageRemove(process.stderr);
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
onTestCaseResult(_test, _testCaseResult) {}
|
||||
onTestResult(_test, _testResult, _results) {}
|
||||
onTestStart(_test) {}
|
||||
onRunComplete(_testContexts, _aggregatedResults) {}
|
||||
/* eslint-enable */
|
||||
|
||||
_setError(error) {
|
||||
this._error = error;
|
||||
}
|
||||
|
||||
// Return an error that occurred during reporting. This error will
|
||||
// define whether the test run was successful or failed.
|
||||
getLastError() {
|
||||
return this._error;
|
||||
}
|
||||
}
|
||||
exports.default = BaseReporter;
|
561
backend/apis/nodejs/node_modules/@jest/reporters/build/CoverageReporter.js
generated
vendored
Normal file
561
backend/apis/nodejs/node_modules/@jest/reporters/build/CoverageReporter.js
generated
vendored
Normal file
@ -0,0 +1,561 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _v8Coverage() {
|
||||
const data = require('@bcoe/v8-coverage');
|
||||
_v8Coverage = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _glob() {
|
||||
const data = _interopRequireDefault(require('glob'));
|
||||
_glob = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulLibCoverage() {
|
||||
const data = _interopRequireDefault(require('istanbul-lib-coverage'));
|
||||
_istanbulLibCoverage = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulLibReport() {
|
||||
const data = _interopRequireDefault(require('istanbul-lib-report'));
|
||||
_istanbulLibReport = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulLibSourceMaps() {
|
||||
const data = _interopRequireDefault(require('istanbul-lib-source-maps'));
|
||||
_istanbulLibSourceMaps = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulReports() {
|
||||
const data = _interopRequireDefault(require('istanbul-reports'));
|
||||
_istanbulReports = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _v8ToIstanbul() {
|
||||
const data = _interopRequireDefault(require('v8-to-istanbul'));
|
||||
_v8ToIstanbul = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestWorker() {
|
||||
const data = require('jest-worker');
|
||||
_jestWorker = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter'));
|
||||
var _getWatermarks = _interopRequireDefault(require('./getWatermarks'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const FAIL_COLOR = _chalk().default.bold.red;
|
||||
const RUNNING_TEST_COLOR = _chalk().default.bold.dim;
|
||||
class CoverageReporter extends _BaseReporter.default {
|
||||
_context;
|
||||
_coverageMap;
|
||||
_globalConfig;
|
||||
_sourceMapStore;
|
||||
_v8CoverageResults;
|
||||
static filename = __filename;
|
||||
constructor(globalConfig, context) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._coverageMap = _istanbulLibCoverage().default.createCoverageMap({});
|
||||
this._globalConfig = globalConfig;
|
||||
this._sourceMapStore =
|
||||
_istanbulLibSourceMaps().default.createSourceMapStore();
|
||||
this._v8CoverageResults = [];
|
||||
}
|
||||
onTestResult(_test, testResult) {
|
||||
if (testResult.v8Coverage) {
|
||||
this._v8CoverageResults.push(testResult.v8Coverage);
|
||||
return;
|
||||
}
|
||||
if (testResult.coverage) {
|
||||
this._coverageMap.merge(testResult.coverage);
|
||||
}
|
||||
}
|
||||
async onRunComplete(testContexts, aggregatedResults) {
|
||||
await this._addUntestedFiles(testContexts);
|
||||
const {map, reportContext} = await this._getCoverageResult();
|
||||
try {
|
||||
const coverageReporters = this._globalConfig.coverageReporters || [];
|
||||
if (!this._globalConfig.useStderr && coverageReporters.length < 1) {
|
||||
coverageReporters.push('text-summary');
|
||||
}
|
||||
coverageReporters.forEach(reporter => {
|
||||
let additionalOptions = {};
|
||||
if (Array.isArray(reporter)) {
|
||||
[reporter, additionalOptions] = reporter;
|
||||
}
|
||||
_istanbulReports()
|
||||
.default.create(reporter, {
|
||||
maxCols: process.stdout.columns || Infinity,
|
||||
...additionalOptions
|
||||
})
|
||||
.execute(reportContext);
|
||||
});
|
||||
aggregatedResults.coverageMap = map;
|
||||
} catch (e) {
|
||||
console.error(
|
||||
_chalk().default.red(`
|
||||
Failed to write coverage reports:
|
||||
ERROR: ${e.toString()}
|
||||
STACK: ${e.stack}
|
||||
`)
|
||||
);
|
||||
}
|
||||
this._checkThreshold(map);
|
||||
}
|
||||
async _addUntestedFiles(testContexts) {
|
||||
const files = [];
|
||||
testContexts.forEach(context => {
|
||||
const config = context.config;
|
||||
if (
|
||||
this._globalConfig.collectCoverageFrom &&
|
||||
this._globalConfig.collectCoverageFrom.length
|
||||
) {
|
||||
context.hasteFS
|
||||
.matchFilesWithGlob(
|
||||
this._globalConfig.collectCoverageFrom,
|
||||
config.rootDir
|
||||
)
|
||||
.forEach(filePath =>
|
||||
files.push({
|
||||
config,
|
||||
path: filePath
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
if (_jestUtil().isInteractive) {
|
||||
process.stderr.write(
|
||||
RUNNING_TEST_COLOR('Running coverage on untested files...')
|
||||
);
|
||||
}
|
||||
let worker;
|
||||
if (this._globalConfig.maxWorkers <= 1) {
|
||||
worker = require('./CoverageWorker');
|
||||
} else {
|
||||
worker = new (_jestWorker().Worker)(require.resolve('./CoverageWorker'), {
|
||||
enableWorkerThreads: this._globalConfig.workerThreads,
|
||||
exposedMethods: ['worker'],
|
||||
forkOptions: {
|
||||
serialization: 'json'
|
||||
},
|
||||
maxRetries: 2,
|
||||
numWorkers: this._globalConfig.maxWorkers
|
||||
});
|
||||
}
|
||||
const instrumentation = files.map(async fileObj => {
|
||||
const filename = fileObj.path;
|
||||
const config = fileObj.config;
|
||||
const hasCoverageData = this._v8CoverageResults.some(v8Res =>
|
||||
v8Res.some(innerRes => innerRes.result.url === filename)
|
||||
);
|
||||
if (
|
||||
!hasCoverageData &&
|
||||
!this._coverageMap.data[filename] &&
|
||||
'worker' in worker
|
||||
) {
|
||||
try {
|
||||
const result = await worker.worker({
|
||||
config,
|
||||
context: {
|
||||
changedFiles:
|
||||
this._context.changedFiles &&
|
||||
Array.from(this._context.changedFiles),
|
||||
sourcesRelatedToTestsInChangedFiles:
|
||||
this._context.sourcesRelatedToTestsInChangedFiles &&
|
||||
Array.from(this._context.sourcesRelatedToTestsInChangedFiles)
|
||||
},
|
||||
globalConfig: this._globalConfig,
|
||||
path: filename
|
||||
});
|
||||
if (result) {
|
||||
if (result.kind === 'V8Coverage') {
|
||||
this._v8CoverageResults.push([
|
||||
{
|
||||
codeTransformResult: undefined,
|
||||
result: result.result
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
this._coverageMap.addFileCoverage(result.coverage);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
_chalk().default.red(
|
||||
[
|
||||
`Failed to collect coverage from ${filename}`,
|
||||
`ERROR: ${error.message}`,
|
||||
`STACK: ${error.stack}`
|
||||
].join('\n')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
await Promise.all(instrumentation);
|
||||
} catch {
|
||||
// Do nothing; errors were reported earlier to the console.
|
||||
}
|
||||
if (_jestUtil().isInteractive) {
|
||||
(0, _jestUtil().clearLine)(process.stderr);
|
||||
}
|
||||
if (worker && 'end' in worker && typeof worker.end === 'function') {
|
||||
await worker.end();
|
||||
}
|
||||
}
|
||||
_checkThreshold(map) {
|
||||
const {coverageThreshold} = this._globalConfig;
|
||||
if (coverageThreshold) {
|
||||
function check(name, thresholds, actuals) {
|
||||
return ['statements', 'branches', 'lines', 'functions'].reduce(
|
||||
(errors, key) => {
|
||||
const actual = actuals[key].pct;
|
||||
const actualUncovered = actuals[key].total - actuals[key].covered;
|
||||
const threshold = thresholds[key];
|
||||
if (threshold !== undefined) {
|
||||
if (threshold < 0) {
|
||||
if (threshold * -1 < actualUncovered) {
|
||||
errors.push(
|
||||
`Jest: Uncovered count for ${key} (${actualUncovered}) ` +
|
||||
`exceeds ${name} threshold (${-1 * threshold})`
|
||||
);
|
||||
}
|
||||
} else if (actual < threshold) {
|
||||
errors.push(
|
||||
`Jest: "${name}" coverage threshold for ${key} (${threshold}%) not met: ${actual}%`
|
||||
);
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
const THRESHOLD_GROUP_TYPES = {
|
||||
GLOB: 'glob',
|
||||
GLOBAL: 'global',
|
||||
PATH: 'path'
|
||||
};
|
||||
const coveredFiles = map.files();
|
||||
const thresholdGroups = Object.keys(coverageThreshold);
|
||||
const groupTypeByThresholdGroup = {};
|
||||
const filesByGlob = {};
|
||||
const coveredFilesSortedIntoThresholdGroup = coveredFiles.reduce(
|
||||
(files, file) => {
|
||||
const pathOrGlobMatches = thresholdGroups.reduce(
|
||||
(agg, thresholdGroup) => {
|
||||
// Preserve trailing slash, but not required if root dir
|
||||
// See https://github.com/jestjs/jest/issues/12703
|
||||
const resolvedThresholdGroup = path().resolve(thresholdGroup);
|
||||
const suffix =
|
||||
(thresholdGroup.endsWith(path().sep) ||
|
||||
(process.platform === 'win32' &&
|
||||
thresholdGroup.endsWith('/'))) &&
|
||||
!resolvedThresholdGroup.endsWith(path().sep)
|
||||
? path().sep
|
||||
: '';
|
||||
const absoluteThresholdGroup = `${resolvedThresholdGroup}${suffix}`;
|
||||
|
||||
// The threshold group might be a path:
|
||||
|
||||
if (file.indexOf(absoluteThresholdGroup) === 0) {
|
||||
groupTypeByThresholdGroup[thresholdGroup] =
|
||||
THRESHOLD_GROUP_TYPES.PATH;
|
||||
return agg.concat([[file, thresholdGroup]]);
|
||||
}
|
||||
|
||||
// If the threshold group is not a path it might be a glob:
|
||||
|
||||
// Note: glob.sync is slow. By memoizing the files matching each glob
|
||||
// (rather than recalculating it for each covered file) we save a tonne
|
||||
// of execution time.
|
||||
if (filesByGlob[absoluteThresholdGroup] === undefined) {
|
||||
filesByGlob[absoluteThresholdGroup] = _glob()
|
||||
.default.sync(absoluteThresholdGroup)
|
||||
.map(filePath => path().resolve(filePath));
|
||||
}
|
||||
if (filesByGlob[absoluteThresholdGroup].indexOf(file) > -1) {
|
||||
groupTypeByThresholdGroup[thresholdGroup] =
|
||||
THRESHOLD_GROUP_TYPES.GLOB;
|
||||
return agg.concat([[file, thresholdGroup]]);
|
||||
}
|
||||
return agg;
|
||||
},
|
||||
[]
|
||||
);
|
||||
if (pathOrGlobMatches.length > 0) {
|
||||
return files.concat(pathOrGlobMatches);
|
||||
}
|
||||
|
||||
// Neither a glob or a path? Toss it in global if there's a global threshold:
|
||||
if (thresholdGroups.indexOf(THRESHOLD_GROUP_TYPES.GLOBAL) > -1) {
|
||||
groupTypeByThresholdGroup[THRESHOLD_GROUP_TYPES.GLOBAL] =
|
||||
THRESHOLD_GROUP_TYPES.GLOBAL;
|
||||
return files.concat([[file, THRESHOLD_GROUP_TYPES.GLOBAL]]);
|
||||
}
|
||||
|
||||
// A covered file that doesn't have a threshold:
|
||||
return files.concat([[file, undefined]]);
|
||||
},
|
||||
[]
|
||||
);
|
||||
const getFilesInThresholdGroup = thresholdGroup =>
|
||||
coveredFilesSortedIntoThresholdGroup
|
||||
.filter(fileAndGroup => fileAndGroup[1] === thresholdGroup)
|
||||
.map(fileAndGroup => fileAndGroup[0]);
|
||||
function combineCoverage(filePaths) {
|
||||
return filePaths
|
||||
.map(filePath => map.fileCoverageFor(filePath))
|
||||
.reduce((combinedCoverage, nextFileCoverage) => {
|
||||
if (combinedCoverage === undefined || combinedCoverage === null) {
|
||||
return nextFileCoverage.toSummary();
|
||||
}
|
||||
return combinedCoverage.merge(nextFileCoverage.toSummary());
|
||||
}, undefined);
|
||||
}
|
||||
let errors = [];
|
||||
thresholdGroups.forEach(thresholdGroup => {
|
||||
switch (groupTypeByThresholdGroup[thresholdGroup]) {
|
||||
case THRESHOLD_GROUP_TYPES.GLOBAL: {
|
||||
const coverage = combineCoverage(
|
||||
getFilesInThresholdGroup(THRESHOLD_GROUP_TYPES.GLOBAL)
|
||||
);
|
||||
if (coverage) {
|
||||
errors = errors.concat(
|
||||
check(
|
||||
thresholdGroup,
|
||||
coverageThreshold[thresholdGroup],
|
||||
coverage
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case THRESHOLD_GROUP_TYPES.PATH: {
|
||||
const coverage = combineCoverage(
|
||||
getFilesInThresholdGroup(thresholdGroup)
|
||||
);
|
||||
if (coverage) {
|
||||
errors = errors.concat(
|
||||
check(
|
||||
thresholdGroup,
|
||||
coverageThreshold[thresholdGroup],
|
||||
coverage
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case THRESHOLD_GROUP_TYPES.GLOB:
|
||||
getFilesInThresholdGroup(thresholdGroup).forEach(
|
||||
fileMatchingGlob => {
|
||||
errors = errors.concat(
|
||||
check(
|
||||
fileMatchingGlob,
|
||||
coverageThreshold[thresholdGroup],
|
||||
map.fileCoverageFor(fileMatchingGlob).toSummary()
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
break;
|
||||
default:
|
||||
// If the file specified by path is not found, error is returned.
|
||||
if (thresholdGroup !== THRESHOLD_GROUP_TYPES.GLOBAL) {
|
||||
errors = errors.concat(
|
||||
`Jest: Coverage data for ${thresholdGroup} was not found.`
|
||||
);
|
||||
}
|
||||
// Sometimes all files in the coverage data are matched by
|
||||
// PATH and GLOB threshold groups in which case, don't error when
|
||||
// the global threshold group doesn't match any files.
|
||||
}
|
||||
});
|
||||
|
||||
errors = errors.filter(
|
||||
err => err !== undefined && err !== null && err.length > 0
|
||||
);
|
||||
if (errors.length > 0) {
|
||||
this.log(`${FAIL_COLOR(errors.join('\n'))}`);
|
||||
this._setError(new Error(errors.join('\n')));
|
||||
}
|
||||
}
|
||||
}
|
||||
async _getCoverageResult() {
|
||||
if (this._globalConfig.coverageProvider === 'v8') {
|
||||
const mergedCoverages = (0, _v8Coverage().mergeProcessCovs)(
|
||||
this._v8CoverageResults.map(cov => ({
|
||||
result: cov.map(r => r.result)
|
||||
}))
|
||||
);
|
||||
const fileTransforms = new Map();
|
||||
this._v8CoverageResults.forEach(res =>
|
||||
res.forEach(r => {
|
||||
if (r.codeTransformResult && !fileTransforms.has(r.result.url)) {
|
||||
fileTransforms.set(r.result.url, r.codeTransformResult);
|
||||
}
|
||||
})
|
||||
);
|
||||
const transformedCoverage = await Promise.all(
|
||||
mergedCoverages.result.map(async res => {
|
||||
const fileTransform = fileTransforms.get(res.url);
|
||||
let sourcemapContent = undefined;
|
||||
if (
|
||||
fileTransform?.sourceMapPath &&
|
||||
fs().existsSync(fileTransform.sourceMapPath)
|
||||
) {
|
||||
sourcemapContent = JSON.parse(
|
||||
fs().readFileSync(fileTransform.sourceMapPath, 'utf8')
|
||||
);
|
||||
}
|
||||
const converter = (0, _v8ToIstanbul().default)(
|
||||
res.url,
|
||||
fileTransform?.wrapperLength ?? 0,
|
||||
fileTransform && sourcemapContent
|
||||
? {
|
||||
originalSource: fileTransform.originalCode,
|
||||
source: fileTransform.code,
|
||||
sourceMap: {
|
||||
sourcemap: {
|
||||
file: res.url,
|
||||
...sourcemapContent
|
||||
}
|
||||
}
|
||||
}
|
||||
: {
|
||||
source: fs().readFileSync(res.url, 'utf8')
|
||||
}
|
||||
);
|
||||
await converter.load();
|
||||
converter.applyCoverage(res.functions);
|
||||
const istanbulData = converter.toIstanbul();
|
||||
return istanbulData;
|
||||
})
|
||||
);
|
||||
const map = _istanbulLibCoverage().default.createCoverageMap({});
|
||||
transformedCoverage.forEach(res => map.merge(res));
|
||||
const reportContext = _istanbulLibReport().default.createContext({
|
||||
coverageMap: map,
|
||||
dir: this._globalConfig.coverageDirectory,
|
||||
watermarks: (0, _getWatermarks.default)(this._globalConfig)
|
||||
});
|
||||
return {
|
||||
map,
|
||||
reportContext
|
||||
};
|
||||
}
|
||||
const map = await this._sourceMapStore.transformCoverage(this._coverageMap);
|
||||
const reportContext = _istanbulLibReport().default.createContext({
|
||||
coverageMap: map,
|
||||
dir: this._globalConfig.coverageDirectory,
|
||||
sourceFinder: this._sourceMapStore.sourceFinder,
|
||||
watermarks: (0, _getWatermarks.default)(this._globalConfig)
|
||||
});
|
||||
return {
|
||||
map,
|
||||
reportContext
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.default = CoverageReporter;
|
89
backend/apis/nodejs/node_modules/@jest/reporters/build/CoverageWorker.js
generated
vendored
Normal file
89
backend/apis/nodejs/node_modules/@jest/reporters/build/CoverageWorker.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.worker = worker;
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _generateEmptyCoverage = _interopRequireDefault(
|
||||
require('./generateEmptyCoverage')
|
||||
);
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// Make sure uncaught errors are logged before we exit.
|
||||
process.on('uncaughtException', err => {
|
||||
console.error(err.stack);
|
||||
(0, _exit().default)(1);
|
||||
});
|
||||
function worker({config, globalConfig, path, context}) {
|
||||
return (0, _generateEmptyCoverage.default)(
|
||||
fs().readFileSync(path, 'utf8'),
|
||||
path,
|
||||
globalConfig,
|
||||
config,
|
||||
context.changedFiles && new Set(context.changedFiles),
|
||||
context.sourcesRelatedToTestsInChangedFiles &&
|
||||
new Set(context.sourcesRelatedToTestsInChangedFiles)
|
||||
);
|
||||
}
|
229
backend/apis/nodejs/node_modules/@jest/reporters/build/DefaultReporter.js
generated
vendored
Normal file
229
backend/apis/nodejs/node_modules/@jest/reporters/build/DefaultReporter.js
generated
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _console() {
|
||||
const data = require('@jest/console');
|
||||
_console = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter'));
|
||||
var _Status = _interopRequireDefault(require('./Status'));
|
||||
var _getResultHeader = _interopRequireDefault(require('./getResultHeader'));
|
||||
var _getSnapshotStatus = _interopRequireDefault(require('./getSnapshotStatus'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const TITLE_BULLET = _chalk().default.bold('\u25cf ');
|
||||
class DefaultReporter extends _BaseReporter.default {
|
||||
_clear; // ANSI clear sequence for the last printed status
|
||||
_err;
|
||||
_globalConfig;
|
||||
_out;
|
||||
_status;
|
||||
_bufferedOutput;
|
||||
static filename = __filename;
|
||||
constructor(globalConfig) {
|
||||
super();
|
||||
this._globalConfig = globalConfig;
|
||||
this._clear = '';
|
||||
this._out = process.stdout.write.bind(process.stdout);
|
||||
this._err = process.stderr.write.bind(process.stderr);
|
||||
this._status = new _Status.default(globalConfig);
|
||||
this._bufferedOutput = new Set();
|
||||
this.__wrapStdio(process.stdout);
|
||||
this.__wrapStdio(process.stderr);
|
||||
this._status.onChange(() => {
|
||||
this.__clearStatus();
|
||||
this.__printStatus();
|
||||
});
|
||||
}
|
||||
__wrapStdio(stream) {
|
||||
const write = stream.write.bind(stream);
|
||||
let buffer = [];
|
||||
let timeout = null;
|
||||
const flushBufferedOutput = () => {
|
||||
const string = buffer.join('');
|
||||
buffer = [];
|
||||
|
||||
// This is to avoid conflicts between random output and status text
|
||||
this.__clearStatus();
|
||||
if (string) {
|
||||
write(string);
|
||||
}
|
||||
this.__printStatus();
|
||||
this._bufferedOutput.delete(flushBufferedOutput);
|
||||
};
|
||||
this._bufferedOutput.add(flushBufferedOutput);
|
||||
const debouncedFlush = () => {
|
||||
// If the process blows up no errors would be printed.
|
||||
// There should be a smart way to buffer stderr, but for now
|
||||
// we just won't buffer it.
|
||||
if (stream === process.stderr) {
|
||||
flushBufferedOutput();
|
||||
} else {
|
||||
if (!timeout) {
|
||||
timeout = setTimeout(() => {
|
||||
flushBufferedOutput();
|
||||
timeout = null;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
stream.write = chunk => {
|
||||
buffer.push(chunk);
|
||||
debouncedFlush();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// Don't wait for the debounced call and flush all output immediately.
|
||||
forceFlushBufferedOutput() {
|
||||
for (const flushBufferedOutput of this._bufferedOutput) {
|
||||
flushBufferedOutput();
|
||||
}
|
||||
}
|
||||
__clearStatus() {
|
||||
if (_jestUtil().isInteractive) {
|
||||
if (this._globalConfig.useStderr) {
|
||||
this._err(this._clear);
|
||||
} else {
|
||||
this._out(this._clear);
|
||||
}
|
||||
}
|
||||
}
|
||||
__printStatus() {
|
||||
const {content, clear} = this._status.get();
|
||||
this._clear = clear;
|
||||
if (_jestUtil().isInteractive) {
|
||||
if (this._globalConfig.useStderr) {
|
||||
this._err(content);
|
||||
} else {
|
||||
this._out(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
onRunStart(aggregatedResults, options) {
|
||||
this._status.runStarted(aggregatedResults, options);
|
||||
}
|
||||
onTestStart(test) {
|
||||
this._status.testStarted(test.path, test.context.config);
|
||||
}
|
||||
onTestCaseResult(test, testCaseResult) {
|
||||
this._status.addTestCaseResult(test, testCaseResult);
|
||||
}
|
||||
onRunComplete() {
|
||||
this.forceFlushBufferedOutput();
|
||||
this._status.runFinished();
|
||||
process.stdout.write = this._out;
|
||||
process.stderr.write = this._err;
|
||||
(0, _jestUtil().clearLine)(process.stderr);
|
||||
}
|
||||
onTestResult(test, testResult, aggregatedResults) {
|
||||
this.testFinished(test.context.config, testResult, aggregatedResults);
|
||||
if (!testResult.skipped) {
|
||||
this.printTestFileHeader(
|
||||
testResult.testFilePath,
|
||||
test.context.config,
|
||||
testResult
|
||||
);
|
||||
this.printTestFileFailureMessage(
|
||||
testResult.testFilePath,
|
||||
test.context.config,
|
||||
testResult
|
||||
);
|
||||
}
|
||||
this.forceFlushBufferedOutput();
|
||||
}
|
||||
testFinished(config, testResult, aggregatedResults) {
|
||||
this._status.testFinished(config, testResult, aggregatedResults);
|
||||
}
|
||||
printTestFileHeader(testPath, config, result) {
|
||||
// log retry errors if any exist
|
||||
result.testResults.forEach(testResult => {
|
||||
const testRetryReasons = testResult.retryReasons;
|
||||
if (testRetryReasons && testRetryReasons.length > 0) {
|
||||
this.log(
|
||||
`${_chalk().default.reset.inverse.bold.yellow(
|
||||
' LOGGING RETRY ERRORS '
|
||||
)} ${_chalk().default.bold(testResult.fullName)}`
|
||||
);
|
||||
testRetryReasons.forEach((retryReasons, index) => {
|
||||
let {message, stack} = (0,
|
||||
_jestMessageUtil().separateMessageFromStack)(retryReasons);
|
||||
stack = this._globalConfig.noStackTrace
|
||||
? ''
|
||||
: _chalk().default.dim(
|
||||
(0, _jestMessageUtil().formatStackTrace)(
|
||||
stack,
|
||||
config,
|
||||
this._globalConfig,
|
||||
testPath
|
||||
)
|
||||
);
|
||||
message = (0, _jestMessageUtil().indentAllLines)(message);
|
||||
this.log(
|
||||
`${_chalk().default.reset.inverse.bold.blueBright(
|
||||
` RETRY ${index + 1} `
|
||||
)}\n`
|
||||
);
|
||||
this.log(`${message}\n${stack}\n`);
|
||||
});
|
||||
}
|
||||
});
|
||||
this.log((0, _getResultHeader.default)(result, this._globalConfig, config));
|
||||
if (result.console) {
|
||||
this.log(
|
||||
` ${TITLE_BULLET}Console\n\n${(0, _console().getConsoleOutput)(
|
||||
result.console,
|
||||
config,
|
||||
this._globalConfig
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
printTestFileFailureMessage(_testPath, _config, result) {
|
||||
if (result.failureMessage) {
|
||||
this.log(result.failureMessage);
|
||||
}
|
||||
const didUpdate = this._globalConfig.updateSnapshot === 'all';
|
||||
const snapshotStatuses = (0, _getSnapshotStatus.default)(
|
||||
result.snapshot,
|
||||
didUpdate
|
||||
);
|
||||
snapshotStatuses.forEach(this.log);
|
||||
}
|
||||
}
|
||||
exports.default = DefaultReporter;
|
381
backend/apis/nodejs/node_modules/@jest/reporters/build/GitHubActionsReporter.js
generated
vendored
Normal file
381
backend/apis/nodejs/node_modules/@jest/reporters/build/GitHubActionsReporter.js
generated
vendored
Normal file
@ -0,0 +1,381 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _stripAnsi() {
|
||||
const data = _interopRequireDefault(require('strip-ansi'));
|
||||
_stripAnsi = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const titleSeparator = ' \u203A ';
|
||||
const ICONS = _jestUtil().specialChars.ICONS;
|
||||
class GitHubActionsReporter extends _BaseReporter.default {
|
||||
static filename = __filename;
|
||||
options;
|
||||
constructor(
|
||||
_globalConfig,
|
||||
reporterOptions = {
|
||||
silent: true
|
||||
}
|
||||
) {
|
||||
super();
|
||||
this.options = {
|
||||
silent:
|
||||
typeof reporterOptions.silent === 'boolean'
|
||||
? reporterOptions.silent
|
||||
: true
|
||||
};
|
||||
}
|
||||
onTestResult(test, testResult, aggregatedResults) {
|
||||
this.generateAnnotations(test, testResult);
|
||||
if (!this.options.silent) {
|
||||
this.printFullResult(test.context, testResult);
|
||||
}
|
||||
if (this.isLastTestSuite(aggregatedResults)) {
|
||||
this.printFailedTestLogs(test, aggregatedResults);
|
||||
}
|
||||
}
|
||||
generateAnnotations({context}, {testResults}) {
|
||||
testResults.forEach(result => {
|
||||
const title = [...result.ancestorTitles, result.title].join(
|
||||
titleSeparator
|
||||
);
|
||||
result.retryReasons?.forEach((retryReason, index) => {
|
||||
this.#createAnnotation({
|
||||
...this.#getMessageDetails(retryReason, context.config),
|
||||
title: `RETRY ${index + 1}: ${title}`,
|
||||
type: 'warning'
|
||||
});
|
||||
});
|
||||
result.failureMessages.forEach(failureMessage => {
|
||||
this.#createAnnotation({
|
||||
...this.#getMessageDetails(failureMessage, context.config),
|
||||
title,
|
||||
type: 'error'
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
#getMessageDetails(failureMessage, config) {
|
||||
const {message, stack} = (0, _jestMessageUtil().separateMessageFromStack)(
|
||||
failureMessage
|
||||
);
|
||||
const stackLines = (0, _jestMessageUtil().getStackTraceLines)(stack);
|
||||
const topFrame = (0, _jestMessageUtil().getTopFrame)(stackLines);
|
||||
const normalizedStackLines = stackLines.map(line =>
|
||||
(0, _jestMessageUtil().formatPath)(line, config)
|
||||
);
|
||||
const messageText = [message, ...normalizedStackLines].join('\n');
|
||||
return {
|
||||
file: topFrame?.file,
|
||||
line: topFrame?.line,
|
||||
message: messageText
|
||||
};
|
||||
}
|
||||
#createAnnotation({file, line, message, title, type}) {
|
||||
message = (0, _stripAnsi().default)(
|
||||
// copied from: https://github.com/actions/toolkit/blob/main/packages/core/src/command.ts
|
||||
message.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A')
|
||||
);
|
||||
this.log(
|
||||
`\n::${type} file=${file},line=${line},title=${title}::${message}`
|
||||
);
|
||||
}
|
||||
isLastTestSuite(results) {
|
||||
const passedTestSuites = results.numPassedTestSuites;
|
||||
const failedTestSuites = results.numFailedTestSuites;
|
||||
const totalTestSuites = results.numTotalTestSuites;
|
||||
const computedTotal = passedTestSuites + failedTestSuites;
|
||||
if (computedTotal < totalTestSuites) {
|
||||
return false;
|
||||
} else if (computedTotal === totalTestSuites) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Sum(${computedTotal}) of passed (${passedTestSuites}) and failed (${failedTestSuites}) test suites is greater than the total number of test suites (${totalTestSuites}). Please report the bug at https://github.com/jestjs/jest/issues`
|
||||
);
|
||||
}
|
||||
}
|
||||
printFullResult(context, results) {
|
||||
const rootDir = context.config.rootDir;
|
||||
let testDir = results.testFilePath.replace(rootDir, '');
|
||||
testDir = testDir.slice(1, testDir.length);
|
||||
const resultTree = this.getResultTree(
|
||||
results.testResults,
|
||||
testDir,
|
||||
results.perfStats
|
||||
);
|
||||
this.printResultTree(resultTree);
|
||||
}
|
||||
arrayEqual(a1, a2) {
|
||||
if (a1.length !== a2.length) {
|
||||
return false;
|
||||
}
|
||||
for (let index = 0; index < a1.length; index++) {
|
||||
const element = a1[index];
|
||||
if (element !== a2[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
arrayChild(a1, a2) {
|
||||
if (a1.length - a2.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
for (let index = 0; index < a2.length; index++) {
|
||||
const element = a2[index];
|
||||
if (element !== a1[index]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
getResultTree(suiteResult, testPath, suitePerf) {
|
||||
const root = {
|
||||
children: [],
|
||||
name: testPath,
|
||||
passed: true,
|
||||
performanceInfo: suitePerf
|
||||
};
|
||||
const branches = [];
|
||||
suiteResult.forEach(element => {
|
||||
if (element.ancestorTitles.length === 0) {
|
||||
if (element.status === 'failed') {
|
||||
root.passed = false;
|
||||
}
|
||||
const duration = element.duration || 1;
|
||||
root.children.push({
|
||||
children: [],
|
||||
duration,
|
||||
name: element.title,
|
||||
status: element.status
|
||||
});
|
||||
} else {
|
||||
let alreadyInserted = false;
|
||||
for (let index = 0; index < branches.length; index++) {
|
||||
if (
|
||||
this.arrayEqual(branches[index], element.ancestorTitles.slice(0, 1))
|
||||
) {
|
||||
alreadyInserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyInserted) {
|
||||
branches.push(element.ancestorTitles.slice(0, 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
branches.forEach(element => {
|
||||
const newChild = this.getResultChildren(suiteResult, element);
|
||||
if (!newChild.passed) {
|
||||
root.passed = false;
|
||||
}
|
||||
root.children.push(newChild);
|
||||
});
|
||||
return root;
|
||||
}
|
||||
getResultChildren(suiteResult, ancestors) {
|
||||
const node = {
|
||||
children: [],
|
||||
name: ancestors[ancestors.length - 1],
|
||||
passed: true
|
||||
};
|
||||
const branches = [];
|
||||
suiteResult.forEach(element => {
|
||||
let duration = element.duration;
|
||||
if (!duration || isNaN(duration)) {
|
||||
duration = 1;
|
||||
}
|
||||
if (this.arrayEqual(element.ancestorTitles, ancestors)) {
|
||||
if (element.status === 'failed') {
|
||||
node.passed = false;
|
||||
}
|
||||
node.children.push({
|
||||
children: [],
|
||||
duration,
|
||||
name: element.title,
|
||||
status: element.status
|
||||
});
|
||||
} else if (
|
||||
this.arrayChild(
|
||||
element.ancestorTitles.slice(0, ancestors.length + 1),
|
||||
ancestors
|
||||
)
|
||||
) {
|
||||
let alreadyInserted = false;
|
||||
for (let index = 0; index < branches.length; index++) {
|
||||
if (
|
||||
this.arrayEqual(
|
||||
branches[index],
|
||||
element.ancestorTitles.slice(0, ancestors.length + 1)
|
||||
)
|
||||
) {
|
||||
alreadyInserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyInserted) {
|
||||
branches.push(element.ancestorTitles.slice(0, ancestors.length + 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
branches.forEach(element => {
|
||||
const newChild = this.getResultChildren(suiteResult, element);
|
||||
if (!newChild.passed) {
|
||||
node.passed = false;
|
||||
}
|
||||
node.children.push(newChild);
|
||||
});
|
||||
return node;
|
||||
}
|
||||
printResultTree(resultTree) {
|
||||
let perfMs;
|
||||
if (resultTree.performanceInfo.slow) {
|
||||
perfMs = ` (${_chalk().default.red.inverse(
|
||||
`${resultTree.performanceInfo.runtime} ms`
|
||||
)})`;
|
||||
} else {
|
||||
perfMs = ` (${resultTree.performanceInfo.runtime} ms)`;
|
||||
}
|
||||
if (resultTree.passed) {
|
||||
this.startGroup(
|
||||
`${_chalk().default.bold.green.inverse('PASS')} ${
|
||||
resultTree.name
|
||||
}${perfMs}`
|
||||
);
|
||||
resultTree.children.forEach(child => {
|
||||
this.recursivePrintResultTree(child, true, 1);
|
||||
});
|
||||
this.endGroup();
|
||||
} else {
|
||||
this.log(
|
||||
` ${_chalk().default.bold.red.inverse('FAIL')} ${
|
||||
resultTree.name
|
||||
}${perfMs}`
|
||||
);
|
||||
resultTree.children.forEach(child => {
|
||||
this.recursivePrintResultTree(child, false, 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
recursivePrintResultTree(resultTree, alreadyGrouped, depth) {
|
||||
if (resultTree.children.length === 0) {
|
||||
if (!('duration' in resultTree)) {
|
||||
throw new Error('Expected a leaf. Got a node.');
|
||||
}
|
||||
let numberSpaces = depth;
|
||||
if (!alreadyGrouped) {
|
||||
numberSpaces++;
|
||||
}
|
||||
const spaces = ' '.repeat(numberSpaces);
|
||||
let resultSymbol;
|
||||
switch (resultTree.status) {
|
||||
case 'passed':
|
||||
resultSymbol = _chalk().default.green(ICONS.success);
|
||||
break;
|
||||
case 'failed':
|
||||
resultSymbol = _chalk().default.red(ICONS.failed);
|
||||
break;
|
||||
case 'todo':
|
||||
resultSymbol = _chalk().default.magenta(ICONS.todo);
|
||||
break;
|
||||
case 'pending':
|
||||
case 'skipped':
|
||||
resultSymbol = _chalk().default.yellow(ICONS.pending);
|
||||
break;
|
||||
}
|
||||
this.log(
|
||||
`${spaces + resultSymbol} ${resultTree.name} (${
|
||||
resultTree.duration
|
||||
} ms)`
|
||||
);
|
||||
} else {
|
||||
if (!('passed' in resultTree)) {
|
||||
throw new Error('Expected a node. Got a leaf');
|
||||
}
|
||||
if (resultTree.passed) {
|
||||
if (alreadyGrouped) {
|
||||
this.log(' '.repeat(depth) + resultTree.name);
|
||||
resultTree.children.forEach(child => {
|
||||
this.recursivePrintResultTree(child, true, depth + 1);
|
||||
});
|
||||
} else {
|
||||
this.startGroup(' '.repeat(depth) + resultTree.name);
|
||||
resultTree.children.forEach(child => {
|
||||
this.recursivePrintResultTree(child, true, depth + 1);
|
||||
});
|
||||
this.endGroup();
|
||||
}
|
||||
} else {
|
||||
this.log(' '.repeat(depth + 1) + resultTree.name);
|
||||
resultTree.children.forEach(child => {
|
||||
this.recursivePrintResultTree(child, false, depth + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
printFailedTestLogs(context, testResults) {
|
||||
const rootDir = context.context.config.rootDir;
|
||||
const results = testResults.testResults;
|
||||
let written = false;
|
||||
results.forEach(result => {
|
||||
let testDir = result.testFilePath;
|
||||
testDir = testDir.replace(rootDir, '');
|
||||
testDir = testDir.slice(1, testDir.length);
|
||||
if (result.failureMessage) {
|
||||
if (!written) {
|
||||
this.log('');
|
||||
written = true;
|
||||
}
|
||||
this.startGroup(`Errors thrown in ${testDir}`);
|
||||
this.log(result.failureMessage);
|
||||
this.endGroup();
|
||||
}
|
||||
});
|
||||
return written;
|
||||
}
|
||||
startGroup(title) {
|
||||
this.log(`::group::${title}`);
|
||||
}
|
||||
endGroup() {
|
||||
this.log('::endgroup::');
|
||||
}
|
||||
}
|
||||
exports.default = GitHubActionsReporter;
|
218
backend/apis/nodejs/node_modules/@jest/reporters/build/NotifyReporter.js
generated
vendored
Normal file
218
backend/apis/nodejs/node_modules/@jest/reporters/build/NotifyReporter.js
generated
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function util() {
|
||||
const data = _interopRequireWildcard(require('util'));
|
||||
util = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _exit() {
|
||||
const data = _interopRequireDefault(require('exit'));
|
||||
_exit = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const isDarwin = process.platform === 'darwin';
|
||||
const icon = path().resolve(__dirname, '../assets/jest_logo.png');
|
||||
class NotifyReporter extends _BaseReporter.default {
|
||||
_notifier = loadNotifier();
|
||||
_globalConfig;
|
||||
_context;
|
||||
static filename = __filename;
|
||||
constructor(globalConfig, context) {
|
||||
super();
|
||||
this._globalConfig = globalConfig;
|
||||
this._context = context;
|
||||
}
|
||||
onRunComplete(testContexts, result) {
|
||||
const success =
|
||||
result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0;
|
||||
const firstContext = testContexts.values().next();
|
||||
const hasteFS =
|
||||
firstContext && firstContext.value && firstContext.value.hasteFS;
|
||||
let packageName;
|
||||
if (hasteFS != null) {
|
||||
// assuming root package.json is the first one
|
||||
const [filePath] = hasteFS.matchFiles('package.json');
|
||||
packageName =
|
||||
filePath != null
|
||||
? hasteFS.getModuleName(filePath)
|
||||
: this._globalConfig.rootDir;
|
||||
} else {
|
||||
packageName = this._globalConfig.rootDir;
|
||||
}
|
||||
packageName = packageName != null ? `${packageName} - ` : '';
|
||||
const notifyMode = this._globalConfig.notifyMode;
|
||||
const statusChanged =
|
||||
this._context.previousSuccess !== success || this._context.firstRun;
|
||||
const testsHaveRun = result.numTotalTests !== 0;
|
||||
if (
|
||||
testsHaveRun &&
|
||||
success &&
|
||||
(notifyMode === 'always' ||
|
||||
notifyMode === 'success' ||
|
||||
notifyMode === 'success-change' ||
|
||||
(notifyMode === 'change' && statusChanged) ||
|
||||
(notifyMode === 'failure-change' && statusChanged))
|
||||
) {
|
||||
const title = util().format('%s%d%% Passed', packageName, 100);
|
||||
const message = `${isDarwin ? '\u2705 ' : ''}${(0, _jestUtil().pluralize)(
|
||||
'test',
|
||||
result.numPassedTests
|
||||
)} passed`;
|
||||
this._notifier.notify({
|
||||
hint: 'int:transient:1',
|
||||
icon,
|
||||
message,
|
||||
timeout: false,
|
||||
title
|
||||
});
|
||||
} else if (
|
||||
testsHaveRun &&
|
||||
!success &&
|
||||
(notifyMode === 'always' ||
|
||||
notifyMode === 'failure' ||
|
||||
notifyMode === 'failure-change' ||
|
||||
(notifyMode === 'change' && statusChanged) ||
|
||||
(notifyMode === 'success-change' && statusChanged))
|
||||
) {
|
||||
const failed = result.numFailedTests / result.numTotalTests;
|
||||
const title = util().format(
|
||||
'%s%d%% Failed',
|
||||
packageName,
|
||||
Math.ceil(Number.isNaN(failed) ? 0 : failed * 100)
|
||||
);
|
||||
const message = util().format(
|
||||
`${isDarwin ? '\u26D4\uFE0F ' : ''}%d of %d tests failed`,
|
||||
result.numFailedTests,
|
||||
result.numTotalTests
|
||||
);
|
||||
const watchMode = this._globalConfig.watch || this._globalConfig.watchAll;
|
||||
const restartAnswer = 'Run again';
|
||||
const quitAnswer = 'Exit tests';
|
||||
if (!watchMode) {
|
||||
this._notifier.notify({
|
||||
hint: 'int:transient:1',
|
||||
icon,
|
||||
message,
|
||||
timeout: false,
|
||||
title
|
||||
});
|
||||
} else {
|
||||
this._notifier.notify(
|
||||
{
|
||||
// @ts-expect-error - not all options are supported by all systems (specifically `actions` and `hint`)
|
||||
actions: [restartAnswer, quitAnswer],
|
||||
closeLabel: 'Close',
|
||||
hint: 'int:transient:1',
|
||||
icon,
|
||||
message,
|
||||
timeout: false,
|
||||
title
|
||||
},
|
||||
(err, _, metadata) => {
|
||||
if (err || !metadata) {
|
||||
return;
|
||||
}
|
||||
if (metadata.activationValue === quitAnswer) {
|
||||
(0, _exit().default)(0);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
metadata.activationValue === restartAnswer &&
|
||||
this._context.startRun
|
||||
) {
|
||||
this._context.startRun(this._globalConfig);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
this._context.previousSuccess = success;
|
||||
this._context.firstRun = false;
|
||||
}
|
||||
}
|
||||
exports.default = NotifyReporter;
|
||||
function loadNotifier() {
|
||||
try {
|
||||
return require('node-notifier');
|
||||
} catch (err) {
|
||||
if (err.code !== 'MODULE_NOT_FOUND') {
|
||||
throw err;
|
||||
}
|
||||
throw Error(
|
||||
'notify reporter requires optional peer dependency "node-notifier" but it was not found'
|
||||
);
|
||||
}
|
||||
}
|
214
backend/apis/nodejs/node_modules/@jest/reporters/build/Status.js
generated
vendored
Normal file
214
backend/apis/nodejs/node_modules/@jest/reporters/build/Status.js
generated
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _stringLength() {
|
||||
const data = _interopRequireDefault(require('string-length'));
|
||||
_stringLength = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _getSummary = _interopRequireDefault(require('./getSummary'));
|
||||
var _printDisplayName = _interopRequireDefault(require('./printDisplayName'));
|
||||
var _trimAndFormatPath = _interopRequireDefault(require('./trimAndFormatPath'));
|
||||
var _wrapAnsiString = _interopRequireDefault(require('./wrapAnsiString'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const RUNNING_TEXT = ' RUNS ';
|
||||
const RUNNING = `${_chalk().default.reset.inverse.yellow.bold(RUNNING_TEXT)} `;
|
||||
|
||||
/**
|
||||
* This class is a perf optimization for sorting the list of currently
|
||||
* running tests. It tries to keep tests in the same positions without
|
||||
* shifting the whole list.
|
||||
*/
|
||||
class CurrentTestList {
|
||||
_array;
|
||||
constructor() {
|
||||
this._array = [];
|
||||
}
|
||||
add(testPath, config) {
|
||||
const index = this._array.indexOf(null);
|
||||
const record = {
|
||||
config,
|
||||
testPath
|
||||
};
|
||||
if (index !== -1) {
|
||||
this._array[index] = record;
|
||||
} else {
|
||||
this._array.push(record);
|
||||
}
|
||||
}
|
||||
delete(testPath) {
|
||||
const record = this._array.find(
|
||||
record => record !== null && record.testPath === testPath
|
||||
);
|
||||
this._array[this._array.indexOf(record || null)] = null;
|
||||
}
|
||||
get() {
|
||||
return this._array;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A class that generates the CLI status of currently running tests
|
||||
* and also provides an ANSI escape sequence to remove status lines
|
||||
* from the terminal.
|
||||
*/
|
||||
class Status {
|
||||
_cache;
|
||||
_callback;
|
||||
_currentTests;
|
||||
_currentTestCases;
|
||||
_done;
|
||||
_emitScheduled;
|
||||
_estimatedTime;
|
||||
_interval;
|
||||
_aggregatedResults;
|
||||
_showStatus;
|
||||
constructor(_globalConfig) {
|
||||
this._globalConfig = _globalConfig;
|
||||
this._cache = null;
|
||||
this._currentTests = new CurrentTestList();
|
||||
this._currentTestCases = [];
|
||||
this._done = false;
|
||||
this._emitScheduled = false;
|
||||
this._estimatedTime = 0;
|
||||
this._showStatus = false;
|
||||
}
|
||||
onChange(callback) {
|
||||
this._callback = callback;
|
||||
}
|
||||
runStarted(aggregatedResults, options) {
|
||||
this._estimatedTime = (options && options.estimatedTime) || 0;
|
||||
this._showStatus = options && options.showStatus;
|
||||
this._interval = setInterval(() => this._tick(), 1000);
|
||||
this._aggregatedResults = aggregatedResults;
|
||||
this._debouncedEmit();
|
||||
}
|
||||
runFinished() {
|
||||
this._done = true;
|
||||
if (this._interval) clearInterval(this._interval);
|
||||
this._emit();
|
||||
}
|
||||
addTestCaseResult(test, testCaseResult) {
|
||||
this._currentTestCases.push({
|
||||
test,
|
||||
testCaseResult
|
||||
});
|
||||
if (!this._showStatus) {
|
||||
this._emit();
|
||||
} else {
|
||||
this._debouncedEmit();
|
||||
}
|
||||
}
|
||||
testStarted(testPath, config) {
|
||||
this._currentTests.add(testPath, config);
|
||||
if (!this._showStatus) {
|
||||
this._emit();
|
||||
} else {
|
||||
this._debouncedEmit();
|
||||
}
|
||||
}
|
||||
testFinished(_config, testResult, aggregatedResults) {
|
||||
const {testFilePath} = testResult;
|
||||
this._aggregatedResults = aggregatedResults;
|
||||
this._currentTests.delete(testFilePath);
|
||||
this._currentTestCases = this._currentTestCases.filter(({test}) => {
|
||||
if (_config !== test.context.config) {
|
||||
return true;
|
||||
}
|
||||
return test.path !== testFilePath;
|
||||
});
|
||||
this._debouncedEmit();
|
||||
}
|
||||
get() {
|
||||
if (this._cache) {
|
||||
return this._cache;
|
||||
}
|
||||
if (this._done) {
|
||||
return {
|
||||
clear: '',
|
||||
content: ''
|
||||
};
|
||||
}
|
||||
const width = process.stdout.columns;
|
||||
let content = '\n';
|
||||
this._currentTests.get().forEach(record => {
|
||||
if (record) {
|
||||
const {config, testPath} = record;
|
||||
const projectDisplayName = config.displayName
|
||||
? `${(0, _printDisplayName.default)(config)} `
|
||||
: '';
|
||||
const prefix = RUNNING + projectDisplayName;
|
||||
content += `${(0, _wrapAnsiString.default)(
|
||||
prefix +
|
||||
(0, _trimAndFormatPath.default)(
|
||||
(0, _stringLength().default)(prefix),
|
||||
config,
|
||||
testPath,
|
||||
width
|
||||
),
|
||||
width
|
||||
)}\n`;
|
||||
}
|
||||
});
|
||||
if (this._showStatus && this._aggregatedResults) {
|
||||
content += `\n${(0, _getSummary.default)(this._aggregatedResults, {
|
||||
currentTestCases: this._currentTestCases,
|
||||
estimatedTime: this._estimatedTime,
|
||||
roundTime: true,
|
||||
seed: this._globalConfig.seed,
|
||||
showSeed: this._globalConfig.showSeed,
|
||||
width
|
||||
})}`;
|
||||
}
|
||||
let height = 0;
|
||||
for (let i = 0; i < content.length; i++) {
|
||||
if (content[i] === '\n') {
|
||||
height++;
|
||||
}
|
||||
}
|
||||
const clear = '\r\x1B[K\r\x1B[1A'.repeat(height);
|
||||
return (this._cache = {
|
||||
clear,
|
||||
content
|
||||
});
|
||||
}
|
||||
_emit() {
|
||||
this._cache = null;
|
||||
if (this._callback) this._callback();
|
||||
}
|
||||
_debouncedEmit() {
|
||||
if (!this._emitScheduled) {
|
||||
// Perf optimization to avoid two separate renders When
|
||||
// one test finishes and another test starts executing.
|
||||
this._emitScheduled = true;
|
||||
setTimeout(() => {
|
||||
this._emit();
|
||||
this._emitScheduled = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
_tick() {
|
||||
this._debouncedEmit();
|
||||
}
|
||||
}
|
||||
exports.default = Status;
|
239
backend/apis/nodejs/node_modules/@jest/reporters/build/SummaryReporter.js
generated
vendored
Normal file
239
backend/apis/nodejs/node_modules/@jest/reporters/build/SummaryReporter.js
generated
vendored
Normal file
@ -0,0 +1,239 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _BaseReporter = _interopRequireDefault(require('./BaseReporter'));
|
||||
var _getResultHeader = _interopRequireDefault(require('./getResultHeader'));
|
||||
var _getSnapshotSummary = _interopRequireDefault(
|
||||
require('./getSnapshotSummary')
|
||||
);
|
||||
var _getSummary = _interopRequireDefault(require('./getSummary'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const NPM_EVENTS = new Set([
|
||||
'prepublish',
|
||||
'publish',
|
||||
'postpublish',
|
||||
'preinstall',
|
||||
'install',
|
||||
'postinstall',
|
||||
'preuninstall',
|
||||
'uninstall',
|
||||
'postuninstall',
|
||||
'preversion',
|
||||
'version',
|
||||
'postversion',
|
||||
'pretest',
|
||||
'test',
|
||||
'posttest',
|
||||
'prestop',
|
||||
'stop',
|
||||
'poststop',
|
||||
'prestart',
|
||||
'start',
|
||||
'poststart',
|
||||
'prerestart',
|
||||
'restart',
|
||||
'postrestart'
|
||||
]);
|
||||
const {npm_config_user_agent, npm_lifecycle_event, npm_lifecycle_script} =
|
||||
process.env;
|
||||
class SummaryReporter extends _BaseReporter.default {
|
||||
_estimatedTime;
|
||||
_globalConfig;
|
||||
_summaryThreshold;
|
||||
static filename = __filename;
|
||||
constructor(globalConfig, options) {
|
||||
super();
|
||||
this._globalConfig = globalConfig;
|
||||
this._estimatedTime = 0;
|
||||
this._validateOptions(options);
|
||||
this._summaryThreshold = options?.summaryThreshold ?? 20;
|
||||
}
|
||||
_validateOptions(options) {
|
||||
if (
|
||||
options?.summaryThreshold &&
|
||||
typeof options.summaryThreshold !== 'number'
|
||||
) {
|
||||
throw new TypeError('The option summaryThreshold should be a number');
|
||||
}
|
||||
}
|
||||
|
||||
// If we write more than one character at a time it is possible that
|
||||
// Node.js exits in the middle of printing the result. This was first observed
|
||||
// in Node.js 0.10 and still persists in Node.js 6.7+.
|
||||
// Let's print the test failure summary character by character which is safer
|
||||
// when hundreds of tests are failing.
|
||||
_write(string) {
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
process.stderr.write(string.charAt(i));
|
||||
}
|
||||
}
|
||||
onRunStart(aggregatedResults, options) {
|
||||
super.onRunStart(aggregatedResults, options);
|
||||
this._estimatedTime = options.estimatedTime;
|
||||
}
|
||||
onRunComplete(testContexts, aggregatedResults) {
|
||||
const {numTotalTestSuites, testResults, wasInterrupted} = aggregatedResults;
|
||||
if (numTotalTestSuites) {
|
||||
const lastResult = testResults[testResults.length - 1];
|
||||
// Print a newline if the last test did not fail to line up newlines
|
||||
// similar to when an error would have been thrown in the test.
|
||||
if (
|
||||
!this._globalConfig.verbose &&
|
||||
lastResult &&
|
||||
!lastResult.numFailingTests &&
|
||||
!lastResult.testExecError
|
||||
) {
|
||||
this.log('');
|
||||
}
|
||||
this._printSummary(aggregatedResults, this._globalConfig);
|
||||
this._printSnapshotSummary(
|
||||
aggregatedResults.snapshot,
|
||||
this._globalConfig
|
||||
);
|
||||
let message = (0, _getSummary.default)(aggregatedResults, {
|
||||
estimatedTime: this._estimatedTime,
|
||||
seed: this._globalConfig.seed,
|
||||
showSeed: this._globalConfig.showSeed
|
||||
});
|
||||
if (!this._globalConfig.silent) {
|
||||
message += `\n${
|
||||
wasInterrupted
|
||||
? _chalk().default.bold.red('Test run was interrupted.')
|
||||
: this._getTestSummary(testContexts, this._globalConfig)
|
||||
}`;
|
||||
}
|
||||
this.log(message);
|
||||
}
|
||||
}
|
||||
_printSnapshotSummary(snapshots, globalConfig) {
|
||||
if (
|
||||
snapshots.added ||
|
||||
snapshots.filesRemoved ||
|
||||
snapshots.unchecked ||
|
||||
snapshots.unmatched ||
|
||||
snapshots.updated
|
||||
) {
|
||||
let updateCommand;
|
||||
const event = npm_lifecycle_event || '';
|
||||
const prefix = NPM_EVENTS.has(event) ? '' : 'run ';
|
||||
const isYarn =
|
||||
typeof npm_config_user_agent === 'string' &&
|
||||
npm_config_user_agent.includes('yarn');
|
||||
const client = isYarn ? 'yarn' : 'npm';
|
||||
const scriptUsesJest =
|
||||
typeof npm_lifecycle_script === 'string' &&
|
||||
npm_lifecycle_script.includes('jest');
|
||||
if (globalConfig.watch || globalConfig.watchAll) {
|
||||
updateCommand = 'press `u`';
|
||||
} else if (event && scriptUsesJest) {
|
||||
updateCommand = `run \`${`${client} ${prefix}${event}${
|
||||
isYarn ? '' : ' --'
|
||||
}`} -u\``;
|
||||
} else {
|
||||
updateCommand = 're-run jest with `-u`';
|
||||
}
|
||||
const snapshotSummary = (0, _getSnapshotSummary.default)(
|
||||
snapshots,
|
||||
globalConfig,
|
||||
updateCommand
|
||||
);
|
||||
snapshotSummary.forEach(this.log);
|
||||
this.log(''); // print empty line
|
||||
}
|
||||
}
|
||||
|
||||
_printSummary(aggregatedResults, globalConfig) {
|
||||
// If there were any failing tests and there was a large number of tests
|
||||
// executed, re-print the failing results at the end of execution output.
|
||||
const failedTests = aggregatedResults.numFailedTests;
|
||||
const runtimeErrors = aggregatedResults.numRuntimeErrorTestSuites;
|
||||
if (
|
||||
failedTests + runtimeErrors > 0 &&
|
||||
aggregatedResults.numTotalTestSuites > this._summaryThreshold
|
||||
) {
|
||||
this.log(_chalk().default.bold('Summary of all failing tests'));
|
||||
aggregatedResults.testResults.forEach(testResult => {
|
||||
const {failureMessage} = testResult;
|
||||
if (failureMessage) {
|
||||
this._write(
|
||||
`${(0, _getResultHeader.default)(
|
||||
testResult,
|
||||
globalConfig
|
||||
)}\n${failureMessage}\n`
|
||||
);
|
||||
}
|
||||
});
|
||||
this.log(''); // print empty line
|
||||
}
|
||||
}
|
||||
|
||||
_getTestSummary(testContexts, globalConfig) {
|
||||
const getMatchingTestsInfo = () => {
|
||||
const prefix = globalConfig.findRelatedTests
|
||||
? ' related to files matching '
|
||||
: ' matching ';
|
||||
return (
|
||||
_chalk().default.dim(prefix) +
|
||||
(0, _jestUtil().testPathPatternToRegExp)(
|
||||
globalConfig.testPathPattern
|
||||
).toString()
|
||||
);
|
||||
};
|
||||
let testInfo = '';
|
||||
if (globalConfig.runTestsByPath) {
|
||||
testInfo = _chalk().default.dim(' within paths');
|
||||
} else if (globalConfig.onlyChanged) {
|
||||
testInfo = _chalk().default.dim(' related to changed files');
|
||||
} else if (globalConfig.testPathPattern) {
|
||||
testInfo = getMatchingTestsInfo();
|
||||
}
|
||||
let nameInfo = '';
|
||||
if (globalConfig.runTestsByPath) {
|
||||
nameInfo = ` ${globalConfig.nonFlagArgs.map(p => `"${p}"`).join(', ')}`;
|
||||
} else if (globalConfig.testNamePattern) {
|
||||
nameInfo = `${_chalk().default.dim(' with tests matching ')}"${
|
||||
globalConfig.testNamePattern
|
||||
}"`;
|
||||
}
|
||||
const contextInfo =
|
||||
testContexts.size > 1
|
||||
? _chalk().default.dim(' in ') +
|
||||
testContexts.size +
|
||||
_chalk().default.dim(' projects')
|
||||
: '';
|
||||
return (
|
||||
_chalk().default.dim('Ran all test suites') +
|
||||
testInfo +
|
||||
nameInfo +
|
||||
contextInfo +
|
||||
_chalk().default.dim('.')
|
||||
);
|
||||
}
|
||||
}
|
||||
exports.default = SummaryReporter;
|
175
backend/apis/nodejs/node_modules/@jest/reporters/build/VerboseReporter.js
generated
vendored
Normal file
175
backend/apis/nodejs/node_modules/@jest/reporters/build/VerboseReporter.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _DefaultReporter = _interopRequireDefault(require('./DefaultReporter'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {ICONS} = _jestUtil().specialChars;
|
||||
class VerboseReporter extends _DefaultReporter.default {
|
||||
_globalConfig;
|
||||
static filename = __filename;
|
||||
constructor(globalConfig) {
|
||||
super(globalConfig);
|
||||
this._globalConfig = globalConfig;
|
||||
}
|
||||
|
||||
// Verbose mode is for debugging. Buffering of output is undesirable.
|
||||
// See https://github.com/jestjs/jest/issues/8208
|
||||
__wrapStdio(stream) {
|
||||
const write = stream.write.bind(stream);
|
||||
stream.write = chunk => {
|
||||
this.__clearStatus();
|
||||
write(chunk);
|
||||
this.__printStatus();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
static filterTestResults(testResults) {
|
||||
return testResults.filter(({status}) => status !== 'pending');
|
||||
}
|
||||
static groupTestsBySuites(testResults) {
|
||||
const root = {
|
||||
suites: [],
|
||||
tests: [],
|
||||
title: ''
|
||||
};
|
||||
testResults.forEach(testResult => {
|
||||
let targetSuite = root;
|
||||
|
||||
// Find the target suite for this test,
|
||||
// creating nested suites as necessary.
|
||||
for (const title of testResult.ancestorTitles) {
|
||||
let matchingSuite = targetSuite.suites.find(s => s.title === title);
|
||||
if (!matchingSuite) {
|
||||
matchingSuite = {
|
||||
suites: [],
|
||||
tests: [],
|
||||
title
|
||||
};
|
||||
targetSuite.suites.push(matchingSuite);
|
||||
}
|
||||
targetSuite = matchingSuite;
|
||||
}
|
||||
targetSuite.tests.push(testResult);
|
||||
});
|
||||
return root;
|
||||
}
|
||||
onTestResult(test, result, aggregatedResults) {
|
||||
super.testFinished(test.context.config, result, aggregatedResults);
|
||||
if (!result.skipped) {
|
||||
this.printTestFileHeader(
|
||||
result.testFilePath,
|
||||
test.context.config,
|
||||
result
|
||||
);
|
||||
if (!result.testExecError && !result.skipped) {
|
||||
this._logTestResults(result.testResults);
|
||||
}
|
||||
this.printTestFileFailureMessage(
|
||||
result.testFilePath,
|
||||
test.context.config,
|
||||
result
|
||||
);
|
||||
}
|
||||
super.forceFlushBufferedOutput();
|
||||
}
|
||||
_logTestResults(testResults) {
|
||||
this._logSuite(VerboseReporter.groupTestsBySuites(testResults), 0);
|
||||
this._logLine();
|
||||
}
|
||||
_logSuite(suite, indentLevel) {
|
||||
if (suite.title) {
|
||||
this._logLine(suite.title, indentLevel);
|
||||
}
|
||||
this._logTests(suite.tests, indentLevel + 1);
|
||||
suite.suites.forEach(suite => this._logSuite(suite, indentLevel + 1));
|
||||
}
|
||||
_getIcon(status) {
|
||||
if (status === 'failed') {
|
||||
return _chalk().default.red(ICONS.failed);
|
||||
} else if (status === 'pending') {
|
||||
return _chalk().default.yellow(ICONS.pending);
|
||||
} else if (status === 'todo') {
|
||||
return _chalk().default.magenta(ICONS.todo);
|
||||
} else {
|
||||
return _chalk().default.green(ICONS.success);
|
||||
}
|
||||
}
|
||||
_logTest(test, indentLevel) {
|
||||
const status = this._getIcon(test.status);
|
||||
const time = test.duration
|
||||
? ` (${(0, _jestUtil().formatTime)(Math.round(test.duration))})`
|
||||
: '';
|
||||
this._logLine(
|
||||
`${status} ${_chalk().default.dim(test.title + time)}`,
|
||||
indentLevel
|
||||
);
|
||||
}
|
||||
_logTests(tests, indentLevel) {
|
||||
if (this._globalConfig.expand) {
|
||||
tests.forEach(test => this._logTest(test, indentLevel));
|
||||
} else {
|
||||
const summedTests = tests.reduce(
|
||||
(result, test) => {
|
||||
if (test.status === 'pending') {
|
||||
result.pending.push(test);
|
||||
} else if (test.status === 'todo') {
|
||||
result.todo.push(test);
|
||||
} else {
|
||||
this._logTest(test, indentLevel);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
{
|
||||
pending: [],
|
||||
todo: []
|
||||
}
|
||||
);
|
||||
if (summedTests.pending.length > 0) {
|
||||
summedTests.pending.forEach(this._logTodoOrPendingTest(indentLevel));
|
||||
}
|
||||
if (summedTests.todo.length > 0) {
|
||||
summedTests.todo.forEach(this._logTodoOrPendingTest(indentLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
_logTodoOrPendingTest(indentLevel) {
|
||||
return test => {
|
||||
const printedTestStatus =
|
||||
test.status === 'pending' ? 'skipped' : test.status;
|
||||
const icon = this._getIcon(test.status);
|
||||
const text = _chalk().default.dim(`${printedTestStatus} ${test.title}`);
|
||||
this._logLine(`${icon} ${text}`, indentLevel);
|
||||
};
|
||||
}
|
||||
_logLine(str, indentLevel) {
|
||||
const indentation = ' '.repeat(indentLevel || 0);
|
||||
this.log(indentation + (str || ''));
|
||||
}
|
||||
}
|
||||
exports.default = VerboseReporter;
|
84
backend/apis/nodejs/node_modules/@jest/reporters/build/formatTestPath.js
generated
vendored
Normal file
84
backend/apis/nodejs/node_modules/@jest/reporters/build/formatTestPath.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = formatTestPath;
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _relativePath = _interopRequireDefault(require('./relativePath'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function formatTestPath(config, testPath) {
|
||||
const {dirname, basename} = (0, _relativePath.default)(config, testPath);
|
||||
return (0, _slash().default)(
|
||||
_chalk().default.dim(dirname + path().sep) + _chalk().default.bold(basename)
|
||||
);
|
||||
}
|
151
backend/apis/nodejs/node_modules/@jest/reporters/build/generateEmptyCoverage.js
generated
vendored
Normal file
151
backend/apis/nodejs/node_modules/@jest/reporters/build/generateEmptyCoverage.js
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = generateEmptyCoverage;
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulLibCoverage() {
|
||||
const data = require('istanbul-lib-coverage');
|
||||
_istanbulLibCoverage = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _istanbulLibInstrument() {
|
||||
const data = require('istanbul-lib-instrument');
|
||||
_istanbulLibInstrument = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _transform() {
|
||||
const data = require('@jest/transform');
|
||||
_transform = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (key !== 'default' && 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) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
async function generateEmptyCoverage(
|
||||
source,
|
||||
filename,
|
||||
globalConfig,
|
||||
config,
|
||||
changedFiles,
|
||||
sourcesRelatedToTestsInChangedFiles
|
||||
) {
|
||||
const coverageOptions = {
|
||||
changedFiles,
|
||||
collectCoverage: globalConfig.collectCoverage,
|
||||
collectCoverageFrom: globalConfig.collectCoverageFrom,
|
||||
coverageProvider: globalConfig.coverageProvider,
|
||||
sourcesRelatedToTestsInChangedFiles
|
||||
};
|
||||
let coverageWorkerResult = null;
|
||||
if ((0, _transform().shouldInstrument)(filename, coverageOptions, config)) {
|
||||
if (coverageOptions.coverageProvider === 'v8') {
|
||||
const stat = fs().statSync(filename);
|
||||
return {
|
||||
kind: 'V8Coverage',
|
||||
result: {
|
||||
functions: [
|
||||
{
|
||||
functionName: '(empty-report)',
|
||||
isBlockCoverage: true,
|
||||
ranges: [
|
||||
{
|
||||
count: 0,
|
||||
endOffset: stat.size,
|
||||
startOffset: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
scriptId: '0',
|
||||
url: filename
|
||||
}
|
||||
};
|
||||
}
|
||||
const scriptTransformer = await (0, _transform().createScriptTransformer)(
|
||||
config
|
||||
);
|
||||
|
||||
// Transform file with instrumentation to make sure initial coverage data is well mapped to original code.
|
||||
const {code} = await scriptTransformer.transformSourceAsync(
|
||||
filename,
|
||||
source,
|
||||
{
|
||||
instrument: true,
|
||||
supportsDynamicImport: true,
|
||||
supportsExportNamespaceFrom: true,
|
||||
supportsStaticESM: true,
|
||||
supportsTopLevelAwait: true
|
||||
}
|
||||
);
|
||||
// TODO: consider passing AST
|
||||
const extracted = (0, _istanbulLibInstrument().readInitialCoverage)(code);
|
||||
// Check extracted initial coverage is not null, this can happen when using /* istanbul ignore file */
|
||||
if (extracted) {
|
||||
coverageWorkerResult = {
|
||||
coverage: (0, _istanbulLibCoverage().createFileCoverage)(
|
||||
extracted.coverageData
|
||||
),
|
||||
kind: 'BabelCoverage'
|
||||
};
|
||||
}
|
||||
}
|
||||
return coverageWorkerResult;
|
||||
}
|
65
backend/apis/nodejs/node_modules/@jest/reporters/build/getResultHeader.js
generated
vendored
Normal file
65
backend/apis/nodejs/node_modules/@jest/reporters/build/getResultHeader.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getResultHeader;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _formatTestPath = _interopRequireDefault(require('./formatTestPath'));
|
||||
var _printDisplayName = _interopRequireDefault(require('./printDisplayName'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const LONG_TEST_COLOR = _chalk().default.reset.bold.bgRed;
|
||||
// Explicitly reset for these messages since they can get written out in the
|
||||
// middle of error logging
|
||||
const FAIL_TEXT = 'FAIL';
|
||||
const PASS_TEXT = 'PASS';
|
||||
const FAIL = _chalk().default.supportsColor
|
||||
? _chalk().default.reset.inverse.bold.red(` ${FAIL_TEXT} `)
|
||||
: FAIL_TEXT;
|
||||
const PASS = _chalk().default.supportsColor
|
||||
? _chalk().default.reset.inverse.bold.green(` ${PASS_TEXT} `)
|
||||
: PASS_TEXT;
|
||||
function getResultHeader(result, globalConfig, projectConfig) {
|
||||
const testPath = result.testFilePath;
|
||||
const status =
|
||||
result.numFailingTests > 0 || result.testExecError ? FAIL : PASS;
|
||||
const testDetail = [];
|
||||
if (result.perfStats?.slow) {
|
||||
const runTime = result.perfStats.runtime / 1000;
|
||||
testDetail.push(LONG_TEST_COLOR((0, _jestUtil().formatTime)(runTime, 0)));
|
||||
}
|
||||
if (result.memoryUsage) {
|
||||
const toMB = bytes => Math.floor(bytes / 1024 / 1024);
|
||||
testDetail.push(`${toMB(result.memoryUsage)} MB heap size`);
|
||||
}
|
||||
const projectDisplayName =
|
||||
projectConfig && projectConfig.displayName
|
||||
? `${(0, _printDisplayName.default)(projectConfig)} `
|
||||
: '';
|
||||
return `${status} ${projectDisplayName}${(0, _formatTestPath.default)(
|
||||
projectConfig ?? globalConfig,
|
||||
testPath
|
||||
)}${testDetail.length ? ` (${testDetail.join(', ')})` : ''}`;
|
||||
}
|
92
backend/apis/nodejs/node_modules/@jest/reporters/build/getSnapshotStatus.js
generated
vendored
Normal file
92
backend/apis/nodejs/node_modules/@jest/reporters/build/getSnapshotStatus.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getSnapshotStatus;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const ARROW = ' \u203A ';
|
||||
const DOT = ' \u2022 ';
|
||||
const FAIL_COLOR = _chalk().default.bold.red;
|
||||
const SNAPSHOT_ADDED = _chalk().default.bold.green;
|
||||
const SNAPSHOT_UPDATED = _chalk().default.bold.green;
|
||||
const SNAPSHOT_OUTDATED = _chalk().default.bold.yellow;
|
||||
function getSnapshotStatus(snapshot, afterUpdate) {
|
||||
const statuses = [];
|
||||
if (snapshot.added) {
|
||||
statuses.push(
|
||||
SNAPSHOT_ADDED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshot.added)
|
||||
} written.`
|
||||
)
|
||||
);
|
||||
}
|
||||
if (snapshot.updated) {
|
||||
statuses.push(
|
||||
SNAPSHOT_UPDATED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshot.updated)
|
||||
} updated.`
|
||||
)
|
||||
);
|
||||
}
|
||||
if (snapshot.unmatched) {
|
||||
statuses.push(
|
||||
FAIL_COLOR(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshot.unmatched)
|
||||
} failed.`
|
||||
)
|
||||
);
|
||||
}
|
||||
if (snapshot.unchecked) {
|
||||
if (afterUpdate) {
|
||||
statuses.push(
|
||||
SNAPSHOT_UPDATED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshot.unchecked)
|
||||
} removed.`
|
||||
)
|
||||
);
|
||||
} else {
|
||||
statuses.push(
|
||||
`${SNAPSHOT_OUTDATED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshot.unchecked)
|
||||
} obsolete`
|
||||
)}.`
|
||||
);
|
||||
}
|
||||
snapshot.uncheckedKeys.forEach(key => {
|
||||
statuses.push(` ${DOT}${key}`);
|
||||
});
|
||||
}
|
||||
if (snapshot.fileDeleted) {
|
||||
statuses.push(SNAPSHOT_UPDATED(`${ARROW}snapshot file removed.`));
|
||||
}
|
||||
return statuses;
|
||||
}
|
169
backend/apis/nodejs/node_modules/@jest/reporters/build/getSnapshotSummary.js
generated
vendored
Normal file
169
backend/apis/nodejs/node_modules/@jest/reporters/build/getSnapshotSummary.js
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getSnapshotSummary;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _formatTestPath = _interopRequireDefault(require('./formatTestPath'));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const ARROW = ' \u203A ';
|
||||
const DOWN_ARROW = ' \u21B3 ';
|
||||
const DOT = ' \u2022 ';
|
||||
const FAIL_COLOR = _chalk().default.bold.red;
|
||||
const OBSOLETE_COLOR = _chalk().default.bold.yellow;
|
||||
const SNAPSHOT_ADDED = _chalk().default.bold.green;
|
||||
const SNAPSHOT_NOTE = _chalk().default.dim;
|
||||
const SNAPSHOT_REMOVED = _chalk().default.bold.green;
|
||||
const SNAPSHOT_SUMMARY = _chalk().default.bold;
|
||||
const SNAPSHOT_UPDATED = _chalk().default.bold.green;
|
||||
function getSnapshotSummary(snapshots, globalConfig, updateCommand) {
|
||||
const summary = [];
|
||||
summary.push(SNAPSHOT_SUMMARY('Snapshot Summary'));
|
||||
if (snapshots.added) {
|
||||
summary.push(
|
||||
`${SNAPSHOT_ADDED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshots.added)
|
||||
} written `
|
||||
)}from ${(0, _jestUtil().pluralize)('test suite', snapshots.filesAdded)}.`
|
||||
);
|
||||
}
|
||||
if (snapshots.unmatched) {
|
||||
summary.push(
|
||||
`${FAIL_COLOR(
|
||||
`${ARROW}${(0, _jestUtil().pluralize)(
|
||||
'snapshot',
|
||||
snapshots.unmatched
|
||||
)} failed`
|
||||
)} from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.filesUnmatched
|
||||
)}. ${SNAPSHOT_NOTE(
|
||||
`Inspect your code changes or ${updateCommand} to update them.`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
if (snapshots.updated) {
|
||||
summary.push(
|
||||
`${SNAPSHOT_UPDATED(
|
||||
`${
|
||||
ARROW + (0, _jestUtil().pluralize)('snapshot', snapshots.updated)
|
||||
} updated `
|
||||
)}from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.filesUpdated
|
||||
)}.`
|
||||
);
|
||||
}
|
||||
if (snapshots.filesRemoved) {
|
||||
if (snapshots.didUpdate) {
|
||||
summary.push(
|
||||
`${SNAPSHOT_REMOVED(
|
||||
`${ARROW}${(0, _jestUtil().pluralize)(
|
||||
'snapshot file',
|
||||
snapshots.filesRemoved
|
||||
)} removed `
|
||||
)}from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.filesRemoved
|
||||
)}.`
|
||||
);
|
||||
} else {
|
||||
summary.push(
|
||||
`${OBSOLETE_COLOR(
|
||||
`${ARROW}${(0, _jestUtil().pluralize)(
|
||||
'snapshot file',
|
||||
snapshots.filesRemoved
|
||||
)} obsolete `
|
||||
)}from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.filesRemoved
|
||||
)}. ${SNAPSHOT_NOTE(
|
||||
`To remove ${
|
||||
snapshots.filesRemoved === 1 ? 'it' : 'them all'
|
||||
}, ${updateCommand}.`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
||||
const [head, ...tail] = snapshots.filesRemovedList;
|
||||
summary.push(
|
||||
` ${DOWN_ARROW} ${DOT}${(0, _formatTestPath.default)(
|
||||
globalConfig,
|
||||
head
|
||||
)}`
|
||||
);
|
||||
tail.forEach(key => {
|
||||
summary.push(
|
||||
` ${DOT}${(0, _formatTestPath.default)(globalConfig, key)}`
|
||||
);
|
||||
});
|
||||
}
|
||||
if (snapshots.unchecked) {
|
||||
if (snapshots.didUpdate) {
|
||||
summary.push(
|
||||
`${SNAPSHOT_REMOVED(
|
||||
`${ARROW}${(0, _jestUtil().pluralize)(
|
||||
'snapshot',
|
||||
snapshots.unchecked
|
||||
)} removed `
|
||||
)}from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.uncheckedKeysByFile.length
|
||||
)}.`
|
||||
);
|
||||
} else {
|
||||
summary.push(
|
||||
`${OBSOLETE_COLOR(
|
||||
`${ARROW}${(0, _jestUtil().pluralize)(
|
||||
'snapshot',
|
||||
snapshots.unchecked
|
||||
)} obsolete `
|
||||
)}from ${(0, _jestUtil().pluralize)(
|
||||
'test suite',
|
||||
snapshots.uncheckedKeysByFile.length
|
||||
)}. ${SNAPSHOT_NOTE(
|
||||
`To remove ${
|
||||
snapshots.unchecked === 1 ? 'it' : 'them all'
|
||||
}, ${updateCommand}.`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
snapshots.uncheckedKeysByFile.forEach(uncheckedFile => {
|
||||
summary.push(
|
||||
` ${DOWN_ARROW}${(0, _formatTestPath.default)(
|
||||
globalConfig,
|
||||
uncheckedFile.filePath
|
||||
)}`
|
||||
);
|
||||
uncheckedFile.keys.forEach(key => {
|
||||
summary.push(` ${DOT}${key}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
return summary;
|
||||
}
|
206
backend/apis/nodejs/node_modules/@jest/reporters/build/getSummary.js
generated
vendored
Normal file
206
backend/apis/nodejs/node_modules/@jest/reporters/build/getSummary.js
generated
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.PROGRESS_BAR_WIDTH = void 0;
|
||||
exports.default = getSummary;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const PROGRESS_BAR_WIDTH = 40;
|
||||
exports.PROGRESS_BAR_WIDTH = PROGRESS_BAR_WIDTH;
|
||||
function getValuesCurrentTestCases(currentTestCases = []) {
|
||||
let numFailingTests = 0;
|
||||
let numPassingTests = 0;
|
||||
let numPendingTests = 0;
|
||||
let numTodoTests = 0;
|
||||
let numTotalTests = 0;
|
||||
currentTestCases.forEach(testCase => {
|
||||
switch (testCase.testCaseResult.status) {
|
||||
case 'failed': {
|
||||
numFailingTests++;
|
||||
break;
|
||||
}
|
||||
case 'passed': {
|
||||
numPassingTests++;
|
||||
break;
|
||||
}
|
||||
case 'skipped': {
|
||||
numPendingTests++;
|
||||
break;
|
||||
}
|
||||
case 'todo': {
|
||||
numTodoTests++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
numTotalTests++;
|
||||
});
|
||||
return {
|
||||
numFailingTests,
|
||||
numPassingTests,
|
||||
numPendingTests,
|
||||
numTodoTests,
|
||||
numTotalTests
|
||||
};
|
||||
}
|
||||
function renderTime(runTime, estimatedTime, width) {
|
||||
// If we are more than one second over the estimated time, highlight it.
|
||||
const renderedTime =
|
||||
estimatedTime && runTime >= estimatedTime + 1
|
||||
? _chalk().default.bold.yellow((0, _jestUtil().formatTime)(runTime, 0))
|
||||
: (0, _jestUtil().formatTime)(runTime, 0);
|
||||
let time = `${_chalk().default.bold('Time:')} ${renderedTime}`;
|
||||
if (runTime < estimatedTime) {
|
||||
time += `, estimated ${(0, _jestUtil().formatTime)(estimatedTime, 0)}`;
|
||||
}
|
||||
|
||||
// Only show a progress bar if the test run is actually going to take
|
||||
// some time.
|
||||
if (estimatedTime > 2 && runTime < estimatedTime && width) {
|
||||
const availableWidth = Math.min(PROGRESS_BAR_WIDTH, width);
|
||||
const length = Math.min(
|
||||
Math.floor((runTime / estimatedTime) * availableWidth),
|
||||
availableWidth
|
||||
);
|
||||
if (availableWidth >= 2) {
|
||||
time += `\n${_chalk().default.green('█').repeat(length)}${_chalk()
|
||||
.default.white('█')
|
||||
.repeat(availableWidth - length)}`;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
function getSummary(aggregatedResults, options) {
|
||||
let runTime = (Date.now() - aggregatedResults.startTime) / 1000;
|
||||
if (options && options.roundTime) {
|
||||
runTime = Math.floor(runTime);
|
||||
}
|
||||
const valuesForCurrentTestCases = getValuesCurrentTestCases(
|
||||
options?.currentTestCases
|
||||
);
|
||||
const estimatedTime = (options && options.estimatedTime) || 0;
|
||||
const snapshotResults = aggregatedResults.snapshot;
|
||||
const snapshotsAdded = snapshotResults.added;
|
||||
const snapshotsFailed = snapshotResults.unmatched;
|
||||
const snapshotsOutdated = snapshotResults.unchecked;
|
||||
const snapshotsFilesRemoved = snapshotResults.filesRemoved;
|
||||
const snapshotsDidUpdate = snapshotResults.didUpdate;
|
||||
const snapshotsPassed = snapshotResults.matched;
|
||||
const snapshotsTotal = snapshotResults.total;
|
||||
const snapshotsUpdated = snapshotResults.updated;
|
||||
const suitesFailed = aggregatedResults.numFailedTestSuites;
|
||||
const suitesPassed = aggregatedResults.numPassedTestSuites;
|
||||
const suitesPending = aggregatedResults.numPendingTestSuites;
|
||||
const suitesRun = suitesFailed + suitesPassed;
|
||||
const suitesTotal = aggregatedResults.numTotalTestSuites;
|
||||
const testsFailed = aggregatedResults.numFailedTests;
|
||||
const testsPassed = aggregatedResults.numPassedTests;
|
||||
const testsPending = aggregatedResults.numPendingTests;
|
||||
const testsTodo = aggregatedResults.numTodoTests;
|
||||
const testsTotal = aggregatedResults.numTotalTests;
|
||||
const width = (options && options.width) || 0;
|
||||
const optionalLines = [];
|
||||
if (options?.showSeed === true) {
|
||||
const {seed} = options;
|
||||
if (seed === undefined) {
|
||||
throw new Error('Attempted to display seed but seed value is undefined');
|
||||
}
|
||||
optionalLines.push(`${_chalk().default.bold('Seed: ') + seed}`);
|
||||
}
|
||||
const suites = `${
|
||||
_chalk().default.bold('Test Suites: ') +
|
||||
(suitesFailed
|
||||
? `${_chalk().default.bold.red(`${suitesFailed} failed`)}, `
|
||||
: '') +
|
||||
(suitesPending
|
||||
? `${_chalk().default.bold.yellow(`${suitesPending} skipped`)}, `
|
||||
: '') +
|
||||
(suitesPassed
|
||||
? `${_chalk().default.bold.green(`${suitesPassed} passed`)}, `
|
||||
: '') +
|
||||
(suitesRun !== suitesTotal ? `${suitesRun} of ${suitesTotal}` : suitesTotal)
|
||||
} total`;
|
||||
const updatedTestsFailed =
|
||||
testsFailed + valuesForCurrentTestCases.numFailingTests;
|
||||
const updatedTestsPending =
|
||||
testsPending + valuesForCurrentTestCases.numPendingTests;
|
||||
const updatedTestsTodo = testsTodo + valuesForCurrentTestCases.numTodoTests;
|
||||
const updatedTestsPassed =
|
||||
testsPassed + valuesForCurrentTestCases.numPassingTests;
|
||||
const updatedTestsTotal =
|
||||
testsTotal + valuesForCurrentTestCases.numTotalTests;
|
||||
const tests = `${
|
||||
_chalk().default.bold('Tests: ') +
|
||||
(updatedTestsFailed > 0
|
||||
? `${_chalk().default.bold.red(`${updatedTestsFailed} failed`)}, `
|
||||
: '') +
|
||||
(updatedTestsPending > 0
|
||||
? `${_chalk().default.bold.yellow(`${updatedTestsPending} skipped`)}, `
|
||||
: '') +
|
||||
(updatedTestsTodo > 0
|
||||
? `${_chalk().default.bold.magenta(`${updatedTestsTodo} todo`)}, `
|
||||
: '') +
|
||||
(updatedTestsPassed > 0
|
||||
? `${_chalk().default.bold.green(`${updatedTestsPassed} passed`)}, `
|
||||
: '')
|
||||
}${updatedTestsTotal} total`;
|
||||
const snapshots = `${
|
||||
_chalk().default.bold('Snapshots: ') +
|
||||
(snapshotsFailed
|
||||
? `${_chalk().default.bold.red(`${snapshotsFailed} failed`)}, `
|
||||
: '') +
|
||||
(snapshotsOutdated && !snapshotsDidUpdate
|
||||
? `${_chalk().default.bold.yellow(`${snapshotsOutdated} obsolete`)}, `
|
||||
: '') +
|
||||
(snapshotsOutdated && snapshotsDidUpdate
|
||||
? `${_chalk().default.bold.green(`${snapshotsOutdated} removed`)}, `
|
||||
: '') +
|
||||
(snapshotsFilesRemoved && !snapshotsDidUpdate
|
||||
? `${_chalk().default.bold.yellow(
|
||||
`${(0, _jestUtil().pluralize)(
|
||||
'file',
|
||||
snapshotsFilesRemoved
|
||||
)} obsolete`
|
||||
)}, `
|
||||
: '') +
|
||||
(snapshotsFilesRemoved && snapshotsDidUpdate
|
||||
? `${_chalk().default.bold.green(
|
||||
`${(0, _jestUtil().pluralize)('file', snapshotsFilesRemoved)} removed`
|
||||
)}, `
|
||||
: '') +
|
||||
(snapshotsUpdated
|
||||
? `${_chalk().default.bold.green(`${snapshotsUpdated} updated`)}, `
|
||||
: '') +
|
||||
(snapshotsAdded
|
||||
? `${_chalk().default.bold.green(`${snapshotsAdded} written`)}, `
|
||||
: '') +
|
||||
(snapshotsPassed
|
||||
? `${_chalk().default.bold.green(`${snapshotsPassed} passed`)}, `
|
||||
: '')
|
||||
}${snapshotsTotal} total`;
|
||||
const time = renderTime(runTime, estimatedTime, width);
|
||||
return [...optionalLines, suites, tests, snapshots, time].join('\n');
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user