Open bmccreath opened 4 years ago
Apparently, pre-request scripts are not executed for mock server requests. I wish! Does anyone know if this is a feature in the works?
@rheasunshine Do you know if Test scripts are run using Mock Server requests? I'm starting to think know, I can get them to trigger when hitting my server endpoint locally, but not when one of my Monitors hits it. Thanks!
@colbyjayallen I'm fairly sure test scripts / pre-request scripts are only run locally, or using a framework like Newman. e.g. if you were sending a request to a mock server from an external system to postman (e.g. from a mobile app, anything not in postman itself) than the scripts don't run.
@vvs11, @dushyantchillale - Hi. Will Collection variables be supported soon in Mock Server response body? Is it really intended that we should be using Environment variables in Mock Server response body?
@bmccreath @rproman Collections variables are now supported on mock servers. You can specify collection variables in your examples, and the mock server will resolve them while returning the response. Thanks for your patience 🙇.
... you were sending a request to a mock server from an external system to postman (e.g. from a mobile app, anything not in postman itself) than the scripts don't run.
The ability for pre-request scripts to run before the response is returned would be very handy, for example being able to set a variable to today's date in a specific date format (e.g. YYYYMMDD) would be useful
Following up here because I've seen this question asked multiple times in different places. What is the best practice for using a variable like the "today's date" example in the question above? Is this not possible with Postman?
Hi I need to set a collection variable through the pre-request scripts. Does anyone know any workaround for this to get it working with mock servers? thanks
Describe the bug Collection Variables are not returned in the mock server example response body, while environment variables are. There should be no difference in behaviour between these variables.
To Reproduce Steps to reproduce the behavior:
Expected behavior The response body should show the updated value of the collection variable. There should be no difference in behaviour between collection variables, environment variables and global variables in the response body.
Screenshots Pre Request Script Setting CollectionVariable, Environment Variable, and Global Variable
200 Success Example, showing that all 3 variable types are used
Console log, showing that all 3 variables have successfully updated
200 Success Response, showing that only the environment variable has been correctly parsed
App information (please complete the following information):
Additional context Working with Postman Mock Servers, trying to use collection variables as only mocking a single collection without different environments.