scala-js / scala-js-env-jsdom-nodejs

Node.js with jsdom environment for Scala.js
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Support for JS modules #56

Open xko opened 1 year ago

xko commented 1 year ago

After completing the initial vite tutorial, I started looking for the way to UT the actual DOM generated. JsDom was recomended by older tutorial, so I gave it a try. It failed with:

org.scalajs.jsenv.UnsupportedInputException: Unsupported input: List(ESModule(C:\Users\xko\dev\sueppchen\target\scala-3.2.2\sueppchen-test-fastopt\main.js))

IMO it's likely to confuse many new users. Since the modular config is now the default, would be nice to have it supported here. If not, what's currently the best approach to the DOM testing?

sjrd commented 1 year ago

jsdom itself does not support ECMAScript modules: https://github.com/jsdom/jsdom/issues/2475 Until it does, there is nothing we can do here.

You may want to try https://github.com/scala-js/scala-js-env-selenium instead.

xerial commented 1 year ago

@sjrd I've tried Selenium to run Scala.js tests using DOM, but I encountered another issue reported in https://github.com/scala-js/scala-js-env-selenium/issues/128 It seems ESModule can't be used with Selenium probably because module files are accessed using relative paths.

xerial commented 1 year ago

ok. I've found a workaround to use Scala.js + jsdom + Selenium Chrome Driver. Leaving an example project here, which works with Vite, ScalablyTyped, Selenium, jsdom: https://github.com/xerial/scalajs-selenium