@gentrace/core
Version:
Core Gentrace Node.JS library
49 lines (48 loc) • 2.4 kB
TypeScript
import { Context, ResultContext } from "./context";
import { TestCase, TestCaseV2 } from "../models";
import { PipelineRun } from "./pipeline-run";
import { TestCaseForSubmission, TestRun } from "./test-result";
export type GentraceParams = {
pipelineSlug?: string;
gentrace?: Context;
};
export type OptionalPipelineInfo = {
pipelineId?: string;
pipelineSlug?: string;
};
export type LocalTestData = {
name: string;
inputs: Record<string, any>;
expectedOutputs?: Record<string, any>;
};
export declare function sleep(ms: number): Promise<unknown>;
export declare function getParamNames<F extends (...args: any[]) => any>(func: F): string[];
export declare function zip<S1, S2>(firstCollection: Array<S1>, lastCollection: Array<S2>): Array<[S1, S2]>;
export declare function getTestCounter(): number;
export declare function incrementTestCounter(): number;
export declare function decrementTestCounter(): number;
export declare function getProcessEnv(name: string): string;
export declare function safeJsonParse(jsonString: string | null): any;
export declare function getContextTestCaseFilter(contextOrCaseFilter?: ResultContext | ((testCase: Omit<TestCase, "createdAt" | "updatedAt" | "archivedAt" | "deletedAt">) => boolean), caseFilterOrUndefined?: (testCase: Omit<TestCase, "createdAt" | "updatedAt" | "archivedAt" | "deletedAt">) => boolean): {
context: ResultContext | undefined;
caseFilter: (testCase: Omit<TestCase, "createdAt" | "updatedAt" | "archivedAt" | "deletedAt">) => boolean | undefined;
};
export declare function setErrorInterceptor(): void;
/**
* Constructs step runs for a given test case and pipeline run.
*
* @param {TestCase | TestCaseV2 | LocalTestData} testCase - The test case object.
* @param {PipelineRun} pipelineRun - The pipeline run object.
* @returns {TestRun} The constructed test run object.
*/
export declare function constructStepRuns(testCase: {
id?: string | undefined;
name?: string | undefined;
inputs?: Record<string, any> | undefined;
}, pipelineRun: PipelineRun): TestRun;
/**
* Type guard to check if the test case is either TestCase or TestCaseV2
* @param testCase - The test case to check
* @returns True if the test case is TestCase or TestCaseV2, false if it's LocalTestData
*/
export declare function isTestCaseOrTestCaseV2(testCase: TestCaseForSubmission): testCase is TestCase | TestCaseV2;