0
votes

I've scala and scalajs project and it is in github for reference.

Initially I've scalatest version 3.0.3 and scalacheck version 1.13.5. The command sbt clean test is working fine.

I've updated scalatest version to 3.1.4 and scalacheck version 1.14.3.

After this updated scala project tests are working fine but scalajs tests are not.

The error I'm getting is

[info] Fast optimizing /Users/rajkumar.natarajan/Documents/Coding/misc/sjs-test-error/core/js/target/scala-2.12/reftree-test-fastopt.js

[error] Referring to non-existent method org.scalatestplus.scalacheck.ScalaCheckConfiguration.$$init$()scala.Unit

[error] called from generic.RefTreeSpec.()

[error] called from generic.RefTreeSpec.()

[error] called from core module analyzer

[error] Referring to non-existent method org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks.$$init$()scala.Unit

[error] called from generic.RefTreeSpec.()

[error] called from generic.RefTreeSpec.()

[error] called from core module analyzer

[error] There were linking errors

[error] (coreJS / Test / fastOptJS) There were linking errors

[error] Total time: 31 s, completed Jun 9, 2021, 5:54:57 PM

The changes are in this commit.

I tried to figure out but I'm novice in scalajs. Is there anything extra I need to do to work correctly?

1

1 Answers

2
votes

In your diff, at https://github.com/rajcspsg/sjs-test-error/commit/bb3f00cc542b29998af271530dccae9b73f2ad00#diff-5634c415cd8c8504fdb973a3ed092300b43c4b8fc1e184f7249eb29a55511f91R33, you have a dependency on

"org.scalatestplus" %% "scalacheck-1-14" % "3.1.3.0" % Test

which uses %%. This is a dependency on a JVM artifact, which brings the JVM version of its own dependencies. You end up with two versions of ScalaTest on your classpath: one for the JVM and one for JS. With bad luck, the one for the JVM gets selected, and therefore shadows the one for JS. This results in the linking errors that you get.

You can fix this by using %%% instead of %% in that dependency, assuming that that library is available for Scala.js. If it isn't, you'll have to find a way not to need that dependency at all.