Skip to main content

MetaList <Supported_Context_Type, Item_Type>

Serenity/JS Screenplay Pattern-style wrapper around a ChainableMetaQuestion representing a collection that can be resolved in Supported_Context_Type of another Question.

For example, PageElements.located returns MetaList<PageElement>, which allows for the collection of page elements to be resolved in the context of dynamically-provided root element.

import { By, PageElements, PageElement } from '@serenity-js/web'

const firstLabel = () =>
PageElements.located(By.css('label'))
.first()
.describedAs('first label')

const exampleForm = () =>
PageElement.located(By.css('form#example1'))
.describedAs('example form')

const anotherExampleForm = () =>
PageElement.located(By.css('form#example2'))
.describedAs('another example form')

// Next, you can compose the above questions dynamically with various "contexts":
// firstLabel().of(exampleForm())
// firstLabel().of(anotherExampleForm())

Hierarchy

  • List<Item_Type>
    • MetaList

Implements

Index

Constructors

constructor

  • new MetaList<Supported_Context_Type, Item_Type>(collection: Object): MetaList<Supported_Context_Type, Item_Type>
  • Type parameters

    • Supported_Context_Type
    • Item_Type

    Parameters

    • collection: Object

    Returns MetaList<Supported_Context_Type, Item_Type>

Methods

publicas

  • as<O>(mapping: (answer: Item_Type[]) => O | Promise<O>): QuestionAdapter<O>
  • Maps this question to one of a different type.

    Question.about('number returned as string', actor => '42')   // returns: QuestionAdapter<string>
    .as(Number) // returns: QuestionAdapter<number>

    Type parameters

    • O

    Parameters

    • mapping: (answer: Item_Type[]) => O | Promise<O>

    Returns QuestionAdapter<O>

forEach

  • forEach(callback: (current: CurrentItem<Item_Type>, index: number, items: Item_Type[]) => void | Promise<void>): Task
  • Parameters

    • callback: (current: CurrentItem<Item_Type>, index: number, items: Item_Type[]) => void | Promise<void>

    Returns Task

answeredBy

describedAs

  • describedAs(subject: string): MetaList<Supported_Context_Type, Item_Type>
  • Changes the description of this question’s subject.


    Parameters

    • subject: string

    Returns MetaList<Supported_Context_Type, Item_Type>

toString

  • toString(): string
  • Human-readable description of this MetaQuestion, typically involving the description of the subject.

    For example, a description of a meta question obout “the text of an element” would be text of ${ element.toString() }


    Returns string

of

  • of(context: Answerable<Supported_Context_Type>): MetaList<Supported_Context_Type, Item_Type>
  • Answers the given ChainableMetaQuestion in the context of another Answerable and returns another ChainableMetaQuestion ready for further chaining.

    Learn more


    Parameters

    Returns MetaList<Supported_Context_Type, Item_Type>

eachMappedTo

  • eachMappedTo<Mapped_Item_Type>(question: MetaQuestion<Item_Type, Question<Mapped_Item_Type | Promise<Mapped_Item_Type>>>): MetaList<Supported_Context_Type, Mapped_Item_Type>
  • Type parameters

    • Mapped_Item_Type

    Parameters

    Returns MetaList<Supported_Context_Type, Mapped_Item_Type>

where

  • Type parameters

    • Answer_Type

    Parameters

    Returns MetaList<Supported_Context_Type, Item_Type>

count

first

last

nth

  • Parameters

    • index: number

    Returns MetaQuestionAdapter<Supported_Context_Type, Item_Type>