|
| 1 | +# Frequently Asked Questions (FAQs) |
| 2 | + |
| 3 | +<!-- Table of Contents --> |
| 4 | +- [What is the http client used by PactumJS](#what-is-the-http-client-used-by-pactumjs) |
| 5 | +- [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) |
| 6 | +- [How disable or ignore SSL certificate errors in PactumJS?](#how-disable-or-ignore-ssl-certificate-errors-in-pactumjs) |
| 7 | +- [What kinds of API testing does PactumJS?](#what-kinds-of-api-testing-does-pactumjs) |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## What is the http client used by PactumJS |
| 12 | + |
| 13 | +PactumJS under the hood uses [phin.js](https://github.com/ethanent/phin) for http/https requests. |
| 14 | + |
| 15 | +## Can PactumJS conditionally proxy or pass through requests sent to mock server to external servers? |
| 16 | + |
| 17 | +PactumJS currently cannot conditionally proxy or pass-through requests, be it in full or partial sent to mock server to external servers. |
| 18 | + |
| 19 | +## How disable or ignore SSL certificate errors in PactumJS? |
| 20 | + |
| 21 | +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. |
| 22 | + |
| 23 | +```js |
| 24 | +const https = require('https'); |
| 25 | +const pactum = require('pactum'); |
| 26 | + |
| 27 | +// If you have the cert/key pair |
| 28 | +const key = fs.readFileSync("server.key") |
| 29 | +const cert = fs.readFileSync("server.crt") |
| 30 | + |
| 31 | +const agent = new https.Agent({ |
| 32 | + cert: cert, // Optional - add if cert available |
| 33 | + key: key, // Optional - add if key is available |
| 34 | + rejectUnauthorized: false // Ignore certificate errors |
| 35 | +}); |
| 36 | + |
| 37 | +pactum.spec() |
| 38 | + .get('https://api.example.com') |
| 39 | + .withCore({agent: agent }) |
| 40 | + .expectStatus(200) |
| 41 | +``` |
| 42 | + |
| 43 | +## What kinds of API testing does PactumJS? |
| 44 | +PactumJS currently only support REST/GraphQL API testing over http(s). |
| 45 | + |
0 commit comments