Skip to content
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

Support ModuleKind.ESModule #115

Closed
mushtaq opened this issue Sep 10, 2020 · 3 comments
Closed

Support ModuleKind.ESModule #115

mushtaq opened this issue Sep 10, 2020 · 3 comments

Comments

@mushtaq
Copy link
Contributor

mushtaq commented Sep 10, 2020

When I use scalajs-bundler which generates a single bundle with ModuleKind as CommonJSModule, I am successfully able to use SeleniumJSEnv with Chrome for running tests written with ScalaTest.

For a simpler workflows, I do not want to use scalajs-bunlder and would like to package the app as an ESModule. This works fine when I load it via index.html.

But, when I try to run ScalaTest with SeleniumJSEnv and Chrome, I get the following error. Is it possible to remove this restriction?

[debug] > Exec(example-client-js2/test, Some(1bd87d3d-7450-4236-a443-4a8b93ea8f4a), Some(CommandSource(console0)))
[debug] Evaluating tasks: example-client-js2 / Test / test
[debug] Running task... Cancel: Signal, check cycles: false, forcegc: true
[debug] Global IR cache stats: reused: 230 -- invalidated: 0 -- trees read: 0
[error] org.scalajs.jsenv.UnsupportedInputException: Unsupported input: List(ESModule(/Users/mushtaqahmed/projects/tmt/msocket/example/example-client-js2/target/scala-2.13/example-client-js2-test-fastopt.js))
[error] 	at org.scalajs.jsenv.selenium.SeleniumRun$.$anonfun$startInternal$1(SeleniumRun.scala:134)
[error] 	at scala.collection.immutable.List.map(List.scala:293)
[error] 	at org.scalajs.jsenv.selenium.SeleniumRun$.startInternal(SeleniumRun.scala:132)
[error] 	at org.scalajs.jsenv.selenium.SeleniumRun$.startWithCom(SeleniumRun.scala:122)
[error] 	at org.scalajs.jsenv.selenium.SeleniumJSEnv.startWithCom(SeleniumJSEnv.scala:28)
[error] 	at org.scalajs.testing.adapter.JSEnvRPC.<init>(JSEnvRPC.scala:25)
[error] 	at org.scalajs.testing.adapter.TestAdapter.startManagedRunner(TestAdapter.scala:129)
[error] 	at org.scalajs.testing.adapter.TestAdapter.$anonfun$getRunnerForThread$1(TestAdapter.scala:120)
[error] 	at scala.collection.concurrent.TrieMap.getOrElseUpdate(TrieMap.scala:897)
[error] 	at org.scalajs.testing.adapter.TestAdapter.getRunnerForThread(TestAdapter.scala:120)
[error] 	at org.scalajs.testing.adapter.TestAdapter.loadFrameworks(TestAdapter.scala:56)
[error] 	at org.scalajs.sbtplugin.ScalaJSPluginInternal$.$anonfun$scalaJSTestSettings$4(ScalaJSPluginInternal.scala:508)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:233)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:59)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:834)
[error] (example-client-js2 / Test / loadedTestFrameworks) org.scalajs.jsenv.UnsupportedInputException: Unsupported input: List(ESModule(/Users/mushtaqahmed/projects/tmt/msocket/example/example-client-js2/target/scala-2.13/example-client-js2-test-fastopt.js))
[error] Total time: 0 s, completed 10 Sep 2020, 17:15:43
[debug] > Exec(shell, None, None)
@sjrd
Copy link
Member

sjrd commented Sep 10, 2020

It's most likely possible, yes. PR welcome ;)

@mushtaq
Copy link
Contributor Author

mushtaq commented Sep 10, 2020

Sure :-)

@sjrd sjrd changed the title Support ModuleKind .ESModule Support ModuleKind.ESModule Sep 10, 2020
@gzm0
Copy link
Contributor

gzm0 commented Sep 17, 2020

FWIW, the required changes to the HTML template builder will be similar to scala-js/scala-js@0c414b5. The tougher part will be that loading ES modules through the file: scheme is not allowed, so you'll need to spin up an HTTP server.

mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 21, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 22, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 22, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 23, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 27, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 27, 2020
mushtaq added a commit to mushtaq/scala-js-env-selenium that referenced this issue Sep 27, 2020
@gzm0 gzm0 closed this as completed in f964525 Sep 27, 2020
gzm0 added a commit that referenced this issue Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants