Client side Server mocks

A simple and robust tool to mock unfinished server requests

Boris Dinkevich
2 min readNov 4, 2016

It probably happened to you

Your awesome Angular or React Native project is halfway done, but the server team just can’t get the APIs to work.

So you start using online services with weird syntax, building local node mini-servers or just pasting JSONs all over your code.

No more!

Over the past year we have been using (and building) — “BaD ass Server Mocks” aka BDSM

A simple frontend only tool that allows you to easily mock unimplemented server APIs

Simple to setup

1. Install BDSM `npm install bdsm — save-dev` and `import ‘bdsm’;`
2. Open your app and access a “broken” API endpoint
3. Click the BDSM icon and select the “broken” request
4. Tell BDSM how to mock it
5. Re-run the request
6. Win!

Simple BDSM usecase

Why do we love it?

* No need to rely on 3rd party servers and configurations.
* No need to write / maintain local mocking servers
* No need to add “temp” and “debug” code into your project
* Super easy to mock / un-mock APIs
* We actually use it on all our projects — and can’t stop

There is more

Since we loved BDSM so much, we kept adding features:

  • Grouping scenarios — Mock a group of server responses to return different values for testing, you can. E.g. return a full / empty / half-empty shopping cart. Create and switch between multiple scenarios with a single click.
  • Full API — Want to dynamically mock stuff.
  • *Coming soon* — complete filesystem synchronization. Save mocks in your Git repo and have the whole team be able to share the same mocks for each version/branch/tag of your code.

Give it a try

Source: https://github.com/500tech/bdsm

Docs: https://500tech.github.io/bdsm/

Test thimble: https://thimbleprojects.org/murkin/108925/

--

--