mehpi
Simple External API Mocking via Sinon
Motivation
So why another testing utility library for mocking HTTP servers? Because:
- We love sinon
- We wanted to love functional tests, but nock was unideal
- We thought, "Hey wouldn't it be cool if we could mock APIs with sinon?"
Example
const MockAPI = const request = const sinon =
API Reference
new MockAPI(port)
Creates a new MockAPI
instance that runs locally on the given port.
.start(done)
Starts the server, then calls the done
callback.
.stop([done])
Stops the server. If defined, calls the done
callback.
.stub(method, path)
Creates and returns a sinon stub for the given HTTP method and path.
.restore([route])
Restores all route stubs on the mocked server.
License
MIT