akka-js / akka.js

Akka, for Scala.js
http://akka-js.org
474 stars 39 forks source link

Examples of testkit usage #66

Closed kelebra closed 7 years ago

kelebra commented 7 years ago

Hey guys, first of all, thanks a lot for awesome project 👍

However I tried to play around with akka's TestKit from akkajstestkit and I always end up with stacktrace like:

java.lang.ExceptionInInitializerError
...
Caused by: java.lang.RuntimeException: stub

or

[error] Could not run test com.github.kelebra.akka.js.snake.DrawingSpecification: scala.scalajs.js.JavaScriptException: TypeError: Cannot read property 'scheduler$3' of null

I tried to look up correct usage of akkajstestkit in your samples however with no success, any suggestions?

andreaTP commented 7 years ago

Hi @kelebra and thanks a lot for pointing out. What are you saying seems related to https://github.com/akka-js/akka.js#caveats startup time section. There is an "hidden method" that will simplify your workflow: https://github.com/akka-js/akka.js/blob/master/akka-js-testkit/js/src/test/scala/akka/testkit/TestActorRefSpec.scala#L150

you can try first to put an await in between your ActorSystem spawning and the the execution of the streams/ actor logic.

Yes, this should be documented properly.

Please let me know if this solves.

kelebra commented 7 years ago

Actually the issue was in my desire to reflectively create Props (classOf[Actor]) and running all tests from Intellij Idea. When I followed instructions on akka.actor.JSDynamicAccess.injectClass tests started to pass via sbt but still failing with the same error in Idea. Not sure what it is but I can surely can survive with sbt only :)

Anyway, thanks a lot for the fish and the net in your tests.

kelebra commented 7 years ago

On absolutely another note: would you guys be interested in PR into samples repository with more examples like 'snake' game or 'bomber man'?

andreaTP commented 7 years ago

great news! Thanks for reporting! Sorry I do not use IntelliJ, but maybe just a complete clean of caches and re-import could help, AFAIK.

on the other end: YES :-) :+1: :-) of course! Examples and site need a bit of love, if you would like to contribute I will be really happy to merge :-)

b.t.w. can we close this and take conversation to gitter/mail/whatever? Thanks! :-)

kelebra commented 7 years ago

Sure, closing this issue and will prepare PR with sample project :+1: