wiremock-rest-client
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "wiremock-rest-client", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Lightweight REST client to interact with a running WireMock server", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"build": "tsc", | ||
"lint": "tslint", | ||
"lint": "eslint src/**/*.ts", | ||
"prepare": "npm run build", | ||
@@ -15,0 +15,0 @@ "preversion": "npm run lint", |
105
README.md
# WireMock REST Client | ||
The WireMock REST client is a lightweight module to interact with a running [WireMock](http://wiremock.org) server based on the [OpenAPI 3.0 spec](http://wiremock.org/docs/api/) via REST. | ||
## Description | ||
WireMock REST client is a lightweight client to interact with a running [WireMock](http://wiremock.org) server based on the [OpenAPI 3.0 spec](http://wiremock.org/docs/api/). | ||
<!-- TOC --> | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Global](#global) | ||
- [Stub mappings](#stub-mappings) | ||
- [Recordings](#recordings) | ||
- [Requests](#requests) | ||
- [Scenarios](#scenarios) | ||
- [Logging](#logging) | ||
<!-- /TOC --> | ||
@@ -19,6 +29,5 @@ ## Installation | ||
Each service contain methods to perform operations on WireMock endpoints. | ||
See the [API](#api) for the available methods. All methods are related to available operations on the WireMock server endpoints. | ||
**Example:** | ||
```javascript | ||
```js | ||
import { WireMockRestClient } from 'wiremock-rest-client'; | ||
@@ -32,2 +41,35 @@ | ||
await wireMock.global.shutdown(); | ||
``` | ||
## API | ||
### Global | ||
- `updateGlobalSettings(delayDefinition: DelayDefinition): Promise<void>` | ||
- `resetAll(): Promise<void>` | ||
- `shutdown(): Promise<void>` | ||
Example: | ||
```js | ||
await wireMockRestClient.global.resetAll(); | ||
``` | ||
### Stub mappings | ||
- `getAllMappings(): Promise<StubMappings>` | ||
- `createMapping(stubMapping: StubMapping): Promise<StubMapping>` | ||
- `createMappingFromFile(fileName: string): Promise<StubMapping>` | ||
- `createMappingsFromDir(directoryName: string): Promise<any>` | ||
- `deleteAllMappings(): Promise<void>` | ||
- `resetAllMappings(): Promise<void>` | ||
- `getMapping(uuid: string): Promise<StubMapping>` | ||
- `updateMapping(uuid: string, stubMapping: StubMapping): Promise<StubMapping>` | ||
- `deleteMapping(uuid: string): Promise<void>` | ||
- `saveAllMappings(): Promise<void>` | ||
- `findByMetaData(contentPattern: ContentPattern): Promise<StubMappings>` | ||
- `removeByMetaData(contentPattern: ContentPattern): Promise<void>` | ||
**Example:** | ||
```js | ||
await wireMockRestClient.mappings.resetAllMappings(); | ||
const stubMapping = { | ||
@@ -49,4 +91,2 @@ "request": { | ||
console.log(response); | ||
// Create mapping from current working directory | ||
@@ -57,20 +97,55 @@ await wireMock.mappings.createMappingFromFile('stubs/hello-world.json'); | ||
await wireMock.mappings.createMappingsFromDir('stubs'); | ||
``` | ||
await wireMock.mappings.resetAllMappings(); | ||
### Recordings | ||
- `startRecording(recordSpec: RecordSpec): Promise<void>` | ||
- `stopRecording(): Promise<StubMappings>` | ||
- `getRecordingStatus(): Promise<any>` | ||
- `takeSnapshotRecording(snapshotSpec: RecordSpec): Promise<StubMappings>` | ||
const requests = await wireMock.requests.getAllRequests(); | ||
**Example:** | ||
```js | ||
const recordingStatus = wireMockRestClient.recordings.getRecordingStatus(); | ||
``` | ||
console.log(requests); | ||
### Requests | ||
- `getAllRequests(): Promise<any>` | ||
- `deleteAllRequests(): Promise<void>` | ||
- `getRequest(uuid: string): Promise<any>` | ||
- `deleteRequest(uuid: string): Promise<void>` | ||
- `resetAllRequests(): Promise<void>` | ||
- `getCount(requestPattern: RequestPattern): Promise<any>` | ||
- `removeRequests(requestPattern: RequestPattern): Promise<any>` | ||
- `removeRequestsByMetadata(contentPattern: ContentPattern): Promise<any>` | ||
- `findRequests(requestPattern: RequestPattern): Promise<any>` | ||
- `getUnmatchedRequests(): Promise<any>` | ||
- `getUnmatchedNearMisses(): Promise<LoggedRequest[]>` | ||
- `getNearMissesByRequest(loggedRequest: LoggedRequest): Promise<any>` | ||
- `getNearMissesByRequestPattern(requestPattern: RequestPattern): Promise<any>` | ||
await wireMock.global.shutdown(); | ||
**Example:** | ||
```js | ||
const requests = await wireMockRestClient.requests.getAllRequests(); | ||
``` | ||
### Scenarios | ||
- `getAllScenarios(): Promise<Scenario[]>` | ||
- `resetAllScenarios(): Promise<void>` | ||
**Example:** | ||
```js | ||
await wireMockRestClient.scenarios.resetAllScenarios(); | ||
``` | ||
## Logging | ||
- Logging is based on [log4js](https://www.npmjs.com/package/log4js) | ||
- Logging is based on `log4js` | ||
- Default log level is `info` | ||
- Each log line contains a unique id to trace logs for a single request | ||
- Log level `debug` will log the request body for each request. | ||
To configure a different log level, first install `log4js` in your project. Configuration can be set as follows. | ||
To enable logging, install [log4js](https://www.npmjs.com/package/log4js) in your project. | ||
```javascript | ||
A different log level can be configured as follows. | ||
```js | ||
import log4js from 'log4js'; | ||
@@ -83,4 +158,2 @@ | ||
Debug level will log the request body for each request. | ||
**Example:** | ||
@@ -87,0 +160,0 @@ ```shell |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51245
161