Core Concepts AI-generated

MockMotor organizes everything into three levels: Environments contain Services, and Services contain Reactions. A Reaction is the actual unit of "when a request looks like this, respond with that." One Environment groups Services by URL prefix (e.g. /accounts, /payments), and each Service holds an ordered list of Reactions (e.g. GET /accounts/{id}, POST /accounts) tried top to bottom until one matches.

Environment

An Environment is a self-contained mock instance: its own set of ports, its own accounts and variables, its own log. Two environments never share data. An environment's Traffic Type is either HTTP (REST/SOAP/GraphQL/WebSocket, the default) or LDAP (see LDAP Mode) - never both at once. See Environments for the full settings reference. A single MockMotor instance (the running server process) can also be scaled out as one admin plus any number of clones sharing the load - see Clustering & Clones.

Service

A Service is a URL prefix (e.g. /accounts) that a request's path is matched against using longest-prefix matching - the same mechanism MockMotor uses for HTTP paths and (reinterpreted) for LDAP BaseDNs. See Services.

Reaction

A Reaction is the actual mocked response: a set of match conditions (method, path pattern, headers, query string, script), an account selector, a payload, and everything else that goes out on the wire. Reactions within a service are tried in order; the first one whose match conditions all pass wins. See Reactions for the full editor reference.

Request lifecycle, in short

  1. A request arrives on one of the environment's ports.
  2. MockMotor resolves the Service whose URL prefix (or LDAP BaseDN) longest-matches the request.
  3. Within that service, MockMotor finds the first Reaction whose match conditions are satisfied.
  4. If the reaction references mock accounts, they're selected (by an equality-driven script, indexed for speed).
  5. The response payload, headers, status, and any forwarding/delay are computed and sent back.
  6. The whole exchange - matched or not - is written to the environment's log.