import {Property} from '@serenity-js/core/lib/screenplay/questions'
public class | source

Property

Enables easy access to properties of the value of a given Answerable.

Examples:

Example API response
 interface EnvironmentDetails {
     name: string;
     url:  string;
 }

 interface EnvironmentsResponse {
     environments: EnvironmentDetails[];
 }

 const response: EnvironmentsResponse = {
    "environments": [
        {
            "name": "dev",
            "url":  "https://dev.example.com"
        },
        {
            "name": "sit",
            "url":  "https://sit.example.com"
        }
    ]
 }
Combining Property.of and Property.at
 import { actorCalled, List, Property } from '@serenity-js/core';
 import { Ensure, equals } from '@serenity-js/assertions';

 actorCalled('Lisa').attemptsTo(
     Ensure.that(
         Property.of(
             List.of(response.environments)
                 .where(Property.at<EnvironmentDetails>().name, equals('dev'))
                 .first(),
         ).url,
         equals('https://dev.example.com')
     )
 )

See also:

Static Method Summary

Static Public Methods
public static

at(): Proxy<Subject>

Generates a Proxy around a given Answerable subject to turn any of its properties into MetaQuestions to be used when filtering a List,

public static

of(subject: Answerable<Subject>): Proxy<Subject>

Generates a Proxy around a given Answerable subject to turn the properties of the value it will resolve to into Questions.

Static Public Methods

public static at(): Proxy<Subject> source

Generates a Proxy around a given Answerable subject to turn any of its properties into MetaQuestions to be used when filtering a List,

Returns:

Proxy<Subject>

Examples:

Reading a property
 import { actorCalled, Property } from '@serenity-js/core';
 import { Ensure, equals } from '@serenity-js/assertions';

 actorCalled('Lisa').attemptsTo(
     Ensure.that(
         List.of(response.environments)
             .where(Property.at<EnvironmentDetails>().name, equals('dev'))
             .first(),
         equals(response.environments[0])
     )
 )

public static of(subject: Answerable<Subject>): Proxy<Subject> source

Generates a Proxy around a given Answerable subject to turn the properties of the value it will resolve to into Questions.

Params:

NameTypeAttributeDescription
subject Answerable<Subject>

Returns:

Proxy<Subject>

Examples:

Reading a property
 import { actorCalled, Property } from '@serenity-js/core';
 import { Ensure, equals } from '@serenity-js/assertions';

 actorCalled('Lisa').attemptsTo(
     Ensure.that(
         Property.of(response).environments[0].name,
         equals('dev')
     )
 )