Asserts that the body of the most recent API response contains the given text. If the response body is JSON, it is serialized to a string before matching, so the step works for both plain-text and JSON responses. The match is case-insensitive and treats the expected value as literal text, not a pattern.
A request must have been sent earlier in the scenario, otherwise the step fails with No API response available. On failure the message includes the full response body, which helps diagnose what the endpoint actually returned. For structural checks on JSON responses, prefer the JSON property assertions instead of substring matching.
Accepted phrasings
Then the API response should contain "text"
Then API response should contain "text"
Examples
Then the API response should contain "success"
Then API response should contain "John Doe"
Then the API response should contain "published"
Then API response should contain "email"
In a real scenario
Feature: User lookup API
Scenario: Fetching a user returns their profile data
Given the API base URL is "https://api.example.org"
And I set header "Accept" to "application/json"
When I send a GET request to "/users/1"
Then the API response code should be 200
And the API response should contain "John Doe"
And the API response should contain "john@example.org"
And the API response should not contain "error"