avh4 / elm-program-test

Test Elm programs
https://elm-program-test.netlify.com/
MIT License
93 stars 27 forks source link

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

Open r-k-b opened 1 year ago

r-k-b commented 1 year ago

When:

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 commented 1 year ago

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.