Stoobly Docs
  • Introduction
  • Use Cases
    • Generate Mock APIs
      • Empower Development
      • Scale API Testing
    • Enable E2E Testing
  • FAQ
    • Recording
    • Mocking
    • Terminology
  • Getting Started
    • Installing the Agent
      • Installation with pipx
      • Installation with Docker
  • Core Concepts
    • Agent
      • Intercept Modes
        • Mocking
        • Recording
      • Lifecycle Hooks
      • Proxy Settings
        • Data Rules
        • Firewall Rules
        • Rewrite Rules
        • Match Rules
    • Context
    • Mock API
      • Request
        • Response
        • Replay History
      • Scenarios
      • Snapshots
      • Fixtures
      • Public Folder
    • Scaffold
      • Service
      • Validation
      • Workflow
  • Guides
    • How to Run the Agent
      • Run with CLI
      • Run with Docker
    • How to Configure the Agent
      • Forward Proxy
        • Enable HTTPS Traffic
      • Reverse Proxy
    • How to Record Requests
      • Recording from the UI
      • Recording from the CLI
      • How to Create Contexts
      • How to Create Scenarios
        • Creating from the UI
        • Creating from the CLI
      • How to Create Requests
      • How to Customize Recordings
        • Customizing with Lifecycle Hooks
    • How to Update Requests
      • Editing from the UI
      • Editing with Snapshots
      • How to Update Scenarios
        • Updating from the UI
        • Updating from the CLI
      • Updating with Replay
        • Replaying from the UI
        • Replaying from the CLI
        • How to Customize Replays
          • Customizing with Lifecycle Hooks
      • Updating with Open API
    • How to Mock APIs
      • How to Enable Mocking
        • Enabling from the UI
        • Enabling from the CLI
      • How to Snapshot Requests
        • Deleting Snapshots
        • Sharing Snapshots
      • How to Use Fixtures
      • How to Customize Mocking
        • Customizing with Lifecycle Hooks
        • Customizing with Request Headers
      • Troubleshooting
    • How to Replay Requests
      • Replay with the UI
      • Replay with the CLI
    • How to Integrate E2E Testing
      • How to Scaffold an App
        • Scaffolding a Service
        • Customizing a Workflow
          • Customizing Container Services
          • Customizing Lifecycle Hooks
          • Customizing Init Scripts
          • Customizing Configure Scripts
          • Customizing Makefile
        • Troubleshooting
      • How to Run a Workflow
        • Running with CLI command
        • Running with Make
        • Troubleshooting
          • Validating
      • How to Stop a Workflow
        • Stopping with CLI command
        • Stopping with Make
      • How to Update a Scaffold
        • Deleting a Service
      • FAQ
  • Developer Guide
    • Installation from Source
    • Submitting Change Requests
    • Releases
  • Experimental
    • Experimental Features
      • Aliases
      • Endpoints
      • API Testing
        • Getting Started
        • Configuration
          • Assign
          • Lifecycle Hooks
          • Trace
      • Optional Components
Powered by GitBook
On this page
  • Recreating Application State
  • Create a todo item
  • Describe a todo item
  • Delete a todo item
  • Reduce Environment Instability

Was this helpful?

  1. Use Cases
  2. Generate Mock APIs

Empower Development

In order to empower development, we want to:

  • Easily re-create application state

  • Reduce environment instability

Recreating Application State

Working on a feature or fixing a bug often depends on triggering a sequence of requests to drive your application to a certain state. For example, when working on a new API to create a resource, we find ourselves:

  1. Sending a POST request to create the resource

  2. Sending a GET request to confirm the resource was created

  3. Sending a DELETE request to reset the system state

With Stoobly, we can record these requests into a scenario. With scenarios, we can:

  1. Replay them to retrigger the same sequence of requests

  2. Share them with teammates so they replicate the same results

For example given the following imaginary endpoints:

Create a todo item

POST http://localhost:3000/todos

Request Body

Name
Type
Description

description

String

title*

String

{
    description: '',
    id: 1,
    title: '',
}

Describe a todo item

GET http://localhost:3000/todos/:todoID

{
    description: '',
    id: 1,
    title: '',
}

Delete a todo item

DELETE http://localhost:3000/todos/:todoID

We can first create a scenario:

stoobly-agent scenario create create-todo-v1

And then record requests into it:

stoobly-agent record \
    -X POST \
    -d "description=demo&title=test" \
    --scenario-key <SCENARIO-KEY> \
    http://localhost:3000/todos

stoobly-agent record \
    --scenario-key <SCENARIO-KEY> \
    http://localhost:3000/todos/<TODO-ID>

Once we have recorded requests into a scenario, we can replay with:

stoobly-agent scenario replay <SCENARIO-KEY>

Reduce Environment Instability

Depending on a live API service maintained by another can lead to bugs, intermittent failures or latency spikes outside of your control. For example, let's say we want to create a UI form that uses the above API's to create, view, and delete a todo item. Because these features depend on the API, if the service goes down, the UI is unable to progress with work. To reduce downtime, we can use Stoobly to:

  1. Record requests to a scenario

  2. Toggle Stoobly to mock requests using the recorded scenario

  3. Incoming requests that were previously recorded will now return mocked responses

In addition to reducing downtime, using a mock service instead of a shared service for development also imparts folowing benefits:

  1. Decreased request latency

  2. Consistent responses

A shared API service means other clients are modifying the application's state. The more requests sent to the service, the higher the latency. Furthermore, frequently changing application state can lead to inconsistent responses.

PreviousGenerate Mock APIsNextScale API Testing

Last updated 4 months ago

Was this helpful?