Closed dFayet closed 4 years ago
Could you paste the test from the .feature
-file as well that triggers your custom matcher? That way I can add it as an actual test to the testsuite to verify the behaviour.
Btw, if you just want to test that a value in your JSON is a string value, you can use an already built in matcher:
Then the response body contains JSON:
"""
{
"string value": "@variableType(string)"
}
"""
That matcher also supports other variable types: https://behat-api-extension.readthedocs.io/en/latest/guide/verify-server-response.html#variable-type-variabletype
Here is an example
Scenario: Example of the use case
Given I am authenticated as "user@demo.com"
And the "Content-Type" request header is "application/json"
When I request "/my-awesome-endpoint" using HTTP GET
Then the response code is 200
And the response body contains JSON:
"""
{
"message": "@myMatcher()"
}
"""
I know the variableType
matcher but it allows empty ("") string. (This part is missing from my example)
Check out https://github.com/imbo/behat-api-extension/pull/87 for some more information on this.
Hello,
First of all, thank you for this nice extension.
I have only worked with it recently, so this might be a question from a beginner.
After reading https://behat-api-extension.readthedocs.io/en/latest/guide/extending-the-extension.html#register-custom-matcher-functions
I've created a new matcher:
But when I run a test with an invalid value I receive the message
The object in needle was not found in the object elements in the haystack.
Due to https://github.com/imbo/behat-api-extension/blob/develop/src/ArrayContainsComparator.php#L252-L258This is not that bad as the test fails. But I was expecting to see the Matcher's exception.
Is it the awaited bahavior? Did I miss something?
If no, and this is a bug/new feature, I would be more than happy to do a PR :-)