Skip to content

Commit

Permalink
Merge pull request #49 from akhil7000/308-add-message-expect-status
Browse files Browse the repository at this point in the history
docs update: add message expect status
  • Loading branch information
ASaiAnudeep authored May 3, 2024
2 parents 6e8f388 + 34d6574 commit d6d8a33
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/api/assertions/expectStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Assert response status code
expectStatus(status)
```

```js
expectStatus(status, message)
```


## Usage

### ✅ Correct Usage
Expand All @@ -23,6 +28,12 @@ await spec()
.expectStatus(200);
```

```js
await spec()
.get('/api/users')
.expectStatus(200, 'An error occurred in the API call because it did not return the statusCode 200');
```

```js
// bdd style
const _spec = await spec().get('/api/users');
Expand All @@ -35,6 +46,11 @@ _spec.response().to.have.status(200);

Response status code.

#### > message (string)

Custom message.


## Examples

```js
Expand All @@ -45,6 +61,14 @@ await spec()
.expectStatus(200);
```

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

await spec()
.get('https://reqres.in/api/users')
.expectStatus(200, 'An error occurred in the API call because it did not return the statusCode 200');
```

## See Also

- [setDefaultExpectStatus](/api/responses/setDefaultExpectStatus)

0 comments on commit d6d8a33

Please sign in to comment.