Jasmine maven plugin and jasmine-jquery different results

1.1k Views Asked by At

My project is standard maven java project. I'm trying to include jasmine-maven plugin to my CI. But when I run command mvn clean install, it runs the tests correctly. However, if I run mvn jasmine:bdd and run the test from the browser. My html fixtures are not loaded.

This is my project structure.


project
  |
  |-src
    |-main
    |-test
       |-java
          |-javascript
               |-jasmine
                    |-spec
                       |-spec.js
                       |-javascripts
                       |   |-fixtures
                       |       |-all_the_fixtures.html
                       |-lib
                          |-jasmine-jquery-1.3.1.js 


And this is 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>
                        <skipTests>false</skipTests>
                        <jsSrcDir>${basedir}/src/main/webapp/static/js</jsSrcDir>
                        <jsTestSrcDir>${basedir}/src/test/java/javascript/jasmine/spec</jsTestSrcDir>
                        <sourceIncludes>
                            <include>jquery/jquery-min.js</include>
                            <include>src/source.js</include>
                            <include>src/source1.js</include>
                        </sourceIncludes>
                        <specIncludes>
                            <include>lib/*.js</include>
                            <include>**/*.js</include>
                        </specIncludes>
                    </configuration>
                </plugin>

When I run the tests from the browser. All the html fixtures are 404. Is there a way to have both ways worked?

And this is how I load the fixture


it("should get content group with one breadcrumb", function() {
    loadFixtures("all_the_fixtures.html");
});

And this is my jasmine-jquery path configuration


  this.fixturesPath = 'spec/javascripts/fixtures/';

1

There are 1 best solutions below

0
On

I realize this is an old question, just want to document my findings here. I am working through getting some of this same stuff up and running myself. What I found was the the path is relative to the project's base when running the bdd goal, not the jasmine folder you created. This structure would probably work in the OP's environment.

project
|
|-spec
|  |-javascripts
|     |-fixtrues
|        |-all_the_fixtures.html
|-src
   |-main
   |-test
      |-java
      |-javascript
         |-jasmine
         |-spec
            |-spec.js
            |-javascripts
               |-lib
                  |-jasmine-jquery-1.3.1.js

This is a known issue as far as I can tell.

Here's a post about how to work around it using profiles. Basically you create one profile for each goal of the Jasmine plugin. Hope this helps someone...