Appearance
MockServer Verification
Verification:
verify(path, options?)verifyCount(path, expectedCount, options?)verifyNotCalled(path, options?)explainVerification(path, options?)
Journal:
listRequests()listUnmatchedRequests()clearHistory()pendingMocks()isDone()
Admin endpoints:
GET /_mockit/api/mocksGET /_mockit/api/requestsGET /_mockit/api/unmatchedGET /_mockit/api/pendingDELETE /_mockit/api/history
Remote Overrides For Automation Tests
If MockServer is running as a separate process, a Playwright or external test runner can create overrides over HTTP.
Raw HTTP:
ts
await fetch('http://127.0.0.1:3001/_mockit/api/overrides', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
path: '/api/login',
method: 'POST',
count: 1,
response: {
status: 403,
body: { message: 'unauthorized' },
},
}),
});Clear all overrides:
ts
await fetch('http://127.0.0.1:3001/_mockit/api/overrides', {
method: 'DELETE',
});List current overrides:
ts
const res = await fetch('http://127.0.0.1:3001/_mockit/api/overrides');
const overrides = await res.json();Remote DSL:
ts
import { RemoteMockServer, equals, startsWith } from '@toolstackhq/mockit';
const remote = new RemoteMockServer('http://127.0.0.1:3001');
await remote.expect('/api/login')
.method('POST')
.count(1)
.matchHeader('x-tenant', equals('bank-a'))
.matchBearerToken(startsWith('token-'))
.returns(403)
.withBody({ message: 'unauthorized' })
.apply();This is the right pattern when:
- devs start MockIt as part of the local UI stack
- automation tests need to change API behavior at runtime
- the test runner does not own the in-memory
MockServerinstance
Remote overrides support the same built-in matchers as local expectations and TypeScript defaults.