There is some issue with how the karma is being started via test-app. I found both cmd line grails test-app and invoking via IntelliJ grails cmd window (Alt+G) yield different results. The common problem of both errors seems to be the port number that karma starts on.

Solutions

1. Change the port number in karma.conf.js to 8001 or try another number (above 1024 and available).
2. Remove line of the port number specified in JavaScriptUnitTestKarmaSuite.java: @KarmaTestSuiteRunner.KarmaRemoteServerPort(8001)

Results

With the above settings (ie karma.conf.js:port = 8001 and no port specified in the java code), the test-app works fine in both IntelliJ and command line.

During your test runs, sometimes the port binding is not released when test is shutdown. On *nix systems, you can just use kill <process-id>. For Windows, use PowerShell and do the following:

netstat -o -n -a | findstr "<portnumber>"
stop-process -Id <pid>

In Part 3, we saw how to add karma to grails test-app lifecycle.
In Part 4, lets see how to get karma tests running on your build server.

@Simone, i have seen the “No such property” in some scenarios. Can you try the following:

1. does the error happen if you run test-app within an ide? (IDEA or Eclipse)?
2. can you delete your target/* and do a refresh-dependencies and then test-app?
3. you can also try updating to latest asset-pipeline which is at 1.8.1
4. in one of my earlier versions, a similar problem existed while using clover plugin – i commented out the clover plugin in buildconfig to avoid this error
5. after excluding resources and including asset-pipeline in buildconfig, did you do a refresh-dependencies ?

I have set up every thing accordingly and refreshed dependencies multiple times.
But getting the following error. can you please

Starting karma result receiver server on localhost:8001
| Failure: angrails.JavaScriptUnitTestKarmaSuite
| java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Server
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at de.is24.util.karmatestrunner.JSTestExecutionServer.beforeTests(JSTestExecutionServer.java:26)
at de.is24.util.karmatestrunner.junit.KarmaTestSuiteRunner$3.evaluate(KarmaTestSuiteRunner.java:186)
at de.is24.util.karmatestrunner.junit.KarmaTestSuiteRunner$2.evaluate(KarmaTestSuiteRunner.java:168)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at de.is24.grails.tools.KarmaTestType.doRun(KarmaTestType.groovy:52)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.Server
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
… 22 more
| Completed 0 javascript test, 1 failed in 0m 0s