diff --git a/CHANGELOG.md b/CHANGELOG.md index 36690cb..5693274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### Added +- Public Reporting API method `addParameters` ## [5.0.6] - 2022-01-13 ### Fixed diff --git a/lib/constants/events.js b/lib/constants/events.js index c9b5bd3..ffad224 100644 --- a/lib/constants/events.js +++ b/lib/constants/events.js @@ -6,6 +6,7 @@ const EVENTS = { ADD_ATTRIBUTES: 'rp:addAttributes', ADD_LOG: 'rp:addLog', ADD_LAUNCH_LOG: 'rp:addLaunchLog', + ADD_PARAMETERS: 'rp:addParameters', }; module.exports = { EVENTS }; diff --git a/lib/publicReportingAPI.js b/lib/publicReportingAPI.js index e90b8a0..7994290 100644 --- a/lib/publicReportingAPI.js +++ b/lib/publicReportingAPI.js @@ -87,6 +87,18 @@ class PublicReportingAPI { static setStatus(status, suite) { process.emit(EVENTS.SET_STATUS, { status, suite }); } + + /** + * Emit add parameters event. + * @param {Array} parameters - array of parameters, should looks like this: + * [{ + * key: "paramKey", + * value: "paramValue", + * }] + */ + static addParameters(parameters) { + process.emit(EVENTS.ADD_PARAMETERS, { parameters }); + } } module.exports = PublicReportingAPI; diff --git a/spec/publicReportingAPI.spec.js b/spec/publicReportingAPI.spec.js index 9a3ff37..d41a6a5 100644 --- a/spec/publicReportingAPI.spec.js +++ b/spec/publicReportingAPI.spec.js @@ -72,4 +72,14 @@ describe('PublicReportingAPI', () => { suite: 'suite', }); }); + + it('addParameters should trigger process.emit with correct parameters', () => { + spyOn(process, 'emit'); + + PublicReportingAPI.addParameters([{ value: 'value' }]); + + expect(process.emit).toHaveBeenCalledWith(EVENTS.ADD_PARAMETERS, { + parameters: [{ value: 'value' }], + }); + }); });