EPMRPP-89496 || Migrate client-javascript to TypeScript
Summary by CodeRabbit
-
Breaking Changes
- RPClient constructor and several public methods have updated signatures (e.g., startTestItem now uses name/codeRef; getRejectAnswer expects Error); update callers and imports for ESM-named exports. Node.js >=16 required.
-
New Features
- Optional agent metadata for the client (name, version).
- Added OUTPUT_TYPES handlers for launch UUID (stdout, stderr, env, file).
- Config gains skippedIssue flag and expanded TypeScript typings across the public API.
-
Tests & Tooling
- Jest and CI updated to support TypeScript tests.
Walkthrough
Converted the codebase from CommonJS JavaScript to TypeScript ES modules across core libraries, tests, and tooling; introduced typed APIs and types file, migrated/restyled constants, helpers, client, rest client, logger, statistics, and packaging, added/updated tests, and adjusted ESLint/Jest/TS configs and package exports.
Changes
| Cohort / File(s) | Summary |
|---|---|
ESLint config.\.eslintrc |
Replace Airbnb base with airbnb-typescript/base, enable es6/node env, adjust extends/plugins/globals and replace many TS-specific rules with JS equivalents or new entries. |
Jest & TS configjest.config.js, tsconfig.json |
Add ts-jest transform, include .ts tests, collect coverage from TS, enable resolveJsonModule, and disable declarationMap (commented). |
Packaging & types exposurepackage.json, index.d.ts |
Point main/types to build/*, add exports and typesVersions map, set "type":"commonjs", raise Node engine to ≥16, publish build folder, and add skippedIssue?: boolean in typings. |
Core typeslib/types.ts |
Add comprehensive TypeScript public types/interfaces for ClientConfig, AgentParams, Launch/Test items, File/Log shapes, ItemObj, MapType, and TempIdPromise. |
ReportPortal client refactorlib/report-portal-client.ts, __tests__/report-portal-client.spec.ts |
Large TS migration: strong typing, new/updated constructor (agentParams), many method signature changes, added private/protected fields, multipart/file upload paths, and default export. |
REST client & loggerlib/rest.ts, lib/logger.ts, __tests__/rest.spec.ts |
Migrate RestClient to TS with typed options/methods/generic request<T>, add typed addLogger attaching Axios interceptors, replace removed JS logger, and add/replace TS tests. |
Helpers & commonslib/helpers.ts, lib/commons/config.ts, lib/commons/errors.ts, __tests__/helpers.spec.ts, __tests__/config.spec.ts |
Migrate to TS/ESM, add strict typings and signatures (e.g., generateTestCaseId(codeRef, params?)), generic config/getters, deprecation warning in getApiKey, typed error classes, and tests adjusted/cast. |
Constants: events/outputs/statuseslib/constants/events.ts, lib/constants/outputs.ts (new), lib/constants/outputs.js (removed), lib/constants/statuses.ts (new), lib/constants/statuses.js (removed), __tests__/outputs.spec.ts |
Convert EVENTS to named export, reintroduce OUTPUT_TYPES in TS, replace statuses object with TS enum, remove old JS files, and add tests for output handlers. |
Public Reporting APIlib/publicReportingAPI.ts, lib/publicReportingAPI.js (removed), __tests__/publicReportingAPI.spec.ts |
Reimplement PublicReportingAPI in TS as default export; static methods emit EVENTS via process.emit; tests updated to ESM. |
Logger removal/addlib/logger.js (removed), lib/logger.ts |
Remove JS logger, add typed TS addLogger(axiosInstance) that logs request/response/error with timings. |
Statistics & client-idstatistics/*.ts, statistics/client-id.ts, statistics/constants.ts, statistics/statistics.ts, __tests__/statistics.spec.ts, __tests__/client-id.spec.ts |
Migrate statistics modules and client-id to TS/ESM, add typings, adjust exports and constructor/signatures, simplify uuidv4() usage, and update tests. |
Tests: ESM/TS conversions & additions__tests__/* (many .spec.ts additions/updates, deletions of .js tests) |
Convert many tests from CommonJS to ESM/TS, add __tests__/outputs.spec.ts, replace old rest.spec.js with rest.spec.ts, update mocking/assertions and uuid usage. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant TestRunner
participant API as PublicReportingAPI
participant Proc as process
TestRunner->>API: PublicReportingAPI.setDescription(text, suite?)
API->>Proc: process.emit(EVENTS.SET_DESCRIPTION, {text, suite})
TestRunner->>API: PublicReportingAPI.addLog(log, suite?)
API->>Proc: process.emit(EVENTS.ADD_LOG, {log, suite})
TestRunner->>API: PublicReportingAPI.setStatus(status, suite?)
API->>Proc: process.emit(EVENTS.SET_STATUS, {status, suite})
note right of API: Thin TS wrapper emitting events
sequenceDiagram
autonumber
participant Caller
participant RP as RPClient
participant Rest as RestClient
participant Axios as AxiosInstance
participant Logger as addLogger
Caller->>RP: new RPClient(options, agentParams)
RP->>Rest: new RestClient(restOptions)
alt Rest debug enabled
Rest->>Logger: addLogger(Axios)
end
RP->>Rest: POST /launch (startLaunch)
Rest-->>RP: { id, uuid }
RP->>Rest: POST /item (startTestItem with {name, codeRef})
Rest-->>RP: { id, uuid }
RP->>Rest: PUT /item/{id} (finishTestItem)
Rest-->>RP: ack
Estimated code review effort
🎯 5 (Critical) | ⏱️ ~120 minutes
Pre-merge checks (1 passed, 2 warnings)
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description Check | ⚠️ Warning | The pull request does not include any description, leaving reviewers without context on the scope, motivation, or high-level details of the migration. | Please add a descriptive summary that outlines the purpose of the TypeScript migration, key refactoring steps performed, and any impacts on the public API or configuration. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (1 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | ✅ Passed | The title succinctly highlights the most significant change—migrating the client-javascript library to TypeScript—and directly aligns with the pull request’s core objective without extraneous details. |
Poem
Thump-thump on keys I hop and write,
CommonJS to TS by moonlit byte.
Enums hop, events softly cheer,
Axios clocks the logs we hear.
UUIDs glow — the rabbit grins: ship near! 🐇✨
[!TIP]
👮 Agentic pre-merge checks are now available in preview!
Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
- Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
- Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.
Example:
reviews: pre_merge_checks: custom_checks: - name: "Undocumented Breaking Changes" mode: "warning" instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post.
✨ Finishing Touches
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
feature/EPMRPP-89496-Migrate-client-javascript-to-TypeScript
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Great work on this! I'm looking forward to getting these changes soon. Do you have an ETA for when this might be merged?