-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from pactumjs/https-mock-server-support-docs
Https mock server docs update
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# setDefaults | ||
|
||
Set default configurations for the mock server. | ||
|
||
## Syntax | ||
|
||
```js | ||
setDefaults(mockOptions) | ||
``` | ||
|
||
## Usage | ||
|
||
### ✅ Correct Usage | ||
|
||
```js | ||
// set port | ||
mock.setDefaults({port: 3000}); | ||
``` | ||
|
||
```js | ||
// set port and hostname | ||
mock.setDefaults({port: 3000, host: '127.0.0.1'}); | ||
``` | ||
|
||
```js | ||
// set port, hostname and https options - runs https mock server | ||
await mock.setDefaults({port: 3001, host: '127.0.0.1', httpsOpts: {key: "key-path", cert: "cert-path"}}) | ||
``` | ||
|
||
::: tip NOTE | ||
If the `httpsOpts` are provided, then mock server will run on https else it will run on http (default). | ||
::: | ||
|
||
|
||
|
||
## Arguments | ||
|
||
`mockOptions` object | ||
|
||
| Property | Description | | ||
| ------------------------ | ------------------------------------------------------------------------------- | | ||
| port | mock server port [`number`] , default: `9393` | | ||
| host | host name (`localhost`, `127.0.0.1` etc) [`string`] default: `0.0.0.0` | | ||
| httsOpts | https key and certs [`object`], pass this parameter to run https mock server | | ||
| httsOpts.key | path to `.key` file | | ||
| httsOpts.cert | path to `.crt` file | | ||
|
||
## Examples | ||
|
||
### Normal | ||
|
||
```js | ||
const pactum = require('pactum'); | ||
const mock = pactum.mock; | ||
|
||
const mockOpts = {port: 3001, host: '127.0.0.1', httpsOpts: {key: "server.key", cert: "server.crt"}}; | ||
await mock.setDefaults(mockOpts) | ||
await mock.start(); | ||
``` | ||
|
||
## See Also | ||
|
||
- [Mock server](/guides/mock-server) | ||
- [Mock server start](/api/mock/start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters