UNPKG

@argos-ci/core

Version:

Node.js SDK for visual testing with Argos.

290 lines (284 loc) 8.34 kB
import * as _argos_ci_util from '@argos-ci/util'; import { ArgosAPISchema } from '@argos-ci/api-client'; type BuildMetadata = ArgosAPISchema.components["schemas"]["BuildMetadata"]; interface UploadParameters { /** * Globs matching image file paths to upload */ files?: string[]; /** * Root directory to look for image to upload * @default process.cwd() */ root?: string; /** * Globs matching image file paths to ignore * @default ["**\/*.\{png,jpg,jpeg\}"] */ ignore?: string[]; /** * Base URL of Argos API * @default "https://api.argos-ci.com/v2/" */ apiBaseUrl?: string; /** * Git commit */ commit?: string; /** * Git branch */ branch?: string; /** * Argos repository token */ token?: string; /** * Pull-request number */ prNumber?: number; /** * Name of the build used to trigger multiple Argos builds on one commit */ buildName?: string; /** * Mode of comparison applied * @default "ci" */ mode?: "ci" | "monitoring"; /** Parallel test suite mode */ parallel?: { /** Unique build ID for this parallel build */ nonce: string; /** The number of parallel nodes being ran */ total: number; /** The index of the parallel node */ index?: number; } | false; /** * Branch used as baseline for screenshot comparison */ referenceBranch?: string; /** * Commit used as baseline for screenshot comparison */ referenceCommit?: string; /** * Sensitivity threshold between 0 and 1. * The higher the threshold, the less sensitive the diff will be. * @default 0.5 */ threshold?: number; /** * Build metadata. */ metadata?: BuildMetadata; /** * Preview URL configuration. * Accepts a base URL or a function that receives the URL and returns the preview URL. */ previewUrl?: { baseUrl: string; } | ((url: string) => string); } /** * Upload screenshots to Argos. */ declare function upload(params: UploadParameters): Promise<{ build: { id: ArgosAPISchema.components["schemas"]["BuildId"]; number: number; status: ("accepted" | "rejected") | ("no-changes" | "changes-detected") | ("expired" | "pending" | "progress" | "error" | "aborted"); url: string; notification: { description: string; context: string; github: { state: "pending" | "success" | "error" | "failure"; }; gitlab: { state: "pending" | "running" | "success" | "failed" | "canceled"; }; } | null; }; screenshots: { hash: string; optimizedPath: string; metadata: _argos_ci_util.ScreenshotMetadata | null; threshold: number | null; baseName: string | null; pwTrace: { path: string; hash: string; } | null; name: string; path: string; }[]; }>; interface components { schemas: { /** @description SHA1 hash */ Sha1Hash: string; /** @description SHA256 hash */ Sha256Hash: string; /** @description Build */ Build: { id: components["schemas"]["BuildId"]; /** @description The build number */ number: number; /** @description The status of the build */ status: ("accepted" | "rejected") | ("no-changes" | "changes-detected") | ("expired" | "pending" | "progress" | "error" | "aborted"); /** * Format: uri * @description The URL of the build */ url: string; /** @description The notification payload for the build */ notification: { description: string; context: string; github: { /** @enum {string} */ state: "pending" | "success" | "error" | "failure"; }; gitlab: { /** @enum {string} */ state: "pending" | "running" | "success" | "failed" | "canceled"; }; } | null; }; /** * @description A unique identifier for the build * @example 12345 */ BuildId: string; /** @description Error response */ Error: { error: string; details?: { message: string; }[]; }; /** * @description A unique identifier for the build * @example 12345 */ buildId: string; /** @description Screenshot input */ ScreenshotInput: { key: string; name: string; baseName?: string | null; metadata?: { url?: string; previewUrl?: string; viewport?: { width: number; height: number; }; /** @enum {string} */ colorScheme?: "light" | "dark"; /** @enum {string} */ mediaType?: "screen" | "print"; test?: { id?: string; title: string; titlePath: string[]; retries?: number; retry?: number; repeat?: number; location?: { file: string; line: number; column: number; }; } | null; browser?: { name: string; version: string; }; automationLibrary: { name: string; version: string; }; sdk: { name: string; version: string; }; } | null; pwTraceKey?: string | null; threshold?: number | null; }; /** @description Build metadata */ BuildMetadata: { testReport?: { /** @enum {string} */ status: "passed" | "failed" | "timedout" | "interrupted"; stats?: { startTime?: string; duration?: number; }; }; }; /** @description Project */ Project: { id: string; defaultBaseBranch: string; hasRemoteContentAccess: boolean; }; /** @description Page information */ PageInfo: { /** @description Total number of items */ total: number; /** @description Current page number */ page: number; /** @description Number of items per page */ perPage: number; }; }; responses: never; parameters: never; requestBodies: never; headers: never; pathItems: never; } type FinalizeParameters = { parallel?: { nonce: string; }; }; /** * Finalize pending builds. */ declare function finalize(params: FinalizeParameters): Promise<{ builds: components["schemas"]["Build"][]; }>; interface Config { apiBaseUrl: string; commit: string; branch: string; token: string | null; buildName: string | null; parallel: boolean; parallelNonce: string | null; parallelIndex: number | null; parallelTotal: number | null; referenceBranch: string | null; referenceCommit: string | null; owner: string | null; repository: string | null; jobId: string | null; runId: string | null; runAttempt: number | null; prNumber: number | null; prHeadCommit: string | null; prBaseBranch: string | null; mode: "ci" | "monitoring" | null; ciProvider: string | null; threshold: number | null; previewBaseUrl: string | null; } declare function readConfig(options?: Partial<Config>): Promise<Config>; export { type Config, type FinalizeParameters, type UploadParameters, finalize, readConfig, upload };