UNPKG

@argos-ci/playwright

Version:

Playwright SDK for visual testing with Argos.

66 lines (63 loc) 2.36 kB
import { Reporter, TestCase, FullConfig, TestResult, FullResult } from '@playwright/test/reporter'; import { UploadParameters } from '@argos-ci/core'; /** * Dynamic build name. * We require all values in order to ensure it works correctly in parallel mode. */ type DynamicBuildName<T extends readonly string[]> = { /** * The values that the build name can take. * It is required to ensure Argos will always upload * for each build name in order to work in sharding mode. */ values: readonly [...T]; /** * Get the build name for a test case. * Returns any of the values in `values`. */ get: (test: TestCase) => T[number]; }; type ArgosReporterOptions<T extends string[] = string[]> = Omit<UploadParameters, "files" | "root" | "buildName" | "metadata"> & { /** * Upload the report to Argos. * @default true */ uploadToArgos?: boolean; /** * The name of the build in Argos. * Can be a string or a function that receives the test case and returns the build name. */ buildName?: string | DynamicBuildName<T> | null; }; declare function createArgosReporterOptions<T extends string[]>(options: ArgosReporterOptions<T>): ArgosReporterOptions<T>; declare class ArgosReporter implements Reporter { rootUploadDirectoryPromise: null | Promise<string>; uploadDirectoryPromises: Map<string, Promise<string>>; config: ArgosReporterOptions; playwrightConfig: FullConfig; uploadToArgos: boolean; constructor(config: ArgosReporterOptions); /** * Write a file to the temporary directory. */ writeFile(path: string, body: Buffer | string): Promise<void>; /** * Copy a file to the temporary directory. */ copyFile(from: string, to: string): Promise<void>; /** * Copy the trace file if found in the result. */ copyTraceIfFound(result: TestResult, path: string): Promise<void>; /** * Get the root upload directory (cached). */ getRootUploadDirectory(): Promise<string>; onBegin(config: FullConfig): void; onTestEnd(test: TestCase, result: TestResult): Promise<void>; onEnd(result: FullResult): Promise<{ status: "failed"; } | undefined>; printsToStdio(): boolean; } export { type ArgosReporterOptions, createArgosReporterOptions, ArgosReporter as default };