diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 7c128d83..79fcd15f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -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', } ] }, { @@ -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', } ] }, { @@ -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' } ] }, { @@ -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', } ] }, { @@ -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', }, ] }, @@ -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', } ] }, { @@ -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', } ] }, { @@ -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', } ] }, { @@ -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', } ] }, ]; diff --git a/docs/.vitepress/theme/AdComponent.vue b/docs/.vitepress/theme/AdComponent.vue index b14dc7a6..66f5b1cc 100644 --- a/docs/.vitepress/theme/AdComponent.vue +++ b/docs/.vitepress/theme/AdComponent.vue @@ -7,9 +7,9 @@ import Icon from "./Icon.vue"; Keep your tests in tune withRevolutionize Your Test Reporting with AI-Powered Insights - testbeats + TestBeats @@ -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; @@ -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; diff --git a/docs/api/utils/clone.md b/docs/api/utils/clone.md index c8d61cb8..b65bbbe6 100644 --- a/docs/api/utils/clone.md +++ b/docs/api/utils/clone.md @@ -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 }; @@ -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() diff --git a/docs/api/utils/findFile.md b/docs/api/utils/findFile.md new file mode 100644 index 00000000..7cb2ee23 --- /dev/null +++ b/docs/api/utils/findFile.md @@ -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) \ No newline at end of file diff --git a/docs/api/utils/sleep.md b/docs/api/utils/sleep.md index 6cbecc1f..a97dea6d 100644 --- a/docs/api/utils/sleep.md +++ b/docs/api/utils/sleep.md @@ -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 @@ -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 @@ -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; @@ -75,7 +75,7 @@ handler.addSpecHandler('get users', (ctx) => { await spec('get users') .expectStatus(200) - .sleep(1000); + .sleep(1000); ``` ## Yields