elm-program-test icon indicating copy to clipboard operation
elm-program-test copied to clipboard

Attributes containing `"` lead to a failure to show error details

Open r-k-b opened this issue 2 years ago • 1 comments

When:

  • the view html contains attributes like Html.Attributes.attribute "contains-double-quote" "\""
  • and a selector does not match, then

elm-program-test shows an error like:

    PLEASE REPORT THIS AT <https://github.com/avh4/elm-program-test/issues>: renderHtml: couldn't parse failure report: Unexpected Char at row 4, col 10
    
    ▼ ProgramTest.clickButton "that does not exist"
    
    Expected one of the following to exist:
    - <button> with text
        ✓ has tag "button"
        ✗ has containing [ text "that does not exist" ]
    - <button> with <img> with alt text
...etc etc...

Here's a commit demonstrating that in the test cases: https://github.com/avh4/elm-program-test/commit/b67267b92110420b918acdfd20742ba7d5cdbf74

r-k-b avatar Jun 28 '23 04:06 r-k-b

I think the cause is here: https://github.com/elm-explorations/test/blob/2.1.1/src/Test/Html/Internal/ElmHtml/ToString.elm#L125

Should be something like |> List.map (\( k, v ) -> k ++ "=\"" ++ String.replace "\"" "&quot;" v ++ "\"") instead.

Not sure how to verify that tho, it's unclear how to use a local fork of elm-explorations/test.

r-k-b avatar Jul 01 '23 00:07 r-k-b