html-reporter
Version:
Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.
71 lines (70 loc) • 4.87 kB
TypeScript
/// <reference types="node" />
import { Router } from 'express';
import type { TimeTravelMode as TimeTravelModeType, Test as TestplaneTest } from 'testplane';
import { TestStatus } from './constants';
import type { HtmlReporter } from './plugin-api';
import type { ReporterTestResult } from './adapters/test-result';
import { TestplaneTestResult, ImageInfoWithState, ReporterConfig, TestSpecByPath } from './types';
interface GetPathOptions {
imageDir: string;
attempt: number;
browserId: string;
timestamp: number;
}
export declare const getReferencePath: (options: GetPathOptions, stateName?: string) => string;
export declare const getCurrentPath: (options: GetPathOptions, stateName?: string) => string;
export declare const getDiffPath: (options: GetPathOptions, stateName?: string) => string;
export declare const getReferenceAbsolutePath: (testResult: ReporterTestResult, reportDir: string, stateName: string) => string;
export declare const getCurrentAbsolutePath: (testResult: ReporterTestResult, reportDir: string, stateName: string) => string;
export declare const getDiffAbsolutePath: (testResult: ReporterTestResult, reportDir: string, stateName: string) => string;
interface CreatePathOptions extends GetPathOptions {
stateName?: string;
kind: string;
}
export declare function createPath({ attempt: attemptInput, imageDir: imageDirInput, timestamp, browserId, kind, stateName }: CreatePathOptions): string;
export declare const getTempPath: (destPath: string) => string;
export declare function createHash(buffer: Buffer): string;
export interface CopyFileAsyncOptions {
reportDir: string;
overwrite: boolean;
}
export declare function copyFileAsync(srcPath: string, destPath: string, { reportDir, overwrite }?: Partial<CopyFileAsyncOptions>): Promise<void>;
export declare function deleteFile(filePath: string): Promise<void>;
export declare function makeDirFor(destPath: string): Promise<void>;
export declare function fileExists(path: string): boolean;
export declare function logPathToHtmlReport(pluginConfig: ReporterConfig): void;
export declare function logError(e: Error): void;
export declare function prepareCommonJSData(data: unknown): string;
export declare function shouldUpdateAttempt(status: TestStatus): boolean;
export declare function saveStaticFilesToReportDir(htmlReporter: HtmlReporter, pluginConfig: ReporterConfig, destPath: string): Promise<void>;
export declare function copyPlugins({ plugins, pluginsEnabled }: ReporterConfig, destPath: string): Promise<void>;
export declare function copyPlugin(pluginName: string, pluginsPath: string): Promise<void>;
export declare function urlPathNameEndsWith(currentUrl: string, searchString: string): boolean;
export declare function isJsonUrl(url: string): boolean;
export declare function isDbFile(filePath: string): boolean;
export declare function writeDatabaseUrlsFile(destPath: string, srcPaths: string[]): Promise<void>;
export declare function copyToReportDir(destPath: string, files: string[], sourceDirectory: string): Promise<void[]>;
export type ConfigForStaticFile = Pick<ReporterConfig, 'defaultView' | 'diffMode' | 'baseHost' | 'errorPatterns' | 'metaInfoBaseUrls' | 'customScripts' | 'yandexMetrika' | 'pluginsEnabled' | 'plugins' | 'uiMode'>;
export declare function getConfigForStaticFile(pluginConfig: ReporterConfig): ConfigForStaticFile;
export interface DataForStaticFile {
skips: object[];
config: ConfigForStaticFile;
apiValues: HtmlReporter['values'];
timestamp: number;
date: string;
}
export declare function getDataForStaticFile(htmlReporter: HtmlReporter, pluginConfig: ReporterConfig): DataForStaticFile;
export declare function getPluginClientScriptPath(pluginName: string): string | null;
interface PluginMiddleware {
(pluginRouter: Router): unknown;
}
export declare function getPluginMiddleware(pluginName: string): PluginMiddleware | null;
export declare function isUnexpectedPlugin(plugins: ReporterConfig['plugins'], pluginName: string): boolean;
export declare function forEachPlugin(plugins: ReporterConfig['plugins'], callback: (name: string) => void): void;
export declare function mapPlugins<T>(plugins: ReporterConfig['plugins'], callback: (name: string) => T): T[];
export declare const formatTestResult: (rawResult: TestplaneTest | TestplaneTestResult, status: TestStatus, attempt?: number) => ReporterTestResult;
export declare const saveErrorDetails: (testResult: ReporterTestResult, reportPath: string) => Promise<void>;
export declare const getExpectedCacheKey: ([testResult, stateName]: [TestSpecByPath, string | undefined]) => string;
export declare const getImagesInfoByStateName: (imagesInfo: ReporterTestResult['imagesInfo'], stateName: string) => ImageInfoWithState | undefined;
export declare const getTimeTravelModeEnumSafe: () => typeof TimeTravelModeType | null;
export {};