@stuntman/client
TypeScript icon, indicating that this package has built-in type declarations

0.3.6 • Public • Published

Stuntman API client

npm Build Status Coverage Status License

Client for Stuntman proxy/mock server API

Example usage

import { Client } from './apiClient';
import { ruleBuilder } from './ruleBuilder';

const client = new Client();

const uniqueQaUserEmail = 'unique_qa_email@example.com';
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

Package Sidebar

Install

npm i @stuntman/client

Weekly Downloads

2,326

Version

0.3.6

License

MIT

Unpacked Size

111 kB

Total Files

23

Last publish

Collaborators

  • swiniak