UNPKG

@serenity-js/assertions

Version:

Serenity/JS universal assertion library supporting all types of functional tests, including both web and REST API scenarios

62 lines 1.67 kB
import { Expectation } from '@serenity-js/core'; /** * Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the value of * the `actual[propertyName]` meets the `expectation`. * * ## Ensuring that an array has an item * * ```ts * import { 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 expectation * * ```ts * import { 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 objects * * ```ts * import { 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('@')) * ), * ), * ) * ``` * * @param propertyName * @param expectation * * @group Expectations */ export declare function property<Actual extends object, PropertyName extends keyof Actual>(propertyName: PropertyName, expectation: Expectation<Actual[PropertyName]>): Expectation<Actual>; //# sourceMappingURL=property.d.ts.map