id
int64
0
3.78k
code
stringlengths
13
37.9k
declarations
stringlengths
16
64.6k
1,900
onTestResult( _test?: Test, _testResult?: TestResult, _results?: AggregatedResult, ): void {}
type Test = { context: TestContext; duration?: number; path: string; };
1,901
onTestResult( _test?: Test, _testResult?: TestResult, _results?: AggregatedResult, ): void {}
type Test = (arg0: any) => boolean;
1,902
onTestResult( _test?: Test, _testResult?: TestResult, _results?: AggregatedResult, ): void {}
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,903
onTestResult( _test?: Test, _testResult?: TestResult, _results?: AggregatedResult, ): void {}
type TestResult = { console?: ConsoleBuffer; coverage?: CoverageMapData; displayName?: Config.DisplayName; failureMessage?: string | null; leaks: boolean; memoryUsage?: number; numFailingTests: number; numPassingTests: number; numPendingTests: number; numTodoTests: number; openHandles: Array<Error...
1,904
onTestResult( _test?: Test, _testResult?: TestResult, _results?: AggregatedResult, ): void {}
type TestResult = { duration?: number | null; errors: Array<FormattedError>; errorsDetailed: Array<MatcherResults | unknown>; invocations: number; status: TestStatus; location?: {column: number; line: number} | null; numPassingAsserts: number; retryReasons: Array<FormattedError>; testPath: Array<TestN...
1,905
onTestStart(_test?: Test): void {}
type Test = { context: TestContext; duration?: number; path: string; };
1,906
onTestStart(_test?: Test): void {}
type Test = (arg0: any) => boolean;
1,907
override onRunStart( aggregatedResults: AggregatedResult, options: ReporterOnStartOptions, ): void { super.onRunStart(aggregatedResults, options); this._estimatedTime = options.estimatedTime; }
type ReporterOnStartOptions = { estimatedTime: number; showStatus: boolean; };
1,908
override onRunStart( aggregatedResults: AggregatedResult, options: ReporterOnStartOptions, ): void { super.onRunStart(aggregatedResults, options); this._estimatedTime = options.estimatedTime; }
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,909
private _printSnapshotSummary( snapshots: SnapshotSummary, globalConfig: Config.GlobalConfig, ) { if ( snapshots.added || snapshots.filesRemoved || snapshots.unchecked || snapshots.unmatched || snapshots.updated ) { let updateCommand; const event = npm_lifecyc...
type SnapshotSummary = { added: number; didUpdate: boolean; failure: boolean; filesAdded: number; filesRemoved: number; filesRemovedList: Array<string>; filesUnmatched: number; filesUpdated: number; matched: number; total: number; unchecked: number; uncheckedKeysByFile: Array<UncheckedSnapshot>;...
1,910
private _printSummary( aggregatedResults: AggregatedResult, globalConfig: Config.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...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,911
override onTestResult( test: Test, testResult: TestResult, aggregatedResults: AggregatedResult, ): void { this.generateAnnotations(test, testResult); if (!this.options.silent) { this.printFullResult(test.context, testResult); } if (this.isLastTestSuite(aggregatedResults)) { thi...
type Test = { context: TestContext; duration?: number; path: string; };
1,912
override onTestResult( test: Test, testResult: TestResult, aggregatedResults: AggregatedResult, ): void { this.generateAnnotations(test, testResult); if (!this.options.silent) { this.printFullResult(test.context, testResult); } if (this.isLastTestSuite(aggregatedResults)) { thi...
type Test = (arg0: any) => boolean;
1,913
override onTestResult( test: Test, testResult: TestResult, aggregatedResults: AggregatedResult, ): void { this.generateAnnotations(test, testResult); if (!this.options.silent) { this.printFullResult(test.context, testResult); } if (this.isLastTestSuite(aggregatedResults)) { thi...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,914
override onTestResult( test: Test, testResult: TestResult, aggregatedResults: AggregatedResult, ): void { this.generateAnnotations(test, testResult); if (!this.options.silent) { this.printFullResult(test.context, testResult); } if (this.isLastTestSuite(aggregatedResults)) { thi...
type TestResult = { console?: ConsoleBuffer; coverage?: CoverageMapData; displayName?: Config.DisplayName; failureMessage?: string | null; leaks: boolean; memoryUsage?: number; numFailingTests: number; numPassingTests: number; numPendingTests: number; numTodoTests: number; openHandles: Array<Error...
1,915
override onTestResult( test: Test, testResult: TestResult, aggregatedResults: AggregatedResult, ): void { this.generateAnnotations(test, testResult); if (!this.options.silent) { this.printFullResult(test.context, testResult); } if (this.isLastTestSuite(aggregatedResults)) { thi...
type TestResult = { duration?: number | null; errors: Array<FormattedError>; errorsDetailed: Array<MatcherResults | unknown>; invocations: number; status: TestStatus; location?: {column: number; line: number} | null; numPassingAsserts: number; retryReasons: Array<FormattedError>; testPath: Array<TestN...
1,916
private generateAnnotations( {context}: Test, {testResults}: TestResult, ): void { testResults.forEach(result => { const title = [...result.ancestorTitles, result.title].join( titleSeparator, ); result.retryReasons?.forEach((retryReason, index) => { this.#createAnnotatio...
type Test = { context: TestContext; duration?: number; path: string; };
1,917
private generateAnnotations( {context}: Test, {testResults}: TestResult, ): void { testResults.forEach(result => { const title = [...result.ancestorTitles, result.title].join( titleSeparator, ); result.retryReasons?.forEach((retryReason, index) => { this.#createAnnotatio...
type Test = (arg0: any) => boolean;
1,918
private generateAnnotations( {context}: Test, {testResults}: TestResult, ): void { testResults.forEach(result => { const title = [...result.ancestorTitles, result.title].join( titleSeparator, ); result.retryReasons?.forEach((retryReason, index) => { this.#createAnnotatio...
type TestResult = { console?: ConsoleBuffer; coverage?: CoverageMapData; displayName?: Config.DisplayName; failureMessage?: string | null; leaks: boolean; memoryUsage?: number; numFailingTests: number; numPassingTests: number; numPendingTests: number; numTodoTests: number; openHandles: Array<Error...
1,919
private generateAnnotations( {context}: Test, {testResults}: TestResult, ): void { testResults.forEach(result => { const title = [...result.ancestorTitles, result.title].join( titleSeparator, ); result.retryReasons?.forEach((retryReason, index) => { this.#createAnnotatio...
type TestResult = { duration?: number | null; errors: Array<FormattedError>; errorsDetailed: Array<MatcherResults | unknown>; invocations: number; status: TestStatus; location?: {column: number; line: number} | null; numPassingAsserts: number; retryReasons: Array<FormattedError>; testPath: Array<TestN...
1,920
#createAnnotation({file, line, message, title, type}: AnnotationOptions) { message = stripAnsi( // 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} fil...
type AnnotationOptions = { file?: string; line?: number | string; message: string; title: string; type: 'error' | 'warning'; };
1,921
private isLastTestSuite(results: AggregatedResult): boolean { const passedTestSuites = results.numPassedTestSuites; const failedTestSuites = results.numFailedTestSuites; const totalTestSuites = results.numTotalTestSuites; const computedTotal = passedTestSuites + failedTestSuites; if (computedTotal <...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,922
private printFullResult(context: TestContext, results: TestResult): void { const rootDir = context.config.rootDir; let testDir = results.testFilePath.replace(rootDir, ''); testDir = testDir.slice(1, testDir.length); const resultTree = this.getResultTree( results.testResults, testDir, r...
type TestContext = { config: Config.ProjectConfig; hasteFS: IHasteFS; moduleMap: IModuleMap; resolver: Resolver; };
1,923
private printFullResult(context: TestContext, results: TestResult): void { const rootDir = context.config.rootDir; let testDir = results.testFilePath.replace(rootDir, ''); testDir = testDir.slice(1, testDir.length); const resultTree = this.getResultTree( results.testResults, testDir, r...
type TestContext = Record<string, unknown>;
1,924
private printFullResult(context: TestContext, results: TestResult): void { const rootDir = context.config.rootDir; let testDir = results.testFilePath.replace(rootDir, ''); testDir = testDir.slice(1, testDir.length); const resultTree = this.getResultTree( results.testResults, testDir, r...
type TestContext = Global.TestContext;
1,925
private printFullResult(context: TestContext, results: TestResult): void { const rootDir = context.config.rootDir; let testDir = results.testFilePath.replace(rootDir, ''); testDir = testDir.slice(1, testDir.length); const resultTree = this.getResultTree( results.testResults, testDir, r...
type TestResult = { console?: ConsoleBuffer; coverage?: CoverageMapData; displayName?: Config.DisplayName; failureMessage?: string | null; leaks: boolean; memoryUsage?: number; numFailingTests: number; numPassingTests: number; numPendingTests: number; numTodoTests: number; openHandles: Array<Error...
1,926
private printFullResult(context: TestContext, results: TestResult): void { const rootDir = context.config.rootDir; let testDir = results.testFilePath.replace(rootDir, ''); testDir = testDir.slice(1, testDir.length); const resultTree = this.getResultTree( results.testResults, testDir, r...
type TestResult = { duration?: number | null; errors: Array<FormattedError>; errorsDetailed: Array<MatcherResults | unknown>; invocations: number; status: TestStatus; location?: {column: number; line: number} | null; numPassingAsserts: number; retryReasons: Array<FormattedError>; testPath: Array<TestN...
1,927
private printResultTree(resultTree: ResultTree): void { let perfMs; if (resultTree.performanceInfo.slow) { perfMs = ` (${chalk.red.inverse( `${resultTree.performanceInfo.runtime} ms`, )})`; } else { perfMs = ` (${resultTree.performanceInfo.runtime} ms)`; } if (resultTree.pa...
type ResultTree = { children: Array<ResultTreeLeaf | ResultTreeNode>; name: string; passed: boolean; performanceInfo: PerformanceInfo; };
1,928
private printFailedTestLogs( context: Test, testResults: AggregatedResult, ): boolean { const rootDir = context.context.config.rootDir; const results = testResults.testResults; let written = false; results.forEach(result => { let testDir = result.testFilePath; testDir = testDir.rep...
type Test = { context: TestContext; duration?: number; path: string; };
1,929
private printFailedTestLogs( context: Test, testResults: AggregatedResult, ): boolean { const rootDir = context.context.config.rootDir; const results = testResults.testResults; let written = false; results.forEach(result => { let testDir = result.testFilePath; testDir = testDir.rep...
type Test = (arg0: any) => boolean;
1,930
private printFailedTestLogs( context: Test, testResults: AggregatedResult, ): boolean { const rootDir = context.context.config.rootDir; const results = testResults.testResults; let written = false; results.forEach(result => { let testDir = result.testFilePath; testDir = testDir.rep...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,931
function worker({ config, globalConfig, path, context, }: CoverageWorkerData): Promise<CoverageWorkerResult | null> { return generateEmptyCoverage( fs.readFileSync(path, 'utf8'), path, globalConfig, config, context.changedFiles && new Set(context.changedFiles), context.sourcesRelatedTo...
type CoverageWorkerData = { config: Config.ProjectConfig; context: CoverageReporterSerializedContext; globalConfig: Config.GlobalConfig; path: string; };
1,932
function getSnapshotSummary( snapshots: SnapshotSummary, globalConfig: Config.GlobalConfig, updateCommand: string, ): Array<string> { const summary = []; summary.push(SNAPSHOT_SUMMARY('Snapshot Summary')); if (snapshots.added) { summary.push( `${SNAPSHOT_ADDED( `${ARROW + pluralize('snapsh...
type SnapshotSummary = { added: number; didUpdate: boolean; failure: boolean; filesAdded: number; filesRemoved: number; filesRemovedList: Array<string>; filesUnmatched: number; filesUpdated: number; matched: number; total: number; unchecked: number; uncheckedKeysByFile: Array<UncheckedSnapshot>;...
1,933
override onTestResult( test: Test, result: TestResult, aggregatedResults: AggregatedResult, ): void { super.testFinished(test.context.config, result, aggregatedResults); if (!result.skipped) { this.printTestFileHeader( result.testFilePath, test.context.config, result,...
type Test = { context: TestContext; duration?: number; path: string; };
1,934
override onTestResult( test: Test, result: TestResult, aggregatedResults: AggregatedResult, ): void { super.testFinished(test.context.config, result, aggregatedResults); if (!result.skipped) { this.printTestFileHeader( result.testFilePath, test.context.config, result,...
type Test = (arg0: any) => boolean;
1,935
override onTestResult( test: Test, result: TestResult, aggregatedResults: AggregatedResult, ): void { super.testFinished(test.context.config, result, aggregatedResults); if (!result.skipped) { this.printTestFileHeader( result.testFilePath, test.context.config, result,...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,936
override onTestResult( test: Test, result: TestResult, aggregatedResults: AggregatedResult, ): void { super.testFinished(test.context.config, result, aggregatedResults); if (!result.skipped) { this.printTestFileHeader( result.testFilePath, test.context.config, result,...
type TestResult = { console?: ConsoleBuffer; coverage?: CoverageMapData; displayName?: Config.DisplayName; failureMessage?: string | null; leaks: boolean; memoryUsage?: number; numFailingTests: number; numPassingTests: number; numPendingTests: number; numTodoTests: number; openHandles: Array<Error...
1,937
override onTestResult( test: Test, result: TestResult, aggregatedResults: AggregatedResult, ): void { super.testFinished(test.context.config, result, aggregatedResults); if (!result.skipped) { this.printTestFileHeader( result.testFilePath, test.context.config, result,...
type TestResult = { duration?: number | null; errors: Array<FormattedError>; errorsDetailed: Array<MatcherResults | unknown>; invocations: number; status: TestStatus; location?: {column: number; line: number} | null; numPassingAsserts: number; retryReasons: Array<FormattedError>; testPath: Array<TestN...
1,938
private _logSuite(suite: Suite, indentLevel: number) { if (suite.title) { this._logLine(suite.title, indentLevel); } this._logTests(suite.tests, indentLevel + 1); suite.suites.forEach(suite => this._logSuite(suite, indentLevel + 1)); }
class Suite { id: string; parentSuite?: Suite; description: Circus.TestNameLike; throwOnExpectationFailure: boolean; beforeFns: Array<QueueableFn>; afterFns: Array<QueueableFn>; beforeAllFns: Array<QueueableFn>; afterAllFns: Array<QueueableFn>; disabled: boolean; children: Array<Suite | Spec>; res...
1,939
private _logSuite(suite: Suite, indentLevel: number) { if (suite.title) { this._logLine(suite.title, indentLevel); } this._logTests(suite.tests, indentLevel + 1); suite.suites.forEach(suite => this._logSuite(suite, indentLevel + 1)); }
type Suite = { title: string; suites: Array<Suite>; tests: Array<AssertionResult>; };
1,940
private _logTest(test: AssertionResult, indentLevel: number) { const status = this._getIcon(test.status); const time = test.duration ? ` (${formatTime(Math.round(test.duration))})` : ''; this._logLine(`${status} ${chalk.dim(test.title + time)}`, indentLevel); }
type AssertionResult = TestResult.AssertionResult;
1,941
private _logTest(test: AssertionResult, indentLevel: number) { const status = this._getIcon(test.status); const time = test.duration ? ` (${formatTime(Math.round(test.duration))})` : ''; this._logLine(`${status} ${chalk.dim(test.title + time)}`, indentLevel); }
type AssertionResult = { ancestorTitles: Array<string>; duration?: number | null; failureDetails: Array<unknown>; failureMessages: Array<string>; fullName: string; invocations?: number; location?: Callsite | null; numPassingAsserts: number; retryReasons?: Array<string>; status: Status; title: stri...
1,942
(test: AssertionResult): void => { const printedTestStatus = test.status === 'pending' ? 'skipped' : test.status; const icon = this._getIcon(test.status); const text = chalk.dim(`${printedTestStatus} ${test.title}`); this._logLine(`${icon} ${text}`, indentLevel); }
type AssertionResult = TestResult.AssertionResult;
1,943
(test: AssertionResult): void => { const printedTestStatus = test.status === 'pending' ? 'skipped' : test.status; const icon = this._getIcon(test.status); const text = chalk.dim(`${printedTestStatus} ${test.title}`); this._logLine(`${icon} ${text}`, indentLevel); }
type AssertionResult = { ancestorTitles: Array<string>; duration?: number | null; failureDetails: Array<unknown>; failureMessages: Array<string>; fullName: string; invocations?: number; location?: Callsite | null; numPassingAsserts: number; retryReasons?: Array<string>; status: Status; title: stri...
1,944
runStarted( aggregatedResults: AggregatedResult, options: ReporterOnStartOptions, ): void { this._estimatedTime = (options && options.estimatedTime) || 0; this._showStatus = options && options.showStatus; this._interval = setInterval(() => this._tick(), 1000); this._aggregatedResults = aggrega...
type ReporterOnStartOptions = { estimatedTime: number; showStatus: boolean; };
1,945
runStarted( aggregatedResults: AggregatedResult, options: ReporterOnStartOptions, ): void { this._estimatedTime = (options && options.estimatedTime) || 0; this._showStatus = options && options.showStatus; this._interval = setInterval(() => this._tick(), 1000); this._aggregatedResults = aggrega...
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,946
addTestCaseResult(test: Test, testCaseResult: TestCaseResult): void { this._currentTestCases.push({test, testCaseResult}); if (!this._showStatus) { this._emit(); } else { this._debouncedEmit(); } }
type Test = { context: TestContext; duration?: number; path: string; };
1,947
addTestCaseResult(test: Test, testCaseResult: TestCaseResult): void { this._currentTestCases.push({test, testCaseResult}); if (!this._showStatus) { this._emit(); } else { this._debouncedEmit(); } }
type Test = (arg0: any) => boolean;
1,948
addTestCaseResult(test: Test, testCaseResult: TestCaseResult): void { this._currentTestCases.push({test, testCaseResult}); if (!this._showStatus) { this._emit(); } else { this._debouncedEmit(); } }
type TestCaseResult = AssertionResult;
1,949
( snapshotData: SnapshotData, snapshotPath: string, ): void => { const snapshots = Object.keys(snapshotData) .sort(naturalCompare) .map( key => `exports[${printBacktickString(key)}] = ${printBacktickString( normalizeNewlines(snapshotData[key]), )};`, ); ensureDirecto...
type SnapshotData = Record<string, string>;
1,950
( hasteFS: IHasteFS, update: Config.SnapshotUpdateState, snapshotResolver: SnapshotResolver, testPathIgnorePatterns?: Config.ProjectConfig['testPathIgnorePatterns'], ): { filesRemoved: number; filesRemovedList: Array<string>; } => { const pattern = `\\.${EXTENSION}$`; const files = hasteFS.matchFiles(pa...
type SnapshotResolver = { /** Resolves from `testPath` to snapshot path. */ resolveSnapshotPath(testPath: string, snapshotExtension?: string): string; /** Resolves from `snapshotPath` to test path. */ resolveTestPath(snapshotPath: string, snapshotExtension?: string): string; /** Example test path, used for pr...
1,951
( hasteFS: IHasteFS, update: Config.SnapshotUpdateState, snapshotResolver: SnapshotResolver, testPathIgnorePatterns?: Config.ProjectConfig['testPathIgnorePatterns'], ): { filesRemoved: number; filesRemovedList: Array<string>; } => { const pattern = `\\.${EXTENSION}$`; const files = hasteFS.matchFiles(pa...
interface IHasteFS { exists(path: string): boolean; getAbsoluteFileIterator(): Iterable<string>; getAllFiles(): Array<string>; getDependencies(file: string): Array<string> | null; getSize(path: string): number | null; matchFiles(pattern: RegExp | string): Array<string>; matchFilesWithGlob( globs: Read...
1,952
(config: MatchSnapshotConfig) => { const {context, hint, inlineSnapshot, isInline, matcherName, properties} = config; let {received} = config; context.dontThrow && context.dontThrow(); const {currentTestName, isNot, snapshotState} = context; if (isNot) { throw new Error( matcherErrorMessage( ...
type MatchSnapshotConfig = { context: Context; hint?: string; inlineSnapshot?: string; isInline: boolean; matcherName: string; properties?: object; received: any; };
1,953
( config: MatchSnapshotConfig, fromPromise?: boolean, ) => { const {context, hint, inlineSnapshot, isInline, matcherName, received} = config; context.dontThrow && context.dontThrow(); const {isNot, promise} = context; if (!fromPromise) { if (typeof received !== 'function') { const options: ...
type MatchSnapshotConfig = { context: Context; hint?: string; inlineSnapshot?: string; isInline: boolean; matcherName: string; properties?: object; received: any; };
1,954
(inlineSnapshot: InlineSnapshot) => string
type InlineSnapshot = { snapshot: string; frame: Frame; node?: Expression; };
1,955
( prettier: Prettier, sourceFilePath: string, sourceFileWithSnapshots: string, snapshotMatcherNames: Array<string>, ) => { // Resolve project configuration. // For older versions of Prettier, do not load configuration. const config = prettier.resolveConfig ? prettier.resolveConfig.sync(sourceFilePath,...
type Prettier = typeof import('prettier');
1,956
( chalkInstance: Chalk, ): DiffOptionsColor => { const level = chalkInstance.level; if (level === 3) { return chalkInstance .rgb(aForeground3[0], aForeground3[1], aForeground3[2]) .bgRgb(aBackground3[0], aBackground3[1], aBackground3[2]); } if (level === 2) { return chalkInstance.ansi256...
type Chalk = chalk.Chalk;
1,957
( chalkInstance: Chalk, ): DiffOptionsColor => { const level = chalkInstance.level; if (level === 3) { return chalkInstance .rgb(bForeground3[0], bForeground3[1], bForeground3[2]) .bgRgb(bBackground3[0], bBackground3[1], bBackground3[2]); } if (level === 2) { return chalkInstance.ansi256...
type Chalk = chalk.Chalk;
1,958
( { context: {isNot, promise}, hint, inlineSnapshot, matcherName, properties, }: MatchSnapshotConfig, isUpdatable: boolean, ): string => { const options: MatcherHintOptions = {isNot, promise}; if (isUpdatable) { options.receivedColor = bReceivedColor; } let expectedArgument = ''; ...
type MatchSnapshotConfig = { context: Context; hint?: string; inlineSnapshot?: string; isInline: boolean; matcherName: string; properties?: object; received: any; };
1,959
match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions { this._counters.set(testName, (this._counters.get(testName) || 0) + 1); const count = Number(this._counters.get(testName)); if (!key) { key = testNameToKey(test...
type SnapshotMatchOptions = { readonly testName: string; readonly received: unknown; readonly key?: string; readonly inlineSnapshot?: string; readonly isInline: boolean; readonly error?: Error; };
1,960
async function createSnapshotResolver( localRequire: LocalRequire, snapshotResolverPath?: string | null, ): Promise<SnapshotResolver> { return typeof snapshotResolverPath === 'string' ? createCustomSnapshotResolver(snapshotResolverPath, localRequire) : createDefaultSnapshotResolver(); }
type LocalRequire = (module: string) => unknown;
1,961
function verifyConsistentTransformations(custom: SnapshotResolver) { const resolvedSnapshotPath = custom.resolveSnapshotPath( custom.testPathForConsistencyCheck, ); const resolvedTestPath = custom.resolveTestPath(resolvedSnapshotPath); if (resolvedTestPath !== custom.testPathForConsistencyCheck) { throw...
type SnapshotResolver = { /** Resolves from `testPath` to snapshot path. */ resolveSnapshotPath(testPath: string, snapshotExtension?: string): string; /** Resolves from `snapshotPath` to test path. */ resolveTestPath(snapshotPath: string, snapshotExtension?: string): string; /** Example test path, used for pr...
1,962
function deepCyclicCopy<T>( value: T, options: DeepCyclicCopyOptions = {blacklist: EMPTY, keepPrototype: false}, cycles: WeakMap<any, any> = new WeakMap(), ): T { if (typeof value !== 'object' || value === null || Buffer.isBuffer(value)) { return value; } else if (cycles.has(value)) { return cycles.ge...
type DeepCyclicCopyOptions = { blacklist?: Set<string>; keepPrototype?: boolean; };
1,963
function deepCyclicCopyObject<T>( object: T, options: DeepCyclicCopyOptions, cycles: WeakMap<any, any>, ): T { const newObject = options.keepPrototype ? Object.create(Object.getPrototypeOf(object)) : {}; const descriptors = Object.getOwnPropertyDescriptors(object); cycles.set(object, newObject); ...
type DeepCyclicCopyOptions = { blacklist?: Set<string>; keepPrototype?: boolean; };
1,964
(meta: JestImportMeta) => { meta.url = pathToFileURL(modulePath).href; let jest = this.jestObjectCaches.get(modulePath); if (!jest) { jest = this._createJestObjectFor(modulePath); this.jestObjectCaches.set(modulePath, jest); } ...
interface JestImportMeta extends ImportMeta { jest: Jest; }
1,965
private _loadModule( localModule: InitialModule, from: string, moduleName: string | undefined, modulePath: string, options: InternalModuleOptions | undefined, moduleRegistry: ModuleRegistry, ) { if (path.extname(modulePath) === '.json') { const text = stripBOM(this.readFile(modulePat...
type ModuleRegistry = Map<string, InitialModule | Module>;
1,966
private _loadModule( localModule: InitialModule, from: string, moduleName: string | undefined, modulePath: string, options: InternalModuleOptions | undefined, moduleRegistry: ModuleRegistry, ) { if (path.extname(modulePath) === '.json') { const text = stripBOM(this.readFile(modulePat...
type InitialModule = Omit<Module, 'require' | 'parent' | 'paths'>;
1,967
private _getFullTransformationOptions( options: InternalModuleOptions = defaultTransformOptions, ): TransformationOptions { return { ...options, ...this._coverageOptions, }; }
interface InternalModuleOptions extends Required<CallerTransformOptions> { isInternalModule: boolean; }
1,968
private _execModule( localModule: InitialModule, options: InternalModuleOptions | undefined, moduleRegistry: ModuleRegistry, from: string | null, moduleName?: string, ) { if (this.isTornDown) { this._logFormattedReferenceError( 'You are trying to `import` a file after the Jest en...
type ModuleRegistry = Map<string, InitialModule | Module>;
1,969
private _execModule( localModule: InitialModule, options: InternalModuleOptions | undefined, moduleRegistry: ModuleRegistry, from: string | null, moduleName?: string, ) { if (this.isTornDown) { this._logFormattedReferenceError( 'You are trying to `import` a file after the Jest en...
type InitialModule = Omit<Module, 'require' | 'parent' | 'paths'>;
1,970
private _createRequireImplementation( from: InitialModule, options?: InternalModuleOptions, ): NodeRequire { const resolve = (moduleName: string, resolveOptions?: ResolveOptions) => { const resolved = this._requireResolve( from.filename, moduleName, resolveOptions, ); ...
type InitialModule = Omit<Module, 'require' | 'parent' | 'paths'>;
1,971
private _createRequireImplementation( from: InitialModule, options?: InternalModuleOptions, ): NodeRequire { const resolve = (moduleName: string, resolveOptions?: ResolveOptions) => { const resolved = this._requireResolve( from.filename, moduleName, resolveOptions, ); ...
interface InternalModuleOptions extends Required<CallerTransformOptions> { isInternalModule: boolean; }
1,972
private handleExecutionError(e: Error, module: Module): never { const moduleNotFoundError = Resolver.tryCastModuleNotFoundError(e); if (moduleNotFoundError) { if (!moduleNotFoundError.requireStack) { moduleNotFoundError.requireStack = [module.filename || module.id]; for (let cursor = modu...
type Module = NodeModule;
1,973
setGlobalsForRuntime(globals: JestGlobals): void { this.jestGlobals = globals; }
interface JestGlobals extends Global.TestFrameworkGlobals { // we cannot type `expect` properly as it'd create circular dependencies expect: unknown; }
1,974
setGlobalsForRuntime(globals: JestGlobals): void { this.jestGlobals = globals; }
interface JestGlobals extends Global.TestFrameworkGlobals { expect: typeof expect; }
1,975
function addIstanbulInstrumentation( babelOptions: TransformOptions, transformOptions: JestTransformOptions, ): TransformOptions { if (transformOptions.instrument) { const copiedBabelOptions: TransformOptions = {...babelOptions}; copiedBabelOptions.auxiliaryCommentBefore = ' istanbul ignore next '; //...
interface TransformOptions<TransformerConfig = unknown> extends ReducedTransformOptions { /** Cached file system which is used by `jest-runtime` to improve performance. */ cacheFS: StringMap; /** Jest configuration of currently running project. */ config: Config.ProjectConfig; /** Stringified version of the...
1,976
forEach(cb: ReplaceableForEachCallBack): void { if (this.type === 'object') { const descriptors = Object.getOwnPropertyDescriptors(this.object); [ ...Object.keys(descriptors), ...Object.getOwnPropertySymbols(descriptors), ] //@ts-expect-error because typescript do not suppo...
type ReplaceableForEachCallBack = ( value: unknown, key: unknown, object: unknown, ) => void;
1,977
function summarize(coverageMap: CoverageMap): CoverageMap { if (!coverageMap) { return coverageMap; } const summaries = Object.create(null); coverageMap.files().forEach(file => { const covered = []; const lineCoverage = coverageMap.fileCoverageFor(file).getLineCoverage(); Object.keys(lineCove...
type CoverageMap = AggregatedResult['coverageMap'];
1,978
function PhabricatorProcessor( results: AggregatedResult, ): AggregatedResult { return {...results, coverageMap: summarize(results.coverageMap)}; }
type AggregatedResult = AggregatedResultWithoutCoverage & { coverageMap?: CoverageMap | null; };
1,979
constructor(argument: Expression) { this.type = Syntax.AwaitExpression; this.argument = argument; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,980
constructor(expression: ChainElement) { this.type = Syntax.ChainExpression; this.expression = expression; }
type ChainElement = CallExpression | ComputedMemberExpression | StaticMemberExpression;
1,981
constructor(object: Expression, property: Expression, optional: boolean) { this.type = Syntax.MemberExpression; this.computed = true; this.object = object; this.property = property; this.optional = optional; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,982
constructor(test: Expression, consequent: Expression, alternate: Expression) { this.type = Syntax.ConditionalExpression; this.test = test; this.consequent = consequent; this.alternate = alternate; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,983
constructor(expression: Expression, directive: string) { this.type = Syntax.ExpressionStatement; this.expression = expression; this.directive = directive; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,984
constructor(body: Statement, test: Expression) { this.type = Syntax.DoWhileStatement; this.body = body; this.test = test; }
type Statement = AsyncFunctionDeclaration | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | Directive | ForStatement | ForInStatement | ForOfStatement | FunctionDeclaration | IfStatement | ReturnStatement | SwitchStatement | ThrowStatement | ...
1,985
constructor(body: Statement, test: Expression) { this.type = Syntax.DoWhileStatement; this.body = body; this.test = test; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,986
constructor(source: Literal) { this.type = Syntax.ExportAllDeclaration; this.source = source; }
class Literal { readonly type: string; readonly value: boolean | number | string | null; readonly raw: string; constructor(value: boolean | number | string | null, raw: string) { this.type = Syntax.Literal; this.value = value; this.raw = raw; } }
1,987
constructor(declaration: ExportableDefaultDeclaration) { this.type = Syntax.ExportDefaultDeclaration; this.declaration = declaration; }
type ExportableDefaultDeclaration = BindingIdentifier | BindingPattern | ClassDeclaration | Expression | FunctionDeclaration;
1,988
constructor(local: Identifier, exported: Identifier) { this.type = Syntax.ExportSpecifier; this.exported = exported; this.local = local; }
class Identifier { readonly type: string; readonly name: string; constructor(name) { this.type = Syntax.Identifier; this.name = name; } }
1,989
constructor(expression: Expression) { this.type = Syntax.ExpressionStatement; this.expression = expression; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,990
constructor(left: Expression, right: Expression, body: Statement) { this.type = Syntax.ForInStatement; this.left = left; this.right = right; this.body = body; this.each = false; }
type Statement = AsyncFunctionDeclaration | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | Directive | ForStatement | ForInStatement | ForOfStatement | FunctionDeclaration | IfStatement | ReturnStatement | SwitchStatement | ThrowStatement | ...
1,991
constructor(left: Expression, right: Expression, body: Statement) { this.type = Syntax.ForInStatement; this.left = left; this.right = right; this.body = body; this.each = false; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,992
constructor(left: Expression, right: Expression, body: Statement, _await: boolean) { this.type = Syntax.ForOfStatement; this.await = _await; this.left = left; this.right = right; this.body = body; }
type Statement = AsyncFunctionDeclaration | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | Directive | ForStatement | ForInStatement | ForOfStatement | FunctionDeclaration | IfStatement | ReturnStatement | SwitchStatement | ThrowStatement | ...
1,993
constructor(left: Expression, right: Expression, body: Statement, _await: boolean) { this.type = Syntax.ForOfStatement; this.await = _await; this.left = left; this.right = right; this.body = body; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,994
constructor(test: Expression, consequent: Statement, alternate: Statement | null) { this.type = Syntax.IfStatement; this.test = test; this.consequent = consequent; this.alternate = alternate; }
type Statement = AsyncFunctionDeclaration | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | Directive | ForStatement | ForInStatement | ForOfStatement | FunctionDeclaration | IfStatement | ReturnStatement | SwitchStatement | ThrowStatement | ...
1,995
constructor(test: Expression, consequent: Statement, alternate: Statement | null) { this.type = Syntax.IfStatement; this.test = test; this.consequent = consequent; this.alternate = alternate; }
type Expression = ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AsyncArrowFunctionExpression | AsyncFunctionExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ComputedMemberExpression | ConditionalExpression | Identifier | FunctionExpressi...
1,996
constructor(local: Identifier) { this.type = Syntax.ImportDefaultSpecifier; this.local = local; }
class Identifier { readonly type: string; readonly name: string; constructor(name) { this.type = Syntax.Identifier; this.name = name; } }
1,997
constructor(local: Identifier) { this.type = Syntax.ImportNamespaceSpecifier; this.local = local; }
class Identifier { readonly type: string; readonly name: string; constructor(name) { this.type = Syntax.Identifier; this.name = name; } }
1,998
constructor(local: Identifier, imported: Identifier) { this.type = Syntax.ImportSpecifier; this.local = local; this.imported = imported; }
class Identifier { readonly type: string; readonly name: string; constructor(name) { this.type = Syntax.Identifier; this.name = name; } }
1,999
constructor(label: Identifier, body: Statement) { this.type = Syntax.LabeledStatement; this.label = label; this.body = body; }
type Statement = AsyncFunctionDeclaration | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | Directive | ForStatement | ForInStatement | ForOfStatement | FunctionDeclaration | IfStatement | ReturnStatement | SwitchStatement | ThrowStatement | ...