Jacob Wang
Jacob Wang

Reputation: 4794

Scalajs tests not running when using Node.js instead of Rhino

I am currently working on a Scala.js library intended to be exposed as a JS library. To make my tests run faster I added the option as per scalajs's Basic Tutorial

scalaJSUseRhino in Global := false

However when I run the tests in sbt nothing seems to happen:

clean
project myprojectJS
test
last

Here are the relevant outputs from the last command

[debug] Loading JSEnv with linked file /home/jacob/proj/mastermind/js/target/scala-2.11/mastermind-test-fastopt.js
[debug] Subclass fingerprints: List()
[debug] Annotation fingerprints: List()

Nothing seems to be happening after JSEnv has been loaded.

Upvotes: 1

Views: 224

Answers (2)

Hartmut Pfarr
Hartmut Pfarr

Reputation: 6139

ScalaJS tests where not running in my environment, too, as long I was using ScalaTest and UnitTest for a sbt-crossproject.

[debug] Subclass fingerprints: List()
[debug] Annotation fingerprints: List()

both fingerprints where empty lists (running sbt -v -d for verbosity + debug informations)

I switched then to uTest (because of sbt-crossproject), added to my build.sbt settings:

testFrameworks += new TestFramework("utest.runner.Framework"),
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.6.3" % "test"

Now the test log shows...

...
[debug] Loading JSEnv with linked file qqqqq/.js/target/scala-2.11/qqqq-test-fastopt.js
[debug] Starting process: node
[debug] Subclass fingerprints: List((utest.TestSuite,true,org.scalajs.testcommon.Serializer$FingerprintSerializer$$anon$3@12662894))
[debug] Annotation fingerprints: List()
-------------------------------- Running Tests --------------------------------
[debug] Running TaskDef(TutorialTest, org.scalajs.testcommon.Serializer$FingerprintSerializer$$anon$3@60e5e39e, false, [SuiteSelector])
....

Upvotes: 0

Jacob Wang
Jacob Wang

Reputation: 4794

The problem was since I was writing a library that'll be exposed as a Javascript module, I had the following config in SBT:

scalaJSOutputWrapper := ("var __ScalaJSEnv = { exportsNamespace: exports };", ""),

Which means the test runner JS file produced will be wrapped too, making the output Javascript file essentially do nothing.

Adding this config in SBT fixes the issue:

scalaJSOutputWrapper in Test := ("", ""),

Upvotes: 2

Related Questions