Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Added
- TypeScript type definitions. Thanks to [@AlexGalichenko](https://github.com/AlexGalichenko).
### Security
- Updated versions of vulnerable packages (form-data).

## [5.4.0] - 2025-03-27
### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
5.4.1-SNAPSHOT
288 changes: 288 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
declare module '@reportportal/client-javascript' {
/**
* Configuration options for initializing the Report Portal client.
*
* @example
* ```typescript
* const rp = new ReportPortalClient({
* endpoint: 'https://your.reportportal.server/api/v1',
* project: 'your_project_name',
* apiKey: 'your_api_key',
* });
* ```
*/
export interface ReportPortalConfig {
apiKey: string;
endpoint: string;
launch: string;
project: string;
headers?: Record<string, string>;
debug?: boolean;
isLaunchMergeRequired?: boolean;
launchUuidPrint?: boolean;
launchUuidPrintOutput?: string;
restClientConfig?: Record<string, unknown>;
token?: string;
}

/**
* Options to start a new launch.
*
* @example
* ```typescript
* const launch = rp.startLaunch({
* name: 'My Test Launch',
* startTime: rp.helpers.now(),
* });
* ```
*/
export interface LaunchOptions {
name?: string;
startTime?: string;
description?: string;
attributes?: Array<{ key: string; value?: string } | string>;
mode?: string;
id?: string;
}

/**
* Options to start a new test item (e.g., test case or suite).
*
* @example
* ```typescript
* const testItem = rp.startTestItem({
* name: 'My Test Case',
* type: 'TEST',
* startTime: rp.helpers.now(),
* });
* ```
*/
export interface StartTestItemOptions {
name: string;
type: string;
description?: string;
startTime?: string;
attributes?: Array<{ key: string; value?: string } | string>;
hasStats?: boolean;
}

/**
* Options to send logs to Report Portal.
*
* @example
* ```typescript
* await rp.sendLog(testItem.tempId, {
* level: 'INFO',
* message: 'Step executed successfully',
* time: rp.helpers.now(),
* });
* ```
*/
export interface LogOptions {
level?: string;
message?: string;
time?: string;
file?: {
name: string;
content: string;
type: string;
};
}

/**
* Options to finish a test item.
*
* @example
* ```typescript
* await rp.finishTestItem(testItem.tempId, {
* status: 'PASSED',
* endTime: rp.helpers.now(),
* });
* ```
*/
export interface FinishTestItemOptions {
status?: string;
endTime?: string;
issue?: {
issueType: string;
comment?: string;
externalSystemIssues?: Array<any>
};
}

/**
* Options to finish a launch.
*
* @example
* ```typescript
* await rp.finishLaunch(launch.tempId, {
* endTime: rp.helpers.now(),
* });
* ```
*/
export interface FinishLaunchOptions {
endTime?: string;
status?: string;
}

/**
* Main Report Portal client for interacting with the API.
*/
export default class ReportPortalClient {
/**
* Initializes a new Report Portal client.
*/
constructor(config: ReportPortalConfig);

/**
* Starts a new launch.
* @example
* ```typescript
* const launchObj = rpClient.startLaunch({
* name: 'Client test',
* startTime: rpClient.helpers.now(),
* description: 'description of the launch',
* attributes: [
* {
* 'key': 'yourKey',
* 'value': 'yourValue'
* },
* {
* 'value': 'yourValue'
* }
* ],
* //this param used only when you need client to send data into the existing launch
* id: 'id'
* });
* await launchObj.promise;
* ```
*/
startLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> };

/**
* Finishes an active launch.
* @example
* ```typescript
* const launchFinishObj = rpClient.finishLaunch(launchObj.tempId, {
* endTime: rpClient.helpers.now()
* });
* await launchFinishObj.promise;
* ```
*/
finishLaunch(launchId: string, options?: FinishLaunchOptions): Promise<any>;

/**
* Update the launch data
* @example
* ```typescript
* const updateLunch = rpClient.updateLaunch(
* launchObj.tempId,
* {
* description: 'new launch description',
* attributes: [
* {
* key: 'yourKey',
* value: 'yourValue'
* },
* {
* value: 'yourValue'
* }
* ],
* mode: 'DEBUG'
* }
* );
* await updateLaunch.promise;
* ```
*/
updateLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> };

/**
* Starts a new test item under a launch or parent item.
* @example
* ```typescript
* const suiteObj = rpClient.startTestItem({
* description: makeid(),
* name: makeid(),
* startTime: rpClient.helpers.now(),
* type: 'SUITE'
* }, launchObj.tempId);
* const stepObj = rpClient.startTestItem({
* description: makeid(),
* name: makeid(),
* startTime: rpClient.helpers.now(),
* attributes: [
* {
* key: 'yourKey',
* value: 'yourValue'
* },
* {
* value: 'yourValue'
* }
* ],
* type: 'STEP'
* }, launchObj.tempId, suiteObj.tempId);
* ```
*/
startTestItem(options: StartTestItemOptions, launchId: string, parentId?: string): {
tempId: string;
promise: Promise<any>
};

/**
* Finishes a test item.
* @example
* ```typescript
* rpClient.finishTestItem(itemObj.tempId, {
* status: 'failed'
* });
* ```
*/
finishTestItem(itemId: string, options: FinishTestItemOptions): Promise<any>;

/**
* Sends a log entry to a test item.
* @example
* ```typescript
* await rpClient.sendLog(stepObj.tempId, {
* level: 'INFO',
* message: 'User clicks login button',
* time: rpClient.helpers.now()
* });
* ```
*/
sendLog(itemId: string, options: LogOptions): Promise<any>;

/**
* Waits for all test items to be finished.
* @example
* ```typescript
* await agent.getPromiseFinishAllItems(agent.tempLaunchId);
* ```
*/
getPromiseFinishAllItems(launchId: string): Promise<any>;

/**
* Check if connection is established
* @example
* ```typescript
* await agent.checkConnect();
* ```
*/
checkConnect(): Promise<any>;

helpers: {
/**
* Generate ISO timestamp
* @example
* ```typescript
* await rpClient.sendLog(stepObj.tempId, {
* level: 'INFO',
* message: 'User clicks login button',
* time: rpClient.helpers.now()
* });
* ```
*/
now(): string
}
}
}
Loading
Loading