cultureamp / react-elm-components

Write React components in Elm
https://www.npmjs.com/package/react-elm-components
BSD 3-Clause "New" or "Revised" License
779 stars 54 forks source link

How can I get my Elm to render in mocha #12

Open EnriqueVidal opened 7 years ago

EnriqueVidal commented 7 years ago

I know I can test Elm files with elm-test, but I'm also trying to run a small end to end test for my react file with the Elm component, the problem however is that the <Elm /> component in react-elm-components always renders an empty <div /> in mocha.

Any ideas on how to do an end to end test of a react component that's also rendering an Elm file?

Thanks in advance.

ethagnawl commented 5 years ago

@EnriqueVidal Did you ever figure out a solution? I suspect it has something to do with the use of shouldComponentUpdate in index.js, but I don't know enough about React to be sure.

EnriqueVidal commented 5 years ago

@ethagnawl I didn't and had to move on, so nowadays I separate my Elm and react into separate projects. I hadn't closed this in hopes that someone may have found a work around I will try again as soon as I can and either close this issue and post said workaround or update my findings.

ethagnawl commented 5 years ago

@EnriqueVidal It seems like this isn't possible. As far as I can tell, the only way to achieve any sort of pre-rendering of an Elm application is to actually spin up a (headless) browser, wait for the page to load and the app to initialize (wait until an element/id present in your Elm app makes an appearance?), scrape the page and then dump the page's contents to a file.

EnriqueVidal commented 5 years ago

Sorry for the long wait since it's a work week I haven been able to look into this yet, however my test suite runs on either HeadlessChrome or JSDOM I'd be happy if it were possible in any, will definitely try it. Thanks for the info.