// Generated by dts-bundle-generator v9.3.1 import { DecoratorsPluginOptions } from '@babel/parser'; import * as t from '@babel/types'; import { FormattedTestResults } from '@jest/test-result'; import { Config } from '@jest/types'; import { ChildProcess } from 'child_process'; import EventEmitter from 'events'; import { CoverageMapData } from 'istanbul-lib-coverage'; import { SnapshotResolver } from 'jest-snapshot'; import { SnapshotData } from 'jest-snapshot/build/types'; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * a LoginShell holds the shell path and arguments to * start an login/interactive shell */ export interface LoginShell { /** shell executable path */ path: string; /** shell arguments */ args: string[]; } /** * Represents the project that the extension is running on and it's state */ export declare class ProjectWorkspace { /** * The path to the root of the project's workspace * * @type {string} */ rootPath: string; /** * The command to execute Jest on the command line, this is normally a file path like * `node_modules/.bin/jest` but you should not make the assumption that it is always a direct * file path, as in a create-react app it would look like `npm test --`. * * This means when launching a process, you will need to split on the first * space, and then move any other args into the args of the process. * * @type {string} */ jestCommandLine: string; /** * @deprecated please use `jestCommandLine` instead. * * @type {string?} */ get pathToJest(): string; set pathToJest(commandLine: string); /** * Path to a local Jest config file. * * @type {string} */ pathToConfig: string; /** * local Jest major release version, as the runner could run against * any version of Jest. * * @type {number} */ localJestMajorVersion: number; /** * Whether test coverage should be (automatically) collected. * * @type {boolean} */ collectCoverage?: boolean; /** * if to output more information for debugging purpose. Default is false. * * @type {boolean} */ debug?: boolean; /** * suffix string used as part of the output file path, this is to support concurrent Runners. * * @type {string} * @memberof ProjectWorkspace */ outputFileSuffix?: string; /** * optional additional node env variables */ nodeEnv?: { [key: string]: string | undefined; }; /** * optional custom shell for node child_process spawn() call. Default is '/bin/sh' on Unix, and process.env.ComSpec on Windows. * see https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options * * If a string is passed in, a non-login/non-interactive shell will be used to spawn the child_process * If a terminal-shell is passed, a login/interactive shell will be used to spawn the child_process. This is not as efficient as * the non-login/non-interactive shell, but might be needed if parent environment is not guarenteed to be properly initialized * (see https://github.com/jest-community/vscode-jest/issues/741) */ shell?: string | LoginShell; /** * Wether dashed args should be used for the jest command line. Default is false. */ useDashedArgs?: boolean; constructor(rootPath: string, jestCommandLine: string, pathToConfig: string, localJestMajorVersion: number, outputFileSuffix?: string, collectCoverage?: boolean, debug?: boolean, nodeEnv?: { [key: string]: string | undefined; }, shell?: string | LoginShell, useDashedArgs?: boolean); } declare const createProcess: (workspace: ProjectWorkspace, args: string[]) => ChildProcess; export interface CodeLocation { column: number; line: number; } export type RunArgs = { args: string[]; replace?: boolean; skipConversion?: boolean; }; export type Options = { createProcess?: (workspace: ProjectWorkspace, args: string[]) => ChildProcess; noColor?: boolean; testNamePattern?: string; testFileNamePattern?: string; reporters?: string[]; /** either to append or replace the Runner process arguments */ args?: RunArgs; }; export declare enum MessageTypes { noTests = 1, testResults = 3, unknown = 0, watchUsage = 2 } export type MessageType = number; export type RunnerEvent = "processClose" | "processExit" | "executableJSON" | "executableStdErr" | "executableOutput" | "terminalError"; export declare class Runner extends EventEmitter { runProcess?: ChildProcess; outputPath: string; workspace: ProjectWorkspace; _createProcess: (workspace: ProjectWorkspace, args: string[]) => ChildProcess; watchMode: boolean; watchAll: boolean; options: Options; prevMessageTypes: MessageType[]; _exited: boolean; constructor(workspace: ProjectWorkspace, options?: Options); __convertDashedArgs(args: string[]): string[]; _getArgs(): string[]; start(watchMode?: boolean, watchAll?: boolean): void; /** * parse the stdin/out stream buffer for recognized messages. * * note: if these messages coming in in separate chucks, we might not be able to * resolve it properly. While there haven't been much evidence of such scenario, * it's worth to note that it could and we might need to buffer them in that case. * see https://github.com/jest-community/jest-editor-support/pull/9#pullrequestreview-231888752 * * @param {Buffer} data * @param {boolean} isStdErr * @returns {MessageType} * @memberof Runner */ _parseOutput(data: Buffer, isStdErr: boolean): MessageType; runJestWithUpdateForSnapshots(completion: () => void, args?: string[]): void; closeProcess(): void; findMessageType(buf: Buffer): MessageType; doResultsFollowNoTestsFoundMessage(): boolean; } export type JestSettings = { jestVersionMajor: number; configs: Config.ProjectConfig[]; }; export function getSettings(workspace: ProjectWorkspace, options?: Options): Promise; /** * range and location here are 1-based position. */ export declare class ParsedRange { start: CodeLocation; end: CodeLocation; constructor(startLine: number, startCol: number, endLine: number, endCol: number); } export declare enum ParsedNodeType { describe = "describe", expect = "expect", it = "it", root = "root" } export declare class ParsedNode { type: ParsedNodeType; start?: CodeLocation; end?: CodeLocation; file: string; children?: ParsedNode[]; constructor(type: ParsedNodeType, file: string); addChild(type: ParsedNodeType): ParsedNode; filter(f: (node: ParsedNode) => boolean, filterSelf?: boolean): ParsedNode[]; } export declare class Expect extends ParsedNode { constructor(file: string); } export declare class NamedBlock extends ParsedNode { name: string; nameRange?: ParsedRange; lastProperty?: string; /** * type of the name, it's the babel Node["type"], such as "Literal", "TemplateLiteral" etc * * TODO babel parser currently returns "Literal" for the it/describe name argument, which is not part of its "type" definition, therefore declare a string type for now until it is fixed in babel. * */ nameType?: string; constructor(type: ParsedNodeType, file: string, name?: string); } export declare class ItBlock extends NamedBlock { constructor(file: string, name?: string); } export declare class DescribeBlock extends NamedBlock { constructor(file: string, name?: string); } export interface IParseResults { describeBlocks: DescribeBlock[]; expects: Expect[]; itBlocks: ItBlock[]; root: ParsedNode; file: string; } declare class ParseResult implements IParseResults { describeBlocks: DescribeBlock[]; expects: Expect[]; itBlocks: ItBlock[]; root: ParsedNode; file: string; constructor(file: string); addNode(node: ParsedNode, dedup?: boolean): void; } export interface JESParserPluginOptions { decorators?: "legacy" | DecoratorsPluginOptions; } export interface JESParserOptions { plugins?: JESParserPluginOptions; strictMode?: boolean; } declare const getASTfor: (file: string, data?: string, options?: JESParserOptions) => t.File; /** * parse the test file by selecting proper parser based on the file extension. * * exception will be throw should the underlying parse failed. */ export function parse(filePath: string, serializedData?: string, options?: JESParserOptions): ParseResult; export type ParserFunc = typeof getASTfor; export type SnapshotNode = t.Identifier; export interface SnapshotBlock { node: SnapshotNode; parents: t.Node[]; } export interface SnapshotMetadata { exists: boolean; name: string; node: SnapshotNode; content?: string; } export interface SnapshotParserOptions { verbose?: boolean; parserOptions?: JESParserOptions; } export declare class Snapshot { _parser: ParserFunc; _matchers: string[]; _projectConfig?: Config.ProjectConfig; snapshotResolver?: SnapshotResolver; _resolverPromise: Promise; constructor(parser?: ParserFunc, customMatchers?: string[], projectConfig?: Config.ProjectConfig); parse(filePath: string, options?: SnapshotParserOptions): SnapshotBlock[]; _getSnapshotResolver(): Promise; /** * look for snapshot content for the given test. * @param {*} filePath * @param {*} name can be a literal string or a regex pattern. * @returns the content of the snapshot, if exist. If name is a string, a string will be returned. If name is a RegExp, * a SnapshotData object will be returned with all matched snapshots. If nothing matched, null will be returned. * @throws throws exception if the snapshot version mismatched or any other unexpected error. */ getSnapshotContent(filePath: string, name: string | RegExp): Promise; getMetadataAsync(filePath: string, options?: SnapshotParserOptions): Promise; getMetadata(filePath: string, options?: SnapshotParserOptions): SnapshotMetadata[]; } export type JestFileResults = FormattedTestResults["testResults"][number]; export type JestAssertionResults = JestFileResults["assertionResults"][number]; export type JestTotalResults = Omit & { coverageMap?: CoverageMapData; }; /** * Did the thing pass, fail or was it not run? */ export type TestReconciliationState = "Unknown" | "KnownFail" | "KnownSuccess" | "KnownSkip" | "KnownTodo"; export type TestAssertionStatus = Omit & { status: TestReconciliationState; message: string; shortMessage?: string; terseMessage?: string; location?: CodeLocation; line?: number; }; export type TestFileAssertionStatus = Omit & { file: string; status: TestReconciliationState; assertions: TestAssertionStatus[] | null; }; /** * You have a Jest test runner watching for changes, and you have * an extension that wants to know where to show errors after file parsing. * * This class represents the state between runs, keeping track of passes/fails * at a file level, generating useful error messages and providing a nice API. */ export declare class TestReconciler { fileStatuses: { [key: string]: TestFileAssertionStatus; }; constructor(); updateFileWithJestStatus(results: JestTotalResults): TestFileAssertionStatus[]; /** * remove jest status of the test file from the cached results * @param {string} fileName */ removeTestFile(fileName: string): void; mapAssertions(filename: string, assertions: JestAssertionResults[]): TestAssertionStatus[]; sanitizeShortErrorMessage(string: string): string; lineOfError(message: string, filePath: string): number | undefined; statusToReconciliationState(status: string): TestReconciliationState; stateForTestFile(file: string): TestReconciliationState; assertionsForTestFile(file: string): TestAssertionStatus[] | null; stateForTestAssertion(file: string, name: string): TestAssertionStatus | null; } declare namespace Process { export { createProcess }; } export { Process, }; export {};