I am using require-js to model dependencies in a java script project. I also use jasmine to write test cases in BDD style and jasmine-maven-plugin: 1.1.0 to run these tests in headless mode.
This is my original project structure.
project/ | src/main/javascript | | api/*.js | | main.js | src/test/javascript | | spec/*spec.js
This is my webapp pom jasmine configuration:
<plugin> <groupId>com.github.searls</groupId> <artifactId>jasmine-maven-plugin</artifactId> <version>1.1.0</version> <executions> <execution> <goals> <goal>generateManualRunner</goal> <goal>resources</goal> <goal>testResources</goal> <goal>test</goal> <goal>preparePackage</goal> </goals> </execution> </executions> <configuration> <specRunnerTemplate>REQUIRE_JS</specRunnerTemplate> <scriptLoaderPath>lib/require-jquery.js</scriptLoaderPath> <sourceIncludes> <include>lib/require-jquery.js</include> <include>lib/underscore.js</include> <include>lib/backbone.js</include> <include>lib/d3.js</include> <include>lib/d3.layout.js</include> <include>lib/bootstrap.js</include> <include>main.js</include> </sourceIncludes> <preloadSources> <source>lib/require-jquery.js</source> <source>lib/underscore.js</source> <source>lib/backbone.js</source> <source>lib/d3.js</source> <source>lib/d3.layout.js</source> <source>lib/bootstrap.js</source> <source>main.js</source> </preloadSources> <browserVersion>FIREFOX_3_6</browserVersion> </configuration> </plugin>
During maven build, all js sources are copied to target / jasmine / src. Runner.html, which links to my main.js, is in target / jasmine.
Now the problem is that my require-js modules determine their dependencies relative to main.js, whereas in the maven test run, the runner assumes that they will relate to target / jasmine / runner.html. Since my modules are not (and should not be) aware of the additional jasmine / src folder, IMHO is the problem.
When you run mvn clean install, you receive the following error message:
Failed to fulfill the goal com.github.searls: jasmine-maven-plugin: 1.1.0: test (by default) on the mywebapp project: jasmine-maven plugin encountered an exception: java.lang.RuntimeException: org.openqa.selenium.WebDriverException : com.gargoylesoftware.htmlunit.ScriptException: wrapped com.gargoylesoftware.htmlunit.ScriptException: wrapped com.gargoylesoftware.htmlunit.ScriptException: wrapped com.gargoylesoftware.htmlunit.ScriptException: wrapped com.gargoylesoftware.html.lun. RuntimeException: java.io.FileNotFoundException: C: \ Jenkins \ JOBS \ job1 \ workspace \ mywebapp \ target \ jasmine \ api \ Data-util.js (The system cannot find the path specified)
Anyone who has the idea of โโgetting around or setting this up?
source share