For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integrating the JavaScript Client

An introduction to the Stoobly JavaScript client library for E2E testing

The Stoobly JavaScript library (npm package stoobly) lets you record, mock, and test HTTP requests directly from end-to-end testing frameworks like Playwright and Cypress. Use it alongside a stoobly-agent scaffold workflow to control interception from your tests.

What is the Stoobly JavaScript client library?

The stoobly npm package (the Stoobly JavaScript client library) integrates with the stoobly-agent to enable:

  • Recording — Capture HTTP requests and responses for later replay

  • Mocking — Return pre-recorded responses instead of hitting real APIs

  • Replay — Replay recorded requests

  • Testing — Validate API responses against recorded data

Prerequisite

Before using the JavaScript client library, set up Stoobly for E2E testing:

  1. Install the agentstoobly-agent must be available on your machine or in CI

  2. Integrate E2E testing — create a scaffold app and services with --plugin playwright or --plugin cypress

The JavaScript client library builds on that scaffold setup. It does not replace creating the app, services, or workflows.

Installation

npm install stoobly --save-dev

Requires Node.js 18 or higher. See Setup for import patterns and framework-specific install steps.

Integrate with your test framework

After installing the package, wire Stoobly into your E2E tests:

  • PlaywrightplaywrightInterceptor(), withPage(), withContext(), and recording

  • CypresscypressInterceptor(), enable(), and recording

See Setup for import patterns and framework-specific install steps.

Running the Agent from npm scripts

With your scaffold in place, start the workflow that matches your test mode (mock, record, or test) before running tests. Rather than starting and stopping it by hand in a separate terminal, wrap it in package.json scripts so it fits your existing npm test flow:

See npm scripts for the full set of recommended scripts, including record/test variants, diagnostics, and CI setup.

Configure interception

Configuration covers URL patterns, scenarios, sessions, recording options, and how to start and stop interception from test code.

Reference

Last updated