paulbutcher / ScalaMock

Native Scala mocking framework
http://scalamock.org/
MIT License
503 stars 99 forks source link

ScalaTest with ScalaMock could not run any test for ScalaJS project #205

Closed exoego closed 5 years ago

exoego commented 6 years ago

ScalaMock Version (e.g. 3.5.0)

3.6.0

Scala Version (e.g. 2.12)

2.12.4

Runtime (JVM or JS)

JS

Please describe the expected behavior of the issue

ScalaTest with ScalaMock should run tests for ScalaJS project.

Please provide a description of what actually happens

ScalaTest could not run any test for ScalaJS project. It is aborted by org.scalajs.testcommon.RPCCore$RPCException, which is caused by scala.scalajs.js.JavaScriptException: TypeError: Cannot read property 'FooTest' of undefined.

Configuration was below.

Reproducible Test Case

Since it requires a configuration, I made a small project that reproduces the issue. https://github.com/exoego/scalamock-fail-with-scalajs

Procedure

  1. Clone https://github.com/exoego/scalamock-fail-with-scalajs
  2. Run sbt
  3. Run test command

Note: It is reproducible both in Windows and Linux, at least on my PC.

barkhorn commented 6 years ago

Can you give me some more detail here? I had a quick look at your example project, but ScalaMock is not used in the code, nor does it show up in the stacktrace. What makes you think this is a bug in ScalaMock? I'm not sure, based on this.

exoego commented 6 years ago

I guess this might be a bug in ScalaMock, because this error happens if ScalaMock is added as dependency. If I remove ScalaMock from dependency, ScalaTest works.

barkhorn commented 6 years ago

Ok I understand the problem now. Still not sure what could even cause this. Could it be something related to a combination of versions? E.g. does it work with sbt 0.13.15 and scala-js 0.6.18?

exoego commented 6 years ago

I have tried the following combinations quickly. However, I could not find a problrem-free combination...

sbt \ scala-js  0.6.21 0.6.20 0.6.19 0.6.18
1.0.3 x x x N/A
1.0.2 x x x N/A
0.13.16 x x x x (scala 2.12.3)
0.13.15 N/A N/A x x (scala 2.12.3)

"x" means same error happens. Unless noted, scala 2.12.4 is used.

In the release notes of sbt v1.0.3, I found the following bugfix.

Fixes test detection regression. sbt 1.0.3 filters out nested objects/classes from the list, restoring compatibility with 0.13. #3669 by @cunei

So, I tried the recently-released sbt 1.0.3, while I am not sure the fixed bug is related to my issue. However, 1.0.3 does not fix my issue...

Is it better to close this issue and escalate to https://github.com/sbt/sbt ?

barkhorn commented 6 years ago

sorry, was out of the country for a few days. I see the sbt team has already started looking at this, great

exoego commented 5 years ago

Closing this since this issue is quite stale, and the issue is not reproducible after I switched to Linux with OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode). Thanks!

barkhorn commented 5 years ago

Cool. Sorry that this was sitting around for a while. Recently there was activity in https://github.com/scala-js/scala-js/issues/3174 that seems to indicate the root cause is memory pressure. Maybe switching to a 64 bit VM has allocated more heap for you and mitigated the problem.