oasmock-sdk
v0.0.6
Published
TypeScript/JavaScript SDK for programmatic interaction with the oasmock server via HTTP API
Maintainers
Readme
OASMock TypeScript SDK
TypeScript/JavaScript SDK for programmatic interaction with the OASMock server via its HTTP API.
Installation
npm install oasmock-sdkBasic Usage
import { MockSDK } from 'oasmock-sdk'
const mockSDK = new MockSDK('http://localhost:19191')
// One‑time mocking of a response
await mockSDK.onRequest('/some/url', 'POST').respondWithOnce({
body: { some: 'data' }
})
// Mocking with additional conditions
await mockSDK.onRequest('/some/url')
.withCookies({ uid: '1' })
.withHeaders({ authorization: 'Bearer token' })
.withSearchParams({ test: 'value' })
.respondWith({
body: {}
})
// Retrieve request history
const lastRequest = await mockSDK.getLastRequest({
path: '/some/url',
method: 'POST'
})API Reference
See docs/api.md for the full MockSDK / MockSDKRequest reference, type definitions, and error handling.
Development
Building
npm run buildTesting
npm testLinting & Formatting
npm run lint
npm run formatType Checking
npm run typecheckReleasing
Publishing is tag-driven: the git tag is the single source of truth for the npm version.
- Create and push a
vX.Y.Ztag (e.g.v0.0.7):git tag v0.0.7 && git push origin v0.0.7 - The publish workflow derives the version from the tag, validates it as semver, and publishes
[email protected]to npm.
The version committed in package.json is not the publish authority — the tag always wins.
License
MIT
