@stuntman/client
v0.3.6
Published
Stuntman - HTTP proxy / mock API client
Downloads
11,922
Maintainers
Readme
Stuntman API client
Client for Stuntman proxy/mock server API
Example usage
import { Client } from './apiClient';
import { ruleBuilder } from './ruleBuilder';
const client = new Client();
const uniqueQaUserEmail = '[email protected]';
const rule = ruleBuilder()
.limitedUse(2)
.onRequestToHostname('example.com')
.withSearchParam('user', uniqueQaUserEmail)
.mockResponse({
localFn: (req) => {
if (JSON.parse(req.body).email !== uniqueQaUserEmail) {
return {
status: 500,
};
}
return { status: 201 };
},
localVariables: { uniqueQaUserEmail },
});
client.addRule(rule).then((x) => console.log(x));
Check example app for more samples