You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if there were a way to match part of the body of a response. Sometimes responses contain random bits that you don't care about testing.
The text was updated successfully, but these errors were encountered:
You can write your own custom matchers to do whatever you like using ResponseMatcher. For instance:
partialMatcher :: String -> ResponseMatcher
partialMatcher expected = ResponseMatcher {
matchStatus=200
, matchHeaders=[]
, matchBody=MatchBody (\_ actual -> do
if encode expected `isInfixOf` actual
then Nothing
else Just "expected string wasn't a partial match of actual!"
)
}
You can then use this in your tests like so:
let expected = "expected partial response"
request methodPost someTestPath [] body `shouldRespondWith` partialMatcher expected
It would be nice if there were a way to match part of the body of a response. Sometimes responses contain random bits that you don't care about testing.
The text was updated successfully, but these errors were encountered: