The Mocks Server main distribution includes the inquirer-cli plugin preinstalled. It provides an interactive command line interface that enables to control the server using the keyboard while it is running.
Using the arrow keys and the
Return key you can choose menu options in order to perform some actions, like changing the current collection, setting a delay time for the server responses, etc.
This CLI is a great tool for controlling the mock server while you are developing an API client, because you can change the server responses in real time using it without modifying any code. Suppose that you are developing a web application that is polling to the API, and you want to check if it is refreshing the data properly. The only thing that you have to do is to use the CLI to change the current responses collection, and the next time the application requests a data, the response will be different.
The interactive CLI can be disabled using configuration, and then the server logs will be displayed instead. This should be done when using the server for running tests, for example.
As Mocks Server includes hot reloading, the alert will automatically disappear when the error is fixed.
plugins.inquirerCli.enabled(Boolean): Start the interactive CLI or not. Default is
plugins.inquirerCli.emojis(Boolean): Defines whether the inquirer CLI uses emojis or not. Default is
How to disable it
The interactive CLI can be disabled using configuration. The server logs will be displayed instead. This is useful when running tests on CI, for example.
npm run mocks -- --no-plugins.inquirerCli.enabled