unit-testingmockoon

Parameterized paths in Mockoon


I am new to Mockoon. I am creating a POC for using Mockoon as a replacement for some of our mocks in our test suite. Everything works well for both POST and GET requests. However, one issue I'm having: there is one endpoint that uses a parameterized path, something like this:

/access/<parameter>/endpointName

I need to set up Mockoon to be able to handle an endpoint that uses a parameter like this. Does anyone know how to do this, or, is it even possible? Thanks!!


Solution

  • Mockoon uses Express.js behind the scene. So, all of its syntaxes are supported.

    To add a parameter to your endpoint you need to use the colon symbol: /access/:param/endpointName. You will then be able to access the parameter inside the rules or in your body using templating helpers.