eeue56 / elm-html-test

Test elm-html in Elm!
http://package.elm-lang.org/packages/eeue56/elm-html-test/latest
BSD 3-Clause "New" or "Revised" License
67 stars 15 forks source link

I ran into a `fail` decoder: No such type as thunk #4

Closed avh4 closed 7 years ago

avh4 commented 7 years ago
Unhandled exception while running the tests: Error: Ran into a `Debug.crash` in module `Html.Inert`

This was caused by the `case` expression between lines 18 and 23.
One of the branches ended with a crash and the following value got through:

    Err "I ran into a `fail` decoder at _.children[1].children[4].children[4].children[1]: No such type as thunk"

The message provided by the code author is:

    Error internally processing HTML for testing - please report this error message as a bug: I ran into a `fail` decoder at _.children[1].children[4].children[4].children[1]: No such type as thunk
    at eval (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:573:9)
    at _eeue56$elm_html_test$Html_Inert$fromHtml (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:81253:8)
    at _eeue56$elm_html_test$Test_Html_Query$fromHtml (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:82187:4)
    at _NoRedInk$noredink$Page_Teach_AssignmentForm_ViewSpec$findAnnouncements (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:82285:3)
    at eval (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:82306:7)
    at Function.eval [as func] (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:26780:12)
    at A2 (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:92:11)
    at Object.eval [as _0] (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:39546:18)
    at _elm_community$elm_test$Test_Runner$run (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:39507:13)
    at Object._0 (eval at <anonymous> (/ui/node_modules/elm-test/bin/elm-test:119:32), <anonymous>:96158:13)

Here's the toJsonString of the HTML being tested: https://gist.github.com/avh4/f4c68ca856386bc63683414279f69258

avh4 commented 7 years ago

Ah, apparently ElmHtml.InternalTypes.decodeElmHtml is not implemented for thunk yet

avh4 commented 7 years ago

Since elm-html-test currently strips out all functions with JSON.stringify, I think the simplest way to get this to work would be to call virtual-dom's render on the Html before stringifying, which would force all the thunks (the result of the thunks is stored in the vdom as node after it's been forced, so then that would appear in the resulting JSON.

avh4 commented 7 years ago

... unfortunately, it looks like Native.VirtualDom.render is not accessible from outside, even in other native code :(

avh4 commented 7 years ago

Okay, I've got a possible implementation for this--requires a change to both elm-html-test and elm-html-in-elm; I'll make the PRs shortly.

See https://github.com/eeue56/elm-html-test/issues/5 and https://github.com/eeue56/elm-html-in-elm/pull/2

rtfeldman commented 7 years ago

Should be fixed by https://github.com/eeue56/elm-html-test/pull/7