Skip to main content

externalOutcomeBadge <NET>

Interaction object representing an outcome badge icon showing the execution result of a test scenario (passed, failed, pending, etc.).

Unlike most interaction objects in the HTML reporter, OutcomeBadge does not extend InteractionObject — it takes a root element directly. This keeps it lightweight for embedding inside other interaction objects like ScenarioItem or ActivityItem.

The badge communicates outcome both visually (via an icon/colour) and semantically (via the data-outcome attribute), making it accessible to both sighted users and automated tests.

Instantiation (within a parent interaction object)

import { OutcomeBadge } from '@serenity-js/html-reporter/serenity';
import { By } from '@serenity-js/web';

export class ScenarioItem<NET> extends InteractionObject<NET> {
readonly badge = new OutcomeBadge(this.child(By.css('[data-testid="outcome-badge"]')));
}

Usage in a test

await actor.attemptsTo(
Ensure.that(badge.outcomeType(), equals('FAILURE')),
Ensure.that(badge.iconText(), equals('✗')),
);

Index

Constructors

externalconstructor

Methods

externaliconText

  • The visible text of the outcome badge (typically an icon character like '✓', '✗', '⏸').

    Example

    await actor.attemptsTo(
    Ensure.that(badge.iconText(), equals('✗')),
    );

    Returns QuestionAdapter<string>

externaloutcomeType

  • The data-outcome attribute value representing the scenario's execution result (e.g. 'SUCCESS', 'FAILURE', 'PENDING', 'SKIPPED', 'COMPROMISED', 'ERROR').

    Example

    await actor.attemptsTo(
    Ensure.that(badge.outcomeType(), equals('FAILURE')),
    );

    Returns QuestionAdapter<string>

Page Options