Reputation: 507
In the response assertion, I have in patterns to test this value.
"isDefault":false,"companyId":"${__javaScript(${Company}.toLowerCase())}","folderPath":null
I do not want to change the value of the variable ${Company}, I just want to check if what I receive is in lower case.
This is the assertion result:
Assertion error: false Assertion failure: true Assertion failure message: Test failed: text expected to contain /"isDefault":false,"companyId":"","folderPath":null/
Upvotes: 0
Views: 726
Reputation: 168092
You need to surround your ${Company}
variable reference with quotation marks like:
"isDefault":false,"companyId":"${__javaScript("${Company}".toLowerCase(),)}","folderPath":null
Be aware that using __javaScript() function is not very recommended as JavaScript interpreter performance can be a big question mark when it comes to high loads so consider following alternative approaches:
Use __groovy() function which is recommended approach to scripting since JMeter 3.1
"isDefault":false,"companyId":"${__groovy(vars.get("Company").toLowerCase(),)}","folderPath":null
Use __lowerCase() function (this is not a part of official JMeter distribution, you will need to install it using JMeter Plugins Manager)
isDefault":false,"companyId":"${__lowercase(${Company},)}","folderPath":null
Demo for all approaches:
Upvotes: 1