I have set a Mock expectation to return some 400 error with a custom property in the body and a custom header
In the mock script i am reading that custom header and if its set to sepcific property value I am removing the custom property in response body.
It worked on 1-2 times but after that nothing from the script seems working. With or without conditions
Moreover anything i do console.log in the Mock Script shows nowhere to have some debugging
Thank you for your feedback. I’ll try to reproduce this issue locally.
From the screenshots, it seems you’ve set both mock rules and mock scripts. There’s a priority here - if a mock rule matches, the mock script won’t execute. You can set it directly in the mock script.
From my earlier question on separate chat Discord
Is this supported to have both of them execute on a per rule basis?
Also as u are saying due to priority only one of them will execute but it did work for me couple of times(Both rule and script executed and I got expected response) but it suddenly stopped working after few tries
Yes, this is documented in our help doc(Mock scripts - Apidog Docs). Could you please describe your use case in more detail so we can explore better solutions?
Ok. So my requirement is like I have multiple mock rules created which generate the first level response for specific scenarios as defined by the rules. But as a general rule I need to update few fields in response from the request url and request body which are possible only in mock scripts. Hence the need to use both mock scripts and mock expectations
Otherwise I will have to write out all my mock expectations on the mock scripts using it else
Mock Scripts without expectation support does not seem a practical solution for us
It would be really helpful and useful to have a toggle to execute scripts after each Mock Expectation response also. This will ensure people who want to use it as glocal script also can use it
Thank you for your feedback. Your suggestion is very helpful, and I’ll share it with our product team.