Suites
mockyeah
provides the ability to capture request/responses and play them back later as mock services.
While recording, mockyeah
proxies all received requests to configured hosts and captures their responses.
Suites include: response body, method, headers, status code, latency, and path.
See record
, recordStop
, and play
.
See also our section on the CLI for another way to record and play.
Ad Hoc Suites
Suites can be created manually. This can ease the repetitive setup of multiple services. Here are the steps to creating ad hoc suites:
Create a suite directory (e.g.
./mockyeah/suite-example
)Add one or more files containing, at minimum, the following:
module.exports = [
[
'/some/service',
{
text: 'Hello world!'
}
]
];
- Play your ad hoc suites.
require('@mockyeah/server').play('suite-example');
Or play all:
require('@mockyeah/server').playAll();
That's it!
Dynamic Suites
Without mounting suites explicitly via play
or playAll
, you can dynamically opt-in to them
using our custom HTTP header x-mockyeah-suite
, or custom cookie mockyeahSuite
,
with a value equal to the name of a suite in suitesDir
from configuration.