diff --git a/docs/api/utils/sleep.md b/docs/api/utils/sleep.md index f943f6d6..6cbecc1f 100644 --- a/docs/api/utils/sleep.md +++ b/docs/api/utils/sleep.md @@ -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) @@ -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. \ No newline at end of file