rtfeldman / node-test-runner

Runs elm-test suites from Node.js. Get it with npm install -g elm-test
BSD 3-Clause "New" or "Revised" License
134 stars 79 forks source link

Junit reporter breaks with new error messages of elm-program-test #615

Closed stoeffel closed 1 year ago

stoeffel commented 2 years ago

The new test output of elm-program-test breaks the junit output of elm-test.

Error

└─ elm-test  --report junit
/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLStringifier.js:210
            throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
            ^

Error: Invalid character in string: ▼ Query.fromHtml

    <input id="id"></input>

▼ ProgramTest.fillIn ""

Expected one of the following to exist and have an "oninput" handler:
- <input> with aria-label and id
    ✓ has tag "input"
    ✓ has attribute "id" "id"
    ✗ has attribute "aria-label" ""
- <textarea> with aria-label and id
    ✗ has tag "textarea" at index undefined
    at XMLStringifier.assertLegalChar (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLStringifier.js:210:19)
    at XMLStringifier.text (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLStringifier.js:53:21)
    at new XMLText (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLText.js:22:37)
    at XMLElement.text (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:308:17)
    at XMLElement.node (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:294:17)
    at XMLElement.element (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:187:30)
    at XMLElement.element (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:163:32)
    at XMLElement.element (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:158:27)
    at XMLElement.element (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:148:34)
    at XMLDocument.element (/nix/store/yyi707rsplzcqw9917swgkk70ckl69jy-elm-test-0.19.1-revision7/lib/node_modules/elm-test/node_modules/xmlbuilder/lib/XMLNode.js:158:27)

Reproduce

module Example exposing (..)

import Html
import Html.Attributes exposing (id)
import ProgramTest exposing (ProgramTest)
import Test exposing (..)
import Test.Html.Selector exposing (text)

start : ProgramTest () msg (Cmd msg)
start =
    ProgramTest.createElement
        { init = \_ -> ( (), Cmd.none )
        , view = \_ -> Html.input [ id "id" ] []
        , update = \_ _ -> ( (), Cmd.none )
        }
        |> ProgramTest.start ()

tests : Test
tests =
    test "Hello World"
        (\() ->
            start
                |> ProgramTest.fillIn "id" "" "Hello World"
                |> ProgramTest.expectViewHas [ text "Hello World" ]
        )

Run: elm-test --report junit

Potential Fix

We could include a invalidCharReplacement option as per https://github.com/oozcitak/xmlbuilder-js/issues/147#issuecomment-604375441

harrysarson commented 2 years ago

PR welcome! We also desperately need a test for this

lydell commented 1 year ago

Released in 0.19.1-revision12.