liveBook · Manning

Ensure.that

As explained in BDD in Action, Second Edition

Ensure.that is a Serenity/JS interaction that verifies an expectation about a value or state.

Ensure.that verifies that a value or state satisfies an expectation. In a submission flow, it can check that a toaster message includes the expected error text after Wait.until confirms the message is present. section 15.1.7

Directly placing Ensure.that, Wait.until, and Click.on in a Cucumber step works but exposes low-level interface interactions. Composing them into a business-specific verification task makes the step clearer and reusable. section 15.1.7

Checking a failed submission

An actor can attempt VerifySubmission.failedWith('Email exists'). The task can wait for the toaster, use Ensure.that to verify its message and error status, dismiss it, and wait for it to disappear.

How BDD in Action, Second Edition covers it

How deep it goes
Explains expectation checking and task composition but defers the assertion library's internal implementation.
Examples
Uses a duplicate-email toaster notification and a VerifySubmission.failedWith task to demonstrate error verification.
What you can do after
Apply it via Serenity/JS assertions to verify values or states inside reusable verification tasks.
How it connects
Connects assertions with Wait.until, Click.on, Cucumber step definitions, page elements, and reusable tasks.

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.