Core Modules@serenity-js/assertionsExpectationspropertyexternalproperty Callableproperty<Actual, PropertyName>(propertyName: PropertyName, expectation: Expectation<Actual[PropertyName]>): Expectation<Actual>Creates an expectation that is met when the value of the actual[propertyName] meets the expectation. Ensuring that an array has an itemimport { actorCalled } from '@serenity-js/core'import { Ensure, property } from '@serenity-js/assertions'const list = [ 'hello', 'world' ]await actorCalled('Ester').attemptsTo( Ensure.that(list, property(0, isPresent())),) Ensuring that the property meets an expectationimport { actorCalled } from '@serenity-js/core'import { Ensure, property, equals } from '@serenity-js/assertions'const list = [ 'hello', 'world' ]await actorCalled('Ester').attemptsTo( Ensure.that(list, property('length', equals(2))),) Asserting on a list of objectsimport { actorCalled } from '@serenity-js/core'import { Ensure, property, equals } from '@serenity-js/assertions'const developers = [{ name: 'Jan', id: '@jan-molak',}, { name: 'John', id: '@wakaleo',}]await actorCalled('Ester').attemptsTo( Ensure.that( developers, containItemsWhereEachItem( property('id', startsWith('@')) ), ),)Type parametersActual: objectPropertyName: string | number | symbolParametersexternalpropertyName: PropertyNameexternalexpectation: Expectation<Actual[PropertyName]>Returns Expectation<Actual>
Creates an expectation that is met when the value of the
actual[propertyName]
meets theexpectation
.Ensuring that an array has an item
Ensuring that the property meets an expectation
Asserting on a list of objects