UNPKG

@touca/node

Version:

Touca SDK for JavaScript

113 lines 3.63 kB
import { BlobType, ComparisonRule, ResultJson, ToucaType } from './types.js'; export type CheckOptions = { rule?: ComparisonRule; }; type TestcaseMetadata = { builtAt: string; testcase: string; testsuite: string; teamslug: string; version: string; }; type CaseJson = { metadata: TestcaseMetadata; results: Array<{ key: string; value: ResultJson; }>; assertions: Array<{ key: string; value: ResultJson; }>; metrics: Array<{ key: string; value: ResultJson; }>; }; export declare class Case { private readonly meta; private _results; private _tics; private _tocs; constructor(meta: { name: string; team?: string; suite?: string; version?: string; }); /** * Captures the value of a given variable as a data point for the declared * test case and associates it with the specified key. * * @param key name to be associated with the captured data point * @param value value to be captured as a test result * @param options comparison rule for this test result */ check(key: string, value: ToucaType, options?: CheckOptions): void; /** * Captures an external file as a data point for the declared * test case and associates it with the specified key. * * @param key name to be associated with the captured file * @param path path to the external file to be captured */ checkFile(key: string, path: string): void; /** * Logs a given value as an assertion for the declared test case * and associates it with the specified key. * * @param key name to be associated with the logged test result * @param value value to be logged as a test result */ assume(key: string, value: ToucaType): void; /** * Adds a given value to a list of results for the declared test case which is * associated with the specified key. * * @param key name to be associated with the logged test result * @param value element to be appended to the array */ add_array_element(key: string, value: ToucaType): void; /** * Increments value of key every time it is executed. creates the key with * initial value of one if it does not exist. * * @param key name to be associated with the logged test result */ add_hit_count(key: string): void; /** * Adds an already obtained measurements to the list of captured performance * benchmarks. * * Useful for logging a metric that is measured without using this SDK. * * @param key name to be associated with this performance benchmark * @param milliseconds duration of this measurement in milliseconds */ add_metric(key: string, milliseconds: number): void; /** * Starts timing an event with the specified name. * * Measurement of the event is only complete when function `stop_timer` is * later called for the specified name. * * @param key name to be associated with the performance metric */ start_timer(key: string): void; /** * Stops timing an event with the specified name. * * Expects function `startTimer` to have been called previously with the * specified name. * * @param key name to be associated with the performance metric */ stop_timer(key: string): void; private _metrics; private _metadata; blobs(): Array<[string, BlobType]>; json(): CaseJson; serialize(): Uint8Array; } export {}; //# sourceMappingURL=case.d.ts.map