diff --git a/docs/.vitepress/components/Converter.vue b/docs/.vitepress/components/Converter.vue index a3adeb14..5acded97 100644 --- a/docs/.vitepress/components/Converter.vue +++ b/docs/.vitepress/components/Converter.vue @@ -21,7 +21,7 @@ Convert - + Clear @@ -48,7 +48,7 @@ const generatedCode = ref('') const clearOutput = () => { generatedCode.value = '' } - + const parseCurl = (curlCommand) => { if (!curlCommand) { clearOutput() @@ -204,11 +204,12 @@ select { .convert-button { background-color: var(--vp-c-brand); color: white; - padding: 8px 16px; + padding: 2px 12px; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; + margin: 5px; } .convert-button:hover { diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 879de217..b399f8ea 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -45,7 +45,14 @@ const home_sidebar = [ { text: 'Videos', link: '/media/videos' }, { text: 'Projects', link: '/media/projects' } ] - } + }, + { + text: "💁 FAQs", + collapsed: false, + items: [ + { text: 'Q&A', link: '/faq/qna' }, + ] + }, ]; const tools_sidebar = [ @@ -309,6 +316,7 @@ const config = defineConfig({ '/introduction': home_sidebar, '/guides': home_sidebar, '/media': home_sidebar, + '/faq': home_sidebar, '/api': api_sidebar, '/tools': tools_sidebar }, diff --git a/docs/faq/qna.md b/docs/faq/qna.md new file mode 100644 index 00000000..6c1da558 --- /dev/null +++ b/docs/faq/qna.md @@ -0,0 +1,45 @@ +# Frequently Asked Questions (FAQs) + + +- [What is the http client used by PactumJS](#what-is-the-http-client-used-by-pactumjs) +- [Can PactumJS conditionally proxy or pass through requests sent to mock server to external servers?](#can-pactumjs-conditionally-proxy-or-pass-through-requests-sent-to-mock-server-to-external-servers) +- [How disable or ignore SSL certificate errors in PactumJS?](#how-disable-or-ignore-ssl-certificate-errors-in-pactumjs) +- [What kinds of API testing does PactumJS?](#what-kinds-of-api-testing-does-pactumjs) + +--- + +## What is the http client used by PactumJS + +PactumJS under the hood uses [phin.js](https://github.com/ethanent/phin) for http/https requests. + +## Can PactumJS conditionally proxy or pass through requests sent to mock server to external servers? + +PactumJS currently cannot conditionally proxy or pass-through requests, be it in full or partial sent to mock server to external servers. + +## How disable or ignore SSL certificate errors in PactumJS? + +Yes, it is possible to disable SSL certificate checks/erros similar to "" in NodeJS. Set the `rejectUnauthorized` flag to `false` in the `agent` configuration before firing the request. + +```js +const https = require('https'); +const pactum = require('pactum'); + +// If you have the cert/key pair +const key = fs.readFileSync("server.key") +const cert = fs.readFileSync("server.crt") + +const agent = new https.Agent({ + cert: cert, // Optional - add if cert available + key: key, // Optional - add if key is available + rejectUnauthorized: false // Ignore certificate errors +}); + +pactum.spec() + .get('https://api.example.com') + .withCore({agent: agent }) + .expectStatus(200) +``` + +## What kinds of API testing does PactumJS? +PactumJS currently only support REST/GraphQL API testing over http(s). +