{% hint style="warning" %} This is an experimental feature. It is not yet supported by Maestro Cloud and breaking changes might be introduced as we work. on it. {% endhint %}
Here are key facts about Maestro Mock Server.
- Maestro Mock Server works on a concept of rules, that are defined in a workspace.
- A rule describes what HTTP(s) request to incercept and what to reply back.
- Rules are defined in JavaScript files. A single JS file can contain multiple rules.
- There must always be a root
index.js
file in the mock server workspace. From that file, other JS files can be imported defining other rules. - Maestro Mock Server requires integrating Maestro SDK in order to send all HTTP requests to the Mock Server instead of your original API
- Network requests that did not match any rule will continue to their real destination as if there was no mocking in place.
- In order for rules to be applied, they need to be deployed using
maestro mockserver deploy <path to your rules>
Here is the simplest example of a rule that will match a GET
call to your /endpoint
path and will reply with Hello Maestro
instead of the usual response:
// .maestro/mockserver/index.js
get('/endpoint', (req, res) => {
res.json({
message: "Hello Maestro"
});
});
Please follow the documentation to get up and running with Maestro Mock Server!
{% content-ref url="getting-started.md" %} getting-started.md {% endcontent-ref %}