Skip to content

Class: CmcdReportRecorder ​

Defined in: CmcdReportRecorder.ts:71

Test helper that records CMCD reports from the XHR and fetch transports for assertions in e2e tests. The recorder normalizes each captured request to HttpRequest, so tests are identical regardless of which transport the player uses.

Example ​

ts
const recorder = new CmcdReportRecorder()
recorder.attach({ eventTargetUrls: ['https://events.example.com'] })

// ... player runs, emits CMCD requests ...
await fetch('https://cdn.example.com/seg1.m4s?CMCD=sid%3D%22abc%22')
await fetch('https://cdn.example.com/seg2.m4s?CMCD=sid%3D%22abc%22')

const segments = await recorder.waitForSegments({ count: 2 })
equal(segments.length, 2)

recorder.detach()

Constructors ​

Constructor ​

ts
new CmcdReportRecorder(): CmcdReportRecorder;

Returns ​

CmcdReportRecorder

Methods ​

attach() ​

ts
attach(options?): void;

Defined in: CmcdReportRecorder.ts:160

Install transport patches and start recording CMCD reports. If the recorder is already attached, this call does nothing. The recorder keeps the previous options and silently ignores the new options argument. To re-attach with different options, call detach() first.

Parameters ​

options? ​

CmcdReportRecorderOptions = {}

Returns ​

void


clear() ​

ts
clear(): void;

Defined in: CmcdReportRecorder.ts:205

Discard all recorded reports. Does not affect the attached state.

Returns ​

void


detach() ​

ts
detach(): void;

Defined in: CmcdReportRecorder.ts:181

Remove transport patches and stop recording. Rejects any pending wait promises with Error('Recorder detached while waiting').

Returns ​

void


getReports() ​

ts
getReports(): CmcdRecordedReport[];

Defined in: CmcdReportRecorder.ts:214

Return a copy of all recorded reports.

Returns ​

CmcdRecordedReport[]


waitForEvents() ​

ts
waitForEvents(options?): Promise<CmcdRecordedReport[]>;

Defined in: CmcdReportRecorder.ts:262

Wait until at least count event-mode reports are recorded. Resolves with all matching reports. Rejects with a diagnostic error on timeout. count defaults to 1. timeout defaults to the recorder's waitTimeout option (default 15000 ms).

Parameters ​

options? ​

CmcdReportRecorderWaitOptions = {}

Returns ​

Promise<CmcdRecordedReport[]>


waitForManifest() ​

ts
waitForManifest(options?): Promise<CmcdRecordedReport[]>;

Defined in: CmcdReportRecorder.ts:238

Wait until at least count manifest reports are recorded. Resolves with all matching reports. Rejects with a diagnostic error on timeout. count defaults to 1. timeout defaults to the recorder's waitTimeout option (default 15000 ms).

Parameters ​

options? ​

CmcdReportRecorderWaitOptions = {}

Returns ​

Promise<CmcdRecordedReport[]>


waitForReports() ​

ts
waitForReports(options?): Promise<CmcdRecordedReport[]>;

Defined in: CmcdReportRecorder.ts:226

Wait until at least count reports of any type are recorded. Resolves with all matching reports. Rejects with a diagnostic error on timeout. count defaults to 1. timeout defaults to the recorder's waitTimeout option (default 15000 ms).

Parameters ​

options? ​

CmcdReportRecorderWaitOptions = {}

Returns ​

Promise<CmcdRecordedReport[]>


waitForSegments() ​

ts
waitForSegments(options?): Promise<CmcdRecordedReport[]>;

Defined in: CmcdReportRecorder.ts:250

Wait until at least count segment reports are recorded. Resolves with all matching reports. Rejects with a diagnostic error on timeout. count defaults to 1. timeout defaults to the recorder's waitTimeout option (default 15000 ms).

Parameters ​

options? ​

CmcdReportRecorderWaitOptions = {}

Returns ​

Promise<CmcdRecordedReport[]>

A Streaming Video Technology Alliance project.