Skip to content

Commit

Permalink
docs utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ASaiAnudeep committed Aug 3, 2024
1 parent c7cf84d commit 0cafdd0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 25 deletions.
19 changes: 10 additions & 9 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const api_sidebar = [
{ text: 'setDefaultExpectHandlers', link: '/api/responses/setDefaultExpectHandlers', },
{ text: 'removeDefaultExpectHeader', link: '/api/responses/removeDefaultExpectHeader', },
{ text: 'removeDefaultExpectHeaders', link: '/api/responses/removeDefaultExpectHeaders', },
{ text: 'removeDefaultExpectHandlers', link: '/api/responses/removeDefaultExpectHandlers', }
{ text: 'removeDefaultExpectHandlers', link: '/api/responses/removeDefaultExpectHandlers', }
]
},
{
Expand All @@ -122,7 +122,7 @@ const api_sidebar = [
{ text: 'expectBodyContains', link: '/api/assertions/expectBodyContains', },
{ text: 'expectResponseTime', link: '/api/assertions/expectResponseTime', },
{ text: 'expectError', link: '/api/assertions/expectError', },
{ text: 'expect', link: '/api/assertions/expect', }
{ text: 'expect', link: '/api/assertions/expect', }
]
},
{
Expand All @@ -131,7 +131,8 @@ const api_sidebar = [
items: [
{ text: 'clone', link: '/api/utils/clone', },
{ text: 'parse', link: '/api/utils/parse', },
{ text: 'sleep', link: '/api/utils/sleep' }
{ text: 'sleep', link: '/api/utils/sleep' },
{ text: 'findFile', link: '/api/utils/findFile' }
]
},
{
Expand All @@ -156,7 +157,7 @@ const api_sidebar = [
{ text: 'lte', link: '/api/matching/lte', },
{ text: 'notIncludes', link: '/api/matching/notIncludes', },
{ text: 'notNull', link: '/api/matching/notNull', },
{ text: 'notEquals', link: '/api/matching/notEquals', }
{ text: 'notEquals', link: '/api/matching/notEquals', }
]
},
{
Expand All @@ -179,7 +180,7 @@ const api_sidebar = [
{ text: 'setReporterAutoRun', link: '/api/settings/setReporterAutoRun', },
{ text: 'setRequestDefaultRetryCount', link: '/api/settings/setRequestDefaultRetryCount', },
{ text: 'setRequestDefaultRetryDelay', link: '/api/settings/setRequestDefaultRetryDelay', },
{ text: 'setDataDirectory', link: '/api/settings/setDataDirectory', },
{ text: 'setDataDirectory', link: '/api/settings/setDataDirectory', },
{ text: 'removeDefaultHeaders', link: '/api/settings/removeDefaultHeaders', },
]
},
Expand All @@ -195,7 +196,7 @@ const api_sidebar = [
{ text: 'addRetryHandler', link: '/api/handlers/addRetryHandler', },
{ text: 'addSpecHandler', link: '/api/handlers/addSpecHandler', },
{ text: 'addStateHandler', link: '/api/handlers/addStateHandler', },
{ text: 'addWaitHandler', link: '/api/handlers/addWaitHandler', }
{ text: 'addWaitHandler', link: '/api/handlers/addWaitHandler', }
]
},
{
Expand All @@ -211,7 +212,7 @@ const api_sidebar = [
{ text: 'clearInteractions', link: '/api/mock/clearInteractions', },
{ text: 'getInteraction', link: '/api/mock/getInteraction', },
{ text: 'removeInteraction', link: '/api/mock/removeInteraction', },
{ text: 'useRemoteServer', link: '/api/mock/useRemoteServer', }
{ text: 'useRemoteServer', link: '/api/mock/useRemoteServer', }
]
},
{
Expand All @@ -222,7 +223,7 @@ const api_sidebar = [
{ text: 'getDataTemplate', link: '/api/stash/getDataTemplate', },
{ text: 'addDataMap', link: '/api/stash/addDataMap', },
{ text: 'getDataMap', link: '/api/stash/getDataMap', },
{ text: 'loadData', link: '/api/stash/loadData', }
{ text: 'loadData', link: '/api/stash/loadData', }
]
},
{
Expand All @@ -231,7 +232,7 @@ const api_sidebar = [
items: [
{ text: 'fuzz', link: '/api/fuzz/fuzz', },
{ text: 'onSwagger', link: '/api/fuzz/onSwagger', },
{ text: 'withBatchSize', link: '/api/fuzz/withBatchSize', }
{ text: 'withBatchSize', link: '/api/fuzz/withBatchSize', }
]
},
];
Expand Down
10 changes: 3 additions & 7 deletions docs/.vitepress/theme/AdComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Icon from "./Icon.vue";
<a target="_blank" href="https://testbeats.com">
<Icon class="icon" />
<span
>Keep your tests in tune with</span
>Revolutionize Your Test Reporting with AI-Powered Insights</span
>
<span class="cta">testbeats</span>
<span class="cta">TestBeats</span>
</a>
</div>
Expand All @@ -32,7 +32,7 @@ import Icon from "./Icon.vue";
text-align: center;
margin-bottom: 2rem;
padding: 0.5rem 0.85rem;
border: 1px solid var(--vp-c-brand);
border: 2px solid var(--vp-c-brand);
border-radius: 4px;
text-decoration: none;
color: white;
Expand All @@ -42,10 +42,6 @@ import Icon from "./Icon.vue";
background-image: linear-gradient(to top right, #000000, #000842);
}
.ad-component:hover {
color: var(--vp-c-text-1);
}
.ad-component .icon {
display: inline-block;
width: 1rem;
Expand Down
4 changes: 2 additions & 2 deletions docs/api/utils/clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Input could by anything.
## Examples

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

const user = { name: "mom", age: 50 };

Expand All @@ -40,7 +40,7 @@ await spec()
.withJson(user)
.expectStatus(200);

const user_two = clone(user);
const user_two = utils.clone(user);
user_two.name = "dad";

await spec()
Expand Down
51 changes: 51 additions & 0 deletions docs/api/utils/findFile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
tags:
- file
- find file
- search file
---

# findFile

Finds a file recursively in a given path.


## Syntax

```js
findFile(name);
findFile(name, path);
```

## Usage

### ✅ Correct Usage

```js
findFile('file.txt');
findFile('file.txt', 'path/to/the/dir');
```

## Arguments

#### > name (string)

Name of the file to find.

#### > path (string)

Path to the directory to search in. Defaults to data directory - `data`.

## Examples

### Reading a JSON File

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

const user = JSON.parse(utils.findFile('user.json'));
```

## See Also

- [setDataDirectory](/api/settings/setDataDirectory)
14 changes: 7 additions & 7 deletions docs/api/utils/sleep.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ await sleep(1000); // sleeps for 1 second
```

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

```js
Expand All @@ -47,9 +47,9 @@ Number of milliseconds to sleep.
## Examples

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

await sleep(100);
await utils.sleep(100);
```

## Using Spec
Expand All @@ -60,13 +60,13 @@ const { spec } = require('pactum');
await spec()
.get('https://reqres.in/api/path')
.expectStatus(200)
.sleep(1000);
.sleep(1000);
```

## Using Handler

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

handler.addSpecHandler('get users', (ctx) => {
const { spec } = ctx;
Expand All @@ -75,7 +75,7 @@ handler.addSpecHandler('get users', (ctx) => {

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

## Yields
Expand Down

0 comments on commit 0cafdd0

Please sign in to comment.