[`yesod-test`] bring back support for matching of preescaped strings
eahlberg opened this issue · 4 comments
When I upgraded yesod-test
to version 1.6.15 I noticed some tests started to fail, e.g.:
htmlAnyContain "meta[name=description]" "content=\"This is the site description\""
Fails with:
None of meta[name=description] contain content="This is the site description matches: ["<meta content=\"This is the site description\" name=\"description\" />"]
AFAIU this is because htmlAnyContain
was changed to support matching e.g. quotes ('
) by escaping input by default.
I guess it's not possible to support both of these cases with the same API? To work around this locally I have the old version of htmlAnyContain
around which does not escape input. If that's sounds like a sensible solution, I could open a PR which brings back that version under a new name (e.g. htmlAnyContainPreEscaped
) to avoid other people (and my future self) running into this issue.
I think it's a very valid use case to check if some raw HTML is contained verbatim. So I would appreciate an additional API like htmlAnyContainedPreEscaped
. Maybe put the keywords "verbatim" or "raw" in the documentation to make it easier to find it...
A pull request with that function sounds sensible. Let's do it.
In case it's useful, until that function exists, this stopgap should work:
htmlQuery "meta[name=description]" >>= \(bs:_) ->
liftIO $ bs `shouldSatisfy` ("This is the site description" `isInfixOf`)