-
Notifications
You must be signed in to change notification settings - Fork 90
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
Remove Node.js requirement with Scala.js #376
Conversation
Previously, it was not possible to use MUnit with browser-based JavaScript environments because MUnit imported the Node.js `fs` module. This commit refactors the code so that MUnit should gracefully recover when the Node.js `fs` module is not available.
@@ -100,8 +100,7 @@ val sharedJVMSettings: List[Def.Setting[_]] = List( | |||
) ++ mimaEnable | |||
val sharedJSSettings: List[Def.Setting[_]] = List( | |||
skipIdeaSettings, | |||
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")), | |||
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)) | |||
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")) |
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.
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")) | |
crossScalaVersions := allScalaVersions |
just as a complete side note, I don't think we need this anymore
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.
👍 I had a draft comment saying the same thing
Thanks, checked it out locally. It does not throw as before, but now MUnit does not print any information about the assertion failures except the name of the test in which they appeared. Munit on a JVM project prints this kind of useful error on failure:
Whereas MUnit in this PR prints only the following on a similar test in a JS project:
Also, the console is now printing a warning (not an error) before the tests:
You mentioned in previous comments that you need the |
// if (JSIO.isNode) JSPath.parse(JSPath.resolve()).root | ||
// else "/" |
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.
leftover?
@@ -100,8 +100,7 @@ val sharedJVMSettings: List[Def.Setting[_]] = List( | |||
) ++ mimaEnable | |||
val sharedJSSettings: List[Def.Setting[_]] = List( | |||
skipIdeaSettings, | |||
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")), | |||
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)) | |||
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0.")) |
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.
👍 I had a draft comment saying the same thing
@raquo thank you for trying it out! What Scala.js linker settings are you using to reproduce that? It might require a small tweak to get the exception message |
@olafurpg Here is all of the linker config and a few more relevant bits: scalaVersion := "2.13.5" // Scala.js version is 1.5.0
(Test / scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) })
(Test / requireJsDomEnv) := true
(installJsdom / version) := "16.4.0"
useYarn := true
(Test / parallelExecution) := false No other One weirdness on my side that I can think of is that my project where I'm trying to use this is a testing library, so it requires the MUnit dependency without appending For the record, the branch that I'm trying to build is here. The simple test that I made to fail is |
@olafurpg I can confirm this PR works over at http4s/http4s#4938. Thanks for making this change, I'm badly in need of this. Is there anything I can do to get this merged and (snapshot) released ASAP? I'm happy to polish up this PR as @gabro and @tgodzik see fit. |
No longer necessary as of scalameta#376
No longer necessary as of #376
Previously, it was not possible to use MUnit with browser-based
JavaScript environments because MUnit imported the Node.js
fs
module.This commit refactors the code so that MUnit should gracefully recover
when the Node.js
fs
module is not available.Fixes #247