WireMock Client
A node client for interfacing with WireMock's admin API
WARNING: THIS LIBRARY CURRENTLY EXPERIMENTAL AND IN A PRE-ALPHA STATE
Node Example
const {Builders, Matchers, connect} = require('wiremock-client')
const mock = connect('localhost', 8080)
mock.register(Builders.post(Matchers.urlPathMatching('/api/example'))
.withRequestBody(Matchers.containsPattern('token=auth'))
.willReturn(Builders.aResponse()
.withStatus(200)
.withHeader('Content-Type', Matchers.equalTo('application/json'))
.withBody({test: true})
)
)
Browser Example
<script src="wiremock-client.js"></script>
const Builders = WireMock.Builders
const Matchers = WireMock.Matchers
const mock = WireMock.connect('localhost', 8080)
mock.register(Builders.post(Matchers.urlPathMatching('/api/example'))
.withRequestBody(Matchers.containsPattern('token=auth'))
.willReturn(Builders.aResponse()
.withStatus(200)
.withHeader('Content-Type', Matchers.equalTo('application/json'))
.withBody({test: true})
)
)
Features
Matchers
Url Matchers
These matchers are used for matching request urls
Url Matching
urlMatching (url)
urlPattern (pattern)
urlPathMatching (path)
urlPathPattern (pattern)
Global Matchers
containsPattern(pattern) equalTo(value)
Mappings
Stub mappings
Get all stub mapping
wireMock.getStubMapping(uuid)
Create new stub mapping
wireMock.register(mappingBuilder|mapping)
Delete all mapping
wireMock.removeMappings()
Delete all mapping
wireMock.removeMappings()
Reset stub mappings
Get a single stub mapping
Delete a stub mapping
Save all persistent stub mappings to the backing store
Find stubs by matching on their metadata
Remove stubs by matching on their metadata