How to use utility functions with response injections

49 views
Skip to first unread message

yogesh dandekar

unread,
Jun 28, 2024, 5:29:54 AM6/28/24
to mountebank-discuss
Sample stub:
{
    "predicates": [{
      "and": [
        {
          "equals": {
            "path": "/test1"
            ,"method": "GET"
          }
        }
      ]
    }]
    ,"responses": [
        { "inject": "<%- stringify(filename, 'code/injectTestResponse.js') %>" }
    ]
}

Just like /test1 and its corresponding response injection JS file, there can be a few.

Even if I have a 'require' statement within 'code/injectTestResponse.js' - it errors out
when that API call is made:
error: [http:4545 xxx] injection X=> SyntaxError: Unexpected token 'const'

Really looking for a way to have code-reuse within my script injections !

YD

Reply all
Reply to author
Forward
0 new messages