-
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
Avoid relying on Node's fs when running in browser-based JSEnv #247
Comments
@olafurpg Are you planning to solve this? If I understanding correctly, there is no workaround for testing projects that need JS DOM, right? Seems that the usefulness of Scala.js support is pretty limited if that's the case... I was hoping to switch from ScalaTest to MUnit, but I have a lot of frontend tests that need |
No objections from me if somebody wants to implement the proposed fix. The fs module is optional, it’s only used to enrich error messages. We can merge the fix even with no tests to unblock this usecase. |
What are the steps to reproduce this error? I tried to reproduce in the MUnit repo with the diff here but the tests run without errors https://github.com/scalameta/munit/compare/main...olafurpg:js-node-fs?expand=1 |
nvm, I was able to reproduce by removing the linker config settings. |
I'm working on cross-building http4s/http4s#4938 to Scala.js and ran into this issue too when trying to run the test suite on Firefox instead of Node.js. Very very glad to see a fix in the works. |
Problem
MUnit relies on Node.js'
fs
module to read the source location when an assertion fails.This is only possible if SJS if told to emit
CommonJSModule
orESModule
:Issue is that one cannot use such modules in browser-based JSEnv, filesystem doesn't exist there. And tests fail with an exception:
Proposed solution
@sjrd and @olafurpg propose a fallback solution, akin to
to avoid having
fs
a hard dependency for MUnit.Reference material
The text was updated successfully, but these errors were encountered: