-
Notifications
You must be signed in to change notification settings - Fork 383
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
Make testHtml independent of jsEnv #4191
Comments
The error you are seeing is basically Node.js interpreting your file as a script (probably because it does not have the extension artifactPath in (<project>, Compile, fastOptJS) := (crossTarget in project).value / "<output-name>.mjs"'
Further, you'll have to configure Node.js correctly to find I realize this is very manual. However, managing JS bundling, libraries and such is explicitly out of scope for the core repo. So unless you want to manage your JS libraries manually, avoiding scalajs-bundler/webpack might not be the best idea. |
Thanks for clarifying this. I was under the impression that testHtml will generate an HTML file that can be opened in any browser independent of the I think, for my use case where I want to use Chrome exclusively, it is best that I give a shot at tacking scala-js/scala-js-env-selenium#115. Hope it is not too difficult. |
@gzm0 So, is this as-designed/won't fix? |
Well... this might be a good time to re-discuss options with regards to this. The reason we are still triggering the This is not very nice, but I'm not sure how we can improve this without giving more reflection power to Scala.js. We'd need to support (in addition to what is currently supported):
|
Querying all subclasses on an instantiatable class (or all instantiatable classes for that matter) is something we could expose easily as a library-level new method in Querying by annotations is an entirely different story. That information is currently entirely dropped by the compiler back-end. I don't see a path towards including that information in the sjsir files, let alone at run-time. I'm not sure it's possible to move test detection to the JS side. |
Yeah... That was my feeling as well :( Unfortunately, that's the mechanism JUnit uses, so any partial support would be hard to test for us as well :-/ If it's OK with you, I'd like to keep this open for a bit and think a bit more. |
Sure. |
So, it turns out that I didn't really give the entire story: Even JUnit, at the end of the day, only cares about all subclasses of a given type ( What is unclear to me at this point, is if we can change the interface in a backwards compatible manner to deal with this. |
Technically, the bootstrapper contains everything we would want, including the ability to iterate over all the tests, for discovery. The problem is that a generic processor would have to work with an
(¹) There's one catch here, though: if we had a One possible way would be to invent a new standard interface for all bootstrappers. It could have the following form: @EnableReflectiveInstantiation
trait AnnotatedFingerprintTestBootstrapper {
def handlesAnnotationName(annotationName: String): Boolean
def associatedTestClassName(): String
} The test runner could reflectively iterate through all of those, and call We could retroactively make trait Bootstrapper extends AnnotatedFingerprintTestBoostrapper {
def handlesAnnotationName(annotationName: String): Boolean =
annotationName == "org.junit.Test"
def associatedTestClassName(): String =
getClass().getName().stripSuffix("$scalajs$junit$bootstrapper")
} (the second method relies on In theory, the retroactive extension only works on 2.12+ because it requires the new methods to be default methods. But test classes are almost never used from binaries only; they are used from compiled sources. |
Hmmm... So that would require all test frameworks to provide this. I'm not sure that is feasible; especially for test frameworks that currently don't need a compiler plugin. (Although their test class itself could extend |
No, only testing frameworks that rely on an All other testing frameworks use a |
Fair enough. I think we should probably indeed do this. |
The more I think about this, I'm not sure we can implement (¹) without either of:
|
Yes, I think you're right. Although So I believe we need compiler support. |
:( that in turn changes the binary backwards compat story quite a bit. It's quite bothering that Scala.js itself with the |
Yes, the big downside is that it would require recompilation of the superclass/supertrait (so in practice, of the testing framework) for this feature to work. The question is: is that deal breaker? It would mean that
Hum, I'm not following. :s What example? |
The
If step 1 does not happen for an artifact, everybody is blocked from step 2. |
No, that would not be the equivalent. We don't need to recompile test classes. We only need to recompile the superclass/supertrait of all tests, which is defined in the testing framework. So the equivalent here would be to recompile the JUnit testing framework, and then use the new JUnit framework with the existing binaries of the tests in the test kit, and things would work. The blocking step is for the testing framework itself to republish a version. |
Yes, right. It's an example of how we need backwards compatibility for the bootstrapper in JUnit specifically.
I'll think about it, but I don't think so (short of making hardcoded lists). Mainly because we cannot access any information about the testing framework without launching some JS code. |
Note to self: Is it time to build
|
We can't really do that, I'm afraid. First, in terms of binary compatibility, that would break every testing framework that has been published. We would have a hard time to tell them that they need to upgrade to the new version and republish if they want newer users of Scala.js to be able to use their framework; while at the same time that it would break users of older Scala.js. (testing framework authors can be very conservative about what they support) In terms of source compatibility, one design constraint of |
Just to be clear: This is not about Scala.js' |
Oh, you're aiming far! Wow. That will require to get even more people on board, notably the maintainers of all the Scala build tools in circulation. I guess the right way to start a discussion like that would be to open a thread on https://contributors.scala-lang.org/ |
An alternative to all this, could be to introduce a resource file provided by testing frameworks (with a name derived from the name of the Framework class name) that contains the fingerprints. The TestAdapter could look for these files and if they exist, bypass execution of the jsEnv. If the file does not exist, it would fall back to executing the jsEnv in order to retain backwards compatibility. What remains unclear, is how we'd get these files into the testing framework artifacts (as in: ensure most frameworks have them). |
Perhaps we should have a larger discussion with likely stakeholders, such as build tool maintainers and testing framework maintainers. It seems we're not going to achieve anything on our own, or at least without their buy-in. |
I am trying to use
ESModule
support in Scala.js to avoid having to use webpack/scalajs-bunlder. Here is minimal example that works using snowpack with Scala.js.npm start
andnpm run build
work as expected and loads the fastOptJS as ESModule which in turn importsrxjs
. But runningsbt testHtml
gives an error:The alternate way to test could have been via
scala-js-env-selenium
, but that does not support ESModules, yet: scala-js/scala-js-env-selenium#115The text was updated successfully, but these errors were encountered: