Installation
Mocks Server is essentially a set of NPM packages.
Read the usage chapter in 5 minutes ⏱ to fully understand the Mocks Server main concepts: Routes, Variants and Collections.
Requirements
Node.js version 14.0 or above (which can be checked by running node -v
). You can use nvm for managing multiple Node versions on a single machine installed.
For using the interactive CLI may be there some additional requirements. The Inquirer library is used for displaying it. You can check its OS Terminals support here.
Mocks Server can be also started using Docker. Read the Docker integration guide for further info.
NPM installation
Add it to your project dependencies using NPM:
npm i -D @mocks-server/main
This will install the @mocks-server/main
package, which contains some preinstalled plugins. This docs usually make reference to this distribution until the contrary is indicated.
NPM script
Add the next script to the package.json
file:
{
"scripts": {
"mocks" : "mocks-server"
}
}
This enables to start the server by simply running a command in the project folder.
npm run mocks
If you are going to use the JavaScript API to start Mocks Server, this step is not required.