cypress-xray-plugin
Version:
A Cypress plugin for uploading test results to Xray (test management for Jira)
135 lines (134 loc) • 5.55 kB
TypeScript
import type { EvidenceCollection, IterationParameterCollection } from "../context";
import type { Logger } from "../util/logging";
type Task = "cypress-xray-plugin:task:iteration:definition" | "cypress-xray-plugin:task:request" | "cypress-xray-plugin:task:response";
/**
* All tasks which are available within the plugin.
*/
export declare const PluginTask: {
/**
* The task which handles incoming responses from requests dispatched through `cy.request`
* within a test.
*/
readonly INCOMING_RESPONSE: "cypress-xray-plugin:task:response";
/**
* The task that provides Xray iteration parameters for a test run. These can be used to
* distinguish between iterations in the execution results view.
*/
readonly ITERATION_DEFINITION: "cypress-xray-plugin:task:iteration:definition";
/**
* The task which handles outgoing requests dispatched through `cy.request` within a test.
*/
readonly OUTGOING_REQUEST: "cypress-xray-plugin:task:request";
};
/**
* Enqueues the plugin task for processing a dispatched request. The plugin internally keeps track
* of all requests enqueued in this way and will upload them as test execution evidence if the
* appropriate options are enabled.
*
* @param task - the task name
* @param filename - the name of the evidence file to save the request data to
* @param request - the request data
*
* @see https://qytera-gmbh.github.io/projects/cypress-xray-plugin/section/guides/uploadRequestData/
*/
export declare function enqueueTask(task: "cypress-xray-plugin:task:request", filename: string, request: Partial<Cypress.RequestOptions>): Cypress.Chainable<Partial<Cypress.RequestOptions>>;
/**
* Enqueues the plugin task for processing a received response. The plugin internally keeps track
* of all responses enqueued in this way and will upload them as test execution evidence if the
* appropriate options are enabled.
*
* @param task - the task name
* @param filename - the name of the evidence file to save the response data to
* @param response - the response data
*
* @see https://qytera-gmbh.github.io/projects/cypress-xray-plugin/section/guides/uploadRequestData/
*/
export declare function enqueueTask(task: "cypress-xray-plugin:task:response", filename: string, response: Cypress.Response<unknown>): Cypress.Chainable<Cypress.Response<unknown>>;
/**
* Enqueues the plugin task that defines the Xray iteration parameters for the current test run.
*
* @param task - the task name
* @param parameters - the iteration parameters
*/
export declare function enqueueTask(task: "cypress-xray-plugin:task:iteration:definition", parameters: Record<string, string>): Cypress.Chainable<Record<string, string>>;
/**
* Models the parameters for the different plugin tasks.
*/
export interface PluginTaskParameterType {
/**
* The task parameters for defining Xray iteration data.
*/
["cypress-xray-plugin:task:iteration:definition"]: {
/**
* The Xray iteration parameters of the current test.
*/
parameters: Record<string, string>;
/**
* The test name where the task was called.
*/
test: string;
};
/**
* The parameters for an outgoing request task.
*/
["cypress-xray-plugin:task:request"]: {
/**
* The filename of the file where the request data should be saved to.
*/
filename: string;
/**
* The request data.
*/
request: Partial<Cypress.RequestOptions>;
/**
* The test name where `cy.request` was called.
*/
test: string;
};
/**
* The parameters for an incoming response task.
*/
["cypress-xray-plugin:task:response"]: {
/**
* The filename of the file where the response data should be saved to.
*/
filename: string;
/**
* The response data.
*/
response: Cypress.Response<unknown>;
/**
* The test name where `cy.request` was called.
*/
test: string;
};
}
interface PluginTaskReturnType {
/**
* The result of an itereation parameter definition task task.
*/
["cypress-xray-plugin:task:iteration:definition"]: Partial<Cypress.RequestOptions>;
/**
* The result of an outgoing request task.
*/
["cypress-xray-plugin:task:request"]: Partial<Cypress.RequestOptions>;
/**
* The result of an incoming response task.
*/
["cypress-xray-plugin:task:response"]: Cypress.Response<unknown>;
}
type TaskListener = {
[K in Task]: (args: PluginTaskParameterType[K]) => PluginTaskReturnType[K];
};
export declare class CypressTaskListener implements TaskListener {
private readonly projectKey;
private readonly evidenceCollection;
private readonly iterationParameterCollection;
private readonly logger;
private readonly ignoredTests;
constructor(projectKey: string, evidenceCollection: EvidenceCollection, iterationParameterCollection: IterationParameterCollection, logger: Logger);
["cypress-xray-plugin:task:request"](args: PluginTaskParameterType["cypress-xray-plugin:task:request"]): Partial<Cypress.RequestOptions>;
["cypress-xray-plugin:task:response"](args: PluginTaskParameterType["cypress-xray-plugin:task:response"]): Cypress.Response<unknown>;
["cypress-xray-plugin:task:iteration:definition"](args: PluginTaskParameterType["cypress-xray-plugin:task:iteration:definition"]): Record<string, string>;
}
export {};