given the following scenario:
Scenario: check if the array contains a string
* def condition =
"""
function(){
var myFile = "computer3.jpg"
var getAttachment = ["computer3.jpg"]
var isFound = karate.match(getAttachment + " contains " + myFile)
karate.log("is Found", isFound)
return isFound.pass
}
"""
* def r = call condition
I have the following error:
ReferenceError: "computer3" is not defined
How can I check if an array contains some values inside javascript using karate.match.
The following solution worked for me
Scenario: prova 2
* def condition =
"""
function(){
var myFile = "computer3.jpg"
var getAttachment = ["computer3.jpg"]
var temp = "['" + getAttachment+ "'] contains '" + myFile+"'"
var isFound = karate.match(temp)
karate.log("is Found:", isFound)
return isFound.pass
}
"""
* def r = call condition