I'm trying to add javascript unit testing to our project and found out about the Jasmine Maven Plugin. I followed the directions and ended up with this in my pom.xml:
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.2.0.0</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<jsSrcDir>${project.basedir}/src/main/webapp/resources/js</jsSrcDir>
<jsTestSrcDir>${project.basedir}/src/test/javascript</jsTestSrcDir>
</configuration>
</plugin>
I run mvn jasmine:bdd
and get the expected output. I then go to http://localhost:8234
and all I get is a blank screen. I look in the console and see this for each of my js files:
Not allowed to load local resource: file:///absolute/path/to/the/js/src/main/webapp/resources/js/myJS.js
The HTML for the page is including my scripts like this:
<script type="text/javascript" src="file:/absolute/path/to/the/js/src/main/webapp/resources/js/myJS.js"></script>
So my question is, why is the plugin using the file protocol to inculde the js? Is this how it usually works? If so, how do I get my browser to allow the local resource? Is there any way to prevent it from doing this?
Just in case it matters, I tried this with both Firefox and Chrome, and I am using OS X.
I ran into this issue recently and the problem was that my project was in a directory that had spaces in it.
This was on windows but it might be the same on OSX so it's worth a try.
So for instance my project was in a directory like this:
C:\directory with spaces\myproject
Changing it to the following fixed the
jasmine:bdd
command:C:\directorywithoutspaces\myproject
Good luck!