Skip to main content
Version: 4.0.0

Plugins

Preface

Plugins enable you to tap into, modify, or extend the Mocks Server internal behavior. In fact, some of the features described in these docs are provided by plugins preinstalled in the Mocks Server main distribution.

Having access to the whole core API, a plugin is able to do almost anything on Mocks Server, for example:

  • Adding routes and collections programmatically
  • Adding new Variant Handlers
  • Adding custom Express routers to the server.
  • Reading files from the /mocks folder, taking advantage of all supported types and hot reloading.
  • Creating new integration tools, interfaces, etc.

Installing plugins

Plugins can be installed using the configuration file or programmatically.

tip

Read the plugins installation chapter for further info.

Creating plugins

A plugin basically consist on a JavaScript Class containing some standardized methods. The Mocks Server core is at charge of creating the plugin instance using the provided Class and calling to each method on each specific time of the Mocks Server lifecycle. The constructor and the other methods will always receive an instance of the Mocks Server core, so it can be used to tap into, modify, or extend its internal behavior.

tip

Read the plugins development chapter for further info.