thunder-client-support
thunder-client-support copied to clipboard
Tests filter parameter value truncated.
Describe the bug The following statement in Test, on the left side will cause the parameter value to be truncated.
The script is as follow,
function validateObject(probe, reference) {
console.log(probe);
console.log(reference);
}
The value for probe is correct. However, the value for reference is truncated from,
"hello there", said Peter
to
"hello there
The cause of the issue is due to the double quotes, followed by a comma. There can be spaces between the double quote and the comma and the truncation will occur.
The following example will also cause truncation,
"\"hello there\" , said Peter" will produce "hello there
Inserting any characters in between the double quote and the comma will result in no truncation. For example,
"\"hello there\" . , said Peter" will produce "hello there" . , said Peter
To Reproduce
- Create a new request.
- In the Tests, add the string
json.data | validateObject("\"hello there\", said Peter") - Create a custom filter.
function validateObject(probe, reference) { console.log(probe); console.log(reference); } - Run the request and see the output.
Expected behavior
The parameter reference should contain the full string "hello there", said Peter.
In my actual project, the actual data is a variable which contain a json string in an Environment,
{
"name": "test",
"value": "{\"name\":\"My name\",\"description\":\"A short description\",\"data\":{\"type\":\"DataType\"}}"
}
and I'm trying to perform custom object validation as such in Tests,
json.data | validateObject({{test}})
In the filter, I would parse it into a json object and perform some validation. The issue is, the value is truncated causing the actual input to be lost.
Platform:
- OS: Windows 10
- vscode version: 1.78.1
- extension version: 2.6.2
Your Team Size Using TC: 2
Thanks @programatix for reporting the bug, Currently additional quotes are not allowed
Closing this issue, Please use scripting for this use-case.