-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JSDOM to JSIO #529
Conversation
How would someone test that this works? |
It's slightly annoying to setup, but we have to find a way to run the test suite in the JSDOM JSEnv in addition to Node.js. scoverage/scalac-scoverage-plugin#456 is one example of how to do that. |
There we go. Enjoy your 1000+ lines of lockfiles :P |
Confirmed that JSDOM fails in CI without my changes in #530. |
Oh wow, thanks for that. Is the idea that you could now run your munit tests in a browser environment? But this is different in that munit itself could run within the jsdom environment? |
Yes that's right, it was already possible to use it as a test environment. But any file based features were not working (such as diffs and line numbers) because browsers don't have access to file system. Since JSDOM is a mere sandbox emulating the browser, we can break out to access the relevant APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool. Tested locally and everything works swell!
Just noting that this only runs the tests in the JSDOM environment in our CI, there isn't a new project within sbt that runs the tests.
You can manually run them in a sbt shell by changing your jsEnv
:
set testsJS / jsEnv := {new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv}`
And then run the js tests with:
testsJS / test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM it's great that we can support jsdom 👏
The JSDOM JSEnv runs in a sandbox within Node.js, so it has access to the same APIs via a sandbox-breaking technique. See: