Using newman api, when we run a collection with option.collection as a collection object, then the disabled parameters in a get request are not ignored and are included in the call, whereas if we run with option.collection as require(filepath), then it works correctly.
I am modifying the Collection using collection sdk before running, hence cannot pass the file path as option to newman.
EXAMPLE:
Using the following collection:
{
"info": {
"name": "Temp",
"_postman_id": "734b99af-72b1-a510-dc4c-10214c91aeee",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "GET Request",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var responseJSON;",
"",
"try { ",
" responseJSON = JSON.parse(responseBody); ",
" tests['response is valid JSON'] = true;",
"}",
"catch (e) { ",
" responseJSON = {}; ",
" tests['response is valid JSON'] = false;",
"}",
"",
"tests['response json contains headers'] = _.has(responseJSON, 'headers');",
"tests['response json contains args'] = _.has(responseJSON, 'args');",
"tests['response json contains url'] = _.has(responseJSON, 'url');",
"",
"tests['args key contains argument passed as url parameter'] = ('test' in responseJSON.args);",
"tests['args passed via request url params has value \"123\"'] = (_.get(responseJSON, 'args.test') === \"123\");"
]
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "https://postman-echo.com/get?test=123&value1=test1",
"protocol": "https",
"host": [
"postman-echo",
"com"
],
"path": [
"get"
],
"query": [
{
"key": "test",
"value": "123",
"equals": true
},
{
"key": "value1",
"value": "test1",
"equals": true
},
{
"key": "value2",
"value": "test2",
"equals": true,
"disabled": true
},
{
"key": "value3",
"value": "test3",
"equals": true,
"disabled": true
}
]
},
"description": "The HTTP `GET` request method is meant to retrieve data from a server. The data\nis identified by a unique URI (Uniform Resource Identifier). \n\nA `GET` request can pass parameters to the server using \"Query String \nParameters\". For example, in the following request,\n\n> http://example.com/hi/there?hand=wave\n\nThe parameter \"hand\" has the value \"wave\".\n\nThis endpoint echoes the HTTP headers, request parameters and the complete\nURI requested."
},
"response": []
}
]
}
Running with following command:
newman.run({
collection: new Collection(JSON.parse(fs.readFileSync(filepath).toString())),
reporters: 'cli'
}, (err, summary) => {
console.log('DONE');
});
Invokes the GET request incorrectly with the disabled parameters:
GET https://postman-echo.com/get?test=123&value1=test1&value2=test2&value3=test3
Running newman with command:
newman.run({
collection: require(filepath),
reporters: 'cli'
}, (err, summary) => {
console.log('DONE');
});
Invokes the GET request correctly:
GET https://postman-echo.com/get?test=123&value1=test1