Set up comprehensive frontend testing infrastructure
- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1
frontend/node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
118
frontend/node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
118
frontend/node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.backportTsJestDebugEnvVar = exports.backportJestConfig = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const messages_1 = require("./messages");
|
||||
const context = { [bs_logger_1.LogContexts.namespace]: 'backports' };
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportJestConfig = (logger, config) => {
|
||||
logger.debug({ ...context, config }, 'backporting config');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const { globals = {} } = (config || {});
|
||||
const { 'ts-jest': tsJest = {} } = globals;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const mergeTsJest = {};
|
||||
let hadWarnings = false;
|
||||
const warnConfig = (oldPath, newPath, note) => {
|
||||
hadWarnings = true;
|
||||
logger.warn(context, (0, messages_1.interpolate)(note ? "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead.\n \u21B3 {{note}}" /* Deprecations.ConfigOptionWithNote */ : "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead." /* Deprecations.ConfigOption */, {
|
||||
oldPath,
|
||||
newPath,
|
||||
note,
|
||||
}));
|
||||
};
|
||||
if ('__TS_CONFIG__' in globals) {
|
||||
warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsconfig');
|
||||
if (typeof globals.__TS_CONFIG__ === 'object') {
|
||||
mergeTsJest.tsconfig = globals.__TS_CONFIG__;
|
||||
}
|
||||
delete globals.__TS_CONFIG__;
|
||||
}
|
||||
if ('__TRANSFORM_HTML__' in globals) {
|
||||
warnConfig('globals.__TRANSFORM_HTML__', 'globals.ts-jest.stringifyContentPathRegex');
|
||||
if (globals.__TRANSFORM_HTML__) {
|
||||
mergeTsJest.stringifyContentPathRegex = '\\.html?$';
|
||||
}
|
||||
delete globals.__TRANSFORM_HTML__;
|
||||
}
|
||||
if ('typeCheck' in tsJest) {
|
||||
warnConfig('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules');
|
||||
mergeTsJest.isolatedModules = !tsJest.typeCheck;
|
||||
delete tsJest.typeCheck;
|
||||
}
|
||||
if ('tsConfigFile' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfigFile) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfigFile;
|
||||
}
|
||||
delete tsJest.tsConfigFile;
|
||||
}
|
||||
if ('tsConfig' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfig) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfig;
|
||||
}
|
||||
delete tsJest.tsConfig;
|
||||
}
|
||||
if ('enableTsDiagnostics' in tsJest) {
|
||||
warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics');
|
||||
if (tsJest.enableTsDiagnostics) {
|
||||
mergeTsJest.diagnostics = { warnOnly: true };
|
||||
if (typeof tsJest.enableTsDiagnostics === 'string')
|
||||
mergeTsJest.diagnostics.exclude = [tsJest.enableTsDiagnostics];
|
||||
}
|
||||
else {
|
||||
mergeTsJest.diagnostics = false;
|
||||
}
|
||||
delete tsJest.enableTsDiagnostics;
|
||||
}
|
||||
if ('useBabelrc' in tsJest) {
|
||||
warnConfig('globals.ts-jest.useBabelrc', 'globals.ts-jest.babelConfig', "See `babel-jest` related issue: https://github.com/facebook/jest/issues/3845" /* Deprecations.ConfigOptionUseBabelRcNote */);
|
||||
if (tsJest.useBabelrc != null) {
|
||||
mergeTsJest.babelConfig = tsJest.useBabelrc ? true : {};
|
||||
}
|
||||
delete tsJest.useBabelrc;
|
||||
}
|
||||
if ('skipBabel' in tsJest) {
|
||||
warnConfig('globals.ts-jest.skipBabel', 'globals.ts-jest.babelConfig');
|
||||
if (tsJest.skipBabel === false && !mergeTsJest.babelConfig) {
|
||||
mergeTsJest.babelConfig = true;
|
||||
}
|
||||
delete tsJest.skipBabel;
|
||||
}
|
||||
// if we had some warnings we can inform the user about the CLI tool
|
||||
if (hadWarnings) {
|
||||
logger.warn(context, "Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>." /* Helps.MigrateConfigUsingCLI */);
|
||||
}
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
...config,
|
||||
globals: {
|
||||
...globals,
|
||||
'ts-jest': {
|
||||
...mergeTsJest,
|
||||
...tsJest,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.backportJestConfig = backportJestConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportTsJestDebugEnvVar = (logger) => {
|
||||
if ('TS_JEST_DEBUG' in process.env) {
|
||||
const shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '');
|
||||
delete process.env.TS_JEST_DEBUG;
|
||||
if (shouldLog) {
|
||||
process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn';
|
||||
}
|
||||
logger.warn(context, (0, messages_1.interpolate)("Using env. var \"{{old}}\" is deprecated, use \"{{new}}\" instead." /* Deprecations.EnvVar */, {
|
||||
old: 'TS_JEST_DEBUG',
|
||||
new: 'TS_JEST_LOG',
|
||||
}));
|
||||
}
|
||||
};
|
||||
exports.backportTsJestDebugEnvVar = backportTsJestDebugEnvVar;
|
||||
1
frontend/node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
14
frontend/node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
14
frontend/node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPackageVersion = getPackageVersion;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getPackageVersion(moduleName) {
|
||||
try {
|
||||
return require(`${moduleName}/package.json`).version;
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
146
frontend/node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
146
frontend/node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.importer = exports.Importer = void 0;
|
||||
exports.__requireModule = __requireModule;
|
||||
const logger_1 = require("./logger");
|
||||
const memoize_1 = require("./memoize");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'Importer' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Importer {
|
||||
static get instance() {
|
||||
logger.debug('creating Importer singleton');
|
||||
return new Importer();
|
||||
}
|
||||
babelJest(why) {
|
||||
return this._import(why, 'babel-jest');
|
||||
}
|
||||
babelCore(why) {
|
||||
return this._import(why, '@babel/core');
|
||||
}
|
||||
typescript(why, which) {
|
||||
return this._import(why, which);
|
||||
}
|
||||
esBuild(why) {
|
||||
return this._import(why, 'esbuild');
|
||||
}
|
||||
tryThese(moduleName, ...fallbacks) {
|
||||
let name;
|
||||
let loaded;
|
||||
const tries = [moduleName, ...fallbacks];
|
||||
while ((name = tries.shift()) !== undefined) {
|
||||
const req = requireWrapper(name);
|
||||
// remove exports from what we're going to log
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const contextReq = { ...req };
|
||||
delete contextReq.exports;
|
||||
if (req.exists) {
|
||||
// module exists
|
||||
loaded = req;
|
||||
if (req.error) {
|
||||
logger.error({ requireResult: contextReq }, `failed loading module '${name}'`, req.error.message);
|
||||
}
|
||||
else {
|
||||
logger.debug({ requireResult: contextReq }, 'loaded module', name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// module does not exists in the path
|
||||
logger.debug({ requireResult: contextReq }, `module '${name}' not found`);
|
||||
}
|
||||
}
|
||||
// return the loaded one, could be one that has been loaded, or one which has failed during load
|
||||
// but not one which does not exists
|
||||
return loaded;
|
||||
}
|
||||
tryTheseOr(moduleNames, missingResult, allowLoadError = false) {
|
||||
const args = Array.isArray(moduleNames) ? moduleNames : [moduleNames];
|
||||
const result = this.tryThese(...args);
|
||||
if (!result)
|
||||
return missingResult;
|
||||
if (!result.error)
|
||||
return result.exports;
|
||||
if (allowLoadError)
|
||||
return missingResult;
|
||||
throw result.error;
|
||||
}
|
||||
_import(why, moduleName, { alternatives = [], installTip = moduleName } = {}) {
|
||||
// try to load any of the alternative after trying main one
|
||||
const res = this.tryThese(moduleName, ...alternatives);
|
||||
// if we could load one, return it
|
||||
if (res?.exists) {
|
||||
if (!res.error)
|
||||
return res.exports;
|
||||
// it could not load because of a failure while importing, but it exists
|
||||
throw new Error((0, messages_1.interpolate)("Loading module {{module}} failed with error: {{error}}" /* Errors.LoadingModuleFailed */, { module: res.given, error: res.error.message }));
|
||||
}
|
||||
// if it couldn't load, build a nice error message so the user can fix it by himself
|
||||
const msg = alternatives.length ? "Unable to load any of these modules: {{module}}. {{reason}}. To fix it:\n{{fix}}" /* Errors.UnableToLoadAnyModule */ : "Unable to load the module {{module}}. {{reason}} To fix it:\n{{fix}}" /* Errors.UnableToLoadOneModule */;
|
||||
const loadModule = [moduleName, ...alternatives].map((m) => `"${m}"`).join(', ');
|
||||
if (typeof installTip === 'string') {
|
||||
installTip = [{ module: installTip, label: `install "${installTip}"` }];
|
||||
}
|
||||
const fix = installTip
|
||||
.map((tip) => ` ${installTip.length === 1 ? '↳' : '•'} ${(0, messages_1.interpolate)("{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)" /* Helps.FixMissingModule */, tip)}`)
|
||||
.join('\n');
|
||||
throw new Error((0, messages_1.interpolate)(msg, {
|
||||
module: loadModule,
|
||||
reason: why,
|
||||
fix,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.Importer = Importer;
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)((...args) => args.join(':'))
|
||||
], Importer.prototype, "tryThese", null);
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)()
|
||||
], Importer, "instance", null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.importer = Importer.instance;
|
||||
function requireWrapper(moduleName) {
|
||||
let path;
|
||||
let exists = false;
|
||||
try {
|
||||
path = resolveModule(moduleName);
|
||||
exists = true;
|
||||
}
|
||||
catch (error) {
|
||||
return { error: error, exists, given: moduleName };
|
||||
}
|
||||
const result = { exists, path, given: moduleName };
|
||||
try {
|
||||
result.exports = requireModule(path);
|
||||
}
|
||||
catch {
|
||||
try {
|
||||
result.exports = requireModule(moduleName);
|
||||
}
|
||||
catch (error) {
|
||||
result.error = error;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
let requireModule = (mod) => require(mod);
|
||||
let resolveModule = (mod) => require.resolve(mod, { paths: [process.cwd(), __dirname] });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// so that we can test easier
|
||||
function __requireModule(localRequire, localResolve) {
|
||||
requireModule = localRequire;
|
||||
resolveModule = localResolve;
|
||||
}
|
||||
3
frontend/node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
3
frontend/node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './json';
|
||||
export * from './jsonable-value';
|
||||
export * from './logger';
|
||||
19
frontend/node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
19
frontend/node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./json"), exports);
|
||||
__exportStar(require("./jsonable-value"), exports);
|
||||
__exportStar(require("./logger"), exports);
|
||||
2
frontend/node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
2
frontend/node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function stringify(input: unknown): string;
|
||||
export declare function parse(input: string): any;
|
||||
16
frontend/node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
16
frontend/node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringify = stringify;
|
||||
exports.parse = parse;
|
||||
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
||||
const UNDEFINED = 'undefined';
|
||||
function stringify(input) {
|
||||
return input === undefined ? UNDEFINED : (0, fast_json_stable_stringify_1.default)(input);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function parse(input) {
|
||||
return input === UNDEFINED ? undefined : JSON.parse(input);
|
||||
}
|
||||
10
frontend/node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
10
frontend/node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare class JsonableValue<V = Record<string, any>> {
|
||||
private _serialized;
|
||||
private _value;
|
||||
constructor(value: V);
|
||||
set value(value: V);
|
||||
get value(): V;
|
||||
get serialized(): string;
|
||||
valueOf(): V;
|
||||
toString(): string;
|
||||
}
|
||||
29
frontend/node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
29
frontend/node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JsonableValue = void 0;
|
||||
const json_1 = require("./json");
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
class JsonableValue {
|
||||
_serialized;
|
||||
_value;
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
set value(value) {
|
||||
this._value = value;
|
||||
this._serialized = (0, json_1.stringify)(value);
|
||||
}
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
get serialized() {
|
||||
return this._serialized;
|
||||
}
|
||||
valueOf() {
|
||||
return this._value;
|
||||
}
|
||||
toString() {
|
||||
return this._serialized;
|
||||
}
|
||||
}
|
||||
exports.JsonableValue = JsonableValue;
|
||||
1
frontend/node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare let rootLogger: import("bs-logger").Logger;
|
||||
20
frontend/node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
20
frontend/node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.rootLogger = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const backports_1 = require("./backports");
|
||||
const original = process.env.TS_JEST_LOG;
|
||||
const buildOptions = () => ({
|
||||
context: {
|
||||
[bs_logger_1.LogContexts.package]: 'ts-jest',
|
||||
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
||||
version: require('../../package.json').version,
|
||||
},
|
||||
targets: process.env.TS_JEST_LOG ?? undefined,
|
||||
});
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
(0, backports_1.backportTsJestDebugEnvVar)(exports.rootLogger);
|
||||
// re-create the logger if the env var has been backported
|
||||
if (original !== process.env.TS_JEST_LOG) {
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
60
frontend/node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
60
frontend/node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Memoize = Memoize;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cacheProp = Symbol.for('[memoize]');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function Memoize(keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (_, propertyKey, descriptor) => {
|
||||
if (descriptor.value != null) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
|
||||
}
|
||||
else if (descriptor.get != null) {
|
||||
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
|
||||
}
|
||||
};
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureCache(target, reset = false) {
|
||||
if (reset || !target[cacheProp]) {
|
||||
Object.defineProperty(target, cacheProp, {
|
||||
value: Object.create(null),
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
return target[cacheProp];
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureChildCache(target, key, reset = false) {
|
||||
const dict = ensureCache(target);
|
||||
if (reset || !dict[key]) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
dict[key] = new Map();
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return dict[key];
|
||||
}
|
||||
function memoize(namespace,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
func,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return function (...args) {
|
||||
const cache = ensureChildCache(this, namespace);
|
||||
const key = keyBuilder.apply(this, args);
|
||||
if (cache.has(key))
|
||||
return cache.get(key);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = func.apply(this, args);
|
||||
cache.set(key, res);
|
||||
return res;
|
||||
};
|
||||
}
|
||||
4
frontend/node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
4
frontend/node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const TsJestDiagnosticCodes: {
|
||||
readonly Generic: 151000;
|
||||
readonly ConfigModuleOption: 151001;
|
||||
};
|
||||
16
frontend/node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
16
frontend/node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestDiagnosticCodes = void 0;
|
||||
exports.interpolate = interpolate;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function interpolate(msg, vars = {}) {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _));
|
||||
}
|
||||
exports.TsJestDiagnosticCodes = {
|
||||
Generic: 151000,
|
||||
ConfigModuleOption: 151001,
|
||||
};
|
||||
1
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
9
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
9
frontend/node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeSlashes = normalizeSlashes;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function normalizeSlashes(value) {
|
||||
return value.replace(/\\/g, '/');
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
38
frontend/node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
38
frontend/node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cache = void 0;
|
||||
exports.sha1 = sha1;
|
||||
const crypto_1 = require("crypto");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// stores hashes made out of only one argument being a string
|
||||
exports.cache = Object.create(null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function sha1(...data) {
|
||||
const canCache = data.length === 1 && typeof data[0] === 'string';
|
||||
// caching
|
||||
let cacheKey;
|
||||
if (canCache) {
|
||||
cacheKey = data[0];
|
||||
if (cacheKey in exports.cache) {
|
||||
return exports.cache[cacheKey];
|
||||
}
|
||||
}
|
||||
// we use SHA1 because it's the fastest provided by node
|
||||
// and we are not concerned about security here
|
||||
const hash = (0, crypto_1.createHash)('sha1');
|
||||
data.forEach((item) => {
|
||||
if (typeof item === 'string')
|
||||
hash.update(item, 'utf8');
|
||||
else
|
||||
hash.update(item);
|
||||
});
|
||||
const res = hash.digest('hex').toString();
|
||||
if (canCache) {
|
||||
exports.cache[cacheKey] = res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
1
frontend/node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
1
frontend/node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
37
frontend/node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
37
frontend/node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TSError = exports.INSPECT_CUSTOM = void 0;
|
||||
const util_1 = require("util");
|
||||
const make_error_1 = require("make-error");
|
||||
const logger_1 = require("./logger");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'TSError' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
|
||||
/**
|
||||
* TypeScript diagnostics error.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TSError extends make_error_1.BaseError {
|
||||
diagnosticText;
|
||||
diagnosticCodes;
|
||||
name = 'TSError';
|
||||
constructor(diagnosticText, diagnosticCodes) {
|
||||
super((0, messages_1.interpolate)("{{diagnostics}}" /* Errors.UnableToCompileTypeScript */, {
|
||||
diagnostics: diagnosticText.trim(),
|
||||
}));
|
||||
this.diagnosticText = diagnosticText;
|
||||
this.diagnosticCodes = diagnosticCodes;
|
||||
logger.debug({ diagnosticCodes, diagnosticText }, 'created new TSError');
|
||||
// ensure we blacklist any of our code
|
||||
Object.defineProperty(this, 'stack', { value: '' });
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
[exports.INSPECT_CUSTOM]() {
|
||||
return this.diagnosticText;
|
||||
}
|
||||
}
|
||||
exports.TSError = TSError;
|
||||
Reference in New Issue
Block a user