4

I'm attempting to test our play 2.4.x application that makes heavy use of react for rendering tables and similar things. When just running the application normally, all the javascript gets processed and output properly. From our integration test phase however (using something that extends WithBrowser for selenium support in specs2 examples), the assets are clearly not available.

We get a lot of errors like the following (one for each javascript file we attempt to load):

[error] - com.gargoylesoftware.htmlunit.html.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/lib/react/react-with-addons.js]

Is there anything that can be added to tell play to process our javascript pipeline before the test/integration phases?

Joan
  • 4,079
  • 2
  • 28
  • 37
Mad Dog
  • 583
  • 4
  • 18
  • I know it's an obvious point, but are you sure the URLs that htmlunit is reporting are definitely correct? – Andrew Regan Feb 02 '16 at 14:50
  • They are generated off the asset controllers that are used when running the live app (save for hostname:port which is decided at server start). – Mad Dog Feb 02 '16 at 17:31

1 Answers1

2

Are you using the IntegrationTest Configuration in SBT?

I was having the same problem and finally solved it by adding:

(managedClasspath in IntegrationTest) += (packageBin in Assets).value

to my build.sbt

This might not be the same for you, but I'm using Gulp to generate my css and js files and place them in an 'out' directory. So in order to get them picked up by the build I also had to add:

unmanagedResourceDirectories in Assets <+= baseDirectory { _ / "out" }
Chris
  • 1,006
  • 10
  • 13
  • Up until I saw your solution, I had been doing unmanagedResourceDirectories in IntegrationTest <+= baseDirectory(_ / "target/web/public/test") This required running the unit tests first, but it otherwise worked. Yours does not work for me - I am using the following stack of sbt web plugins addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7") addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0") addSbtPlugin("org.madoushi.sbt" % "sbt-sass" % "0.9.3") addSbtPlugin("io.teamscala.sbt" % "sbt-babeljs" % "1.0.3") – Mad Dog Mar 21 '16 at 01:53
  • It seems we are going about it two different ways. I am using Gulp to generate my css and js files (from sass and jsx) and place them in the "out" directory instead of sbt-web. These assets were getting picked up when running in the site and with the unit Tests but not when running IntegrationTests. The managedClasspath setting fixed that. – Chris Mar 21 '16 at 10:00