RUM JavaScript API - 1.345.1
    Preparing search index...

    Interface DynatraceTesting

    Testing API for validating observability events and beacon requests during Playwright tests.

    interface DynatraceTesting {
        clearEvents(): void;
        expectToHaveSentEvent(
            event: Record<string, unknown>,
            options?: ExpectOptions,
        ): Promise<void>;
        expectToHaveSentEventTimes(
            event: Record<string, unknown>,
            times: number,
            options?: ExpectOptions,
        ): Promise<void>;
        toMatchEventSnapshot(options?: SnapshotOptions): Promise<void>;
        waitForBeacons(options?: WaitForBeaconsOptions): Promise<BeaconRequest[]>;
    }
    Index

    Methods

    • Clears all events and beacons, allowing for subsequent expectations to ignore events that have been sent in the past. Example:

      sendFooEvent();
      await dynatraceTesting.expectToHaveSentEventTimes({ foo: "bar" }, 1);
      dynatraceTesting.clearEvents();
      await dynatraceTesting.expectToHaveSentEventTimes({ foo: "bar" }, 1);

      Returns void

    • Verifies that a specific event has been sent, optionally within a timeout period.

      Parameters

      • event: Record<string, unknown>

        The event to check, represented as a key-value pair object. This uses Playwrights expect(event).toMatchObject.

      • Optionaloptions: ExpectOptions

        Configuration options for the verification

      Returns Promise<void>

      A promise that resolves when the event is confirmed to have been sent

    • Verifies that a specific event has been sent a specified number of times, optionally within a timeout period.

      Parameters

      • event: Record<string, unknown>

        The event to check, represented as a key-value pair object. This uses Playwrights expect(event).toMatchObject.

      • times: number

        The exact number of times the event is expected to have been sent

      • Optionaloptions: ExpectOptions

        Configuration options for the verification

      Returns Promise<void>

      A promise that resolves when the event is confirmed to have been sent the specified number of times

    • Compares captured events against a stored snapshot file. On first run, creates the snapshot. On subsequent runs, compares and fails if different. Volatile fields (timestamps, IDs, etc.) are masked by default to prevent flaky tests.

      Parameters

      Returns Promise<void>