Skip to content

Commit

Permalink
doc changes (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajaneeshkumar committed May 17, 2024
1 parent 83a25c9 commit 65b3daf
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/api/utils/sleep.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ sleep(milliseconds)
await sleep(1000); // sleeps for 1 second
```

```js
// sleeps for 1 second after running a spec
await spec()
.get('/path')
.expectStatus(200)
.sleep(1000);
```

```js
// Using handler
await spec('get users')
.expectStatus(200)
.sleep(1000);
```

## Arguments

#### > milliseconds (number)
Expand All @@ -37,6 +52,32 @@ const { sleep } = require('pactum');
await sleep(100);
```

## Using Spec

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

await spec()
.get('https://reqres.in/api/path')
.expectStatus(200)
.sleep(1000);
```

## Using Handler

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

handler.addSpecHandler('get users', (ctx) => {
const { spec } = ctx;
spec.get('https://reqres.in/api/users');
});

await spec('get users')
.expectStatus(200)
.sleep(1000);
```

## Yields

Returns a promise that resolves after a given number of milliseconds.

0 comments on commit 65b3daf

Please sign in to comment.