play-scalajs.g8 icon indicating copy to clipboard operation
play-scalajs.g8 copied to clipboard

Add Integration Tests to the project.

Open naderghanbari opened this issue 9 years ago • 3 comments

That would be great if this sample project had a few integration tests. That way it will be easier for people adopting Scalajs + Play + SBT combo.

There are some caveats (I believe because the way sbt-web works: https://github.com/sbt/sbt-web/issues/54). But it would be nice to mention the best workaround here.

naderghanbari avatar Sep 20 '15 10:09 naderghanbari

So far I found one by using something like this in the server sbt descriptor:

  unmanagedResourceDirectories in IntegrationTest <+= baseDirectory(_ / "target/web/public/test"),
  resourceGenerators in IntegrationTest <+= PlayScalaJS.copyMappings(scalaJSDev, WebKeys.public in TestAssets).map(_ => Seq[File]())

Please share your thoughts and let me know if there are better workarounds. If not, is a PR with this workaround welcome?

naderghanbari avatar Sep 20 '15 10:09 naderghanbari

There is an integration test in this project.

I don't have any real experience running integration tests in Play.

How do you run your integration tests in Play? Are you using it:test? Do you add the tests in a different folder than test?

vmunier avatar Sep 23 '15 14:09 vmunier

Yes, what I have now is putting tests in a separate folder, namely it and then adding Defaults.itSettings to the build file:

# build.sbt
Defaults.itSettings
scalaSource in IntegrationTest <<= baseDirectory(_ / "it")
parallelExecution in IntegrationTest := false,

In that sense there is almost no difference from what you have here. But the problem is the launcher file and other js files (fastOpt or jsDeps) are not available (I believe if you test the actual functionality in integration tests they will fail). So I guess despite the fact that Integration Tests has no great support by SBT, adding a working configuration to this project makes it easier for developers to adopt Scalajs (at least for my case, integration test was the only blocker in the way of migrating to Scalajs)

By the way I found the following as a workaround but maybe there are cleaner and more straightforward ways to achieve this:

resourceGenerators in IntegrationTest <+= PlayScalaJS.copyMappings(scalaJSDev, WebKeys.public in TestAssets).map(_ => Seq[File]())
unmanagedResourceDirectories in IntegrationTest <+= baseDirectory(_ / "target/web/public/test"),

naderghanbari avatar Sep 23 '15 15:09 naderghanbari