Skip to content
On this page

Empower Your Test Results with AI-Powered Insights ->

expectBodyContains

Performs partial equal on body text.

Use this for text comparison.

Syntax

js
expectBodyContains(body)

Usage

โœ… Correct Usage

js
await spec()
  .get('/api/health')
  .expectBodyContains('OK');
js
// bdd style
const _spec = await spec().get('/api/health');
_spec.response().to.have.bodyContains('OK');

Arguments

> body (string)

Response body.

Examples

js
const { spec } = require('pactum');

await spec()
  .get('https://httpbin.org/robots.txt')
  .expectBodyContains(`User-agent: *`);

Released under the MIT License.