5

I am trying to configure jasmine-maven-plugin.

My project structure is as below:

Root
 | --Sub peoject-1 (Common)
 |    |--src
 |    |   |--main
 |    |   |   |--java
 |    |   |   |--resources
 |    |   |   |--webapp
 |    |   |     |--js
 |    |   |     |--<Jquery library> 
 |    |   |--test
 |    |       |--jasmine
 |    |         |--css
 |    |         |--js
 |    |             |--<Jasmine library>
 |    |             |--jasmineSpecRunner.js
 |    |--pom.xml
 |--Sub peoject-2 (JAR project)
 |    |--src
 |    |   |--main
 |    |   |   |--java
 |    |   |   |--resources
 |    |   |--test
 |    |       |--jasmine
 |    |       |--css
 |    |--pom.xml
 |--Sub peoject-3
 |    |--src
 |    |  |--main
 |    |  |    |--java
 |    |  |    |--resources
 |    |  |    |--webapp
 |    |  |         |--js
 |    |  |--test
 |    |      |--jasmine
 |    |           |--html
 |    |           |   |--moduleSpecificSpecRunner.html
 |    |           |--js
 |    |               |--moduleSpecificJasmineSpecification.js
 |    |--pom.xml
 |--pom.xml

I have kept all common JavaScript files inside the Common web project (i.e. jQuery library files, Jasmine library files etc.) along with the jasmineSpecRunner javascript (Jasmine engine).

Inside the module specific specRunner javascript (moduleSpecificJasmineSpecification.js), I have included all common javascript files, module specific javascript source file and jasmineSpecRunner javascript (Jasmine engine).

I wrote some jasmine test cases inside the test/jasmine folder and I am trying to configure jasmine-maven-plugin. Inside module specific pom file I have included the following tag:

<plugin>
    <groupId>com.github.searls</groupId>
    <artifactId>jasmine-maven-plugin</artifactId>
    <version>1.3.1.1</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <jsSrcDir>${project.basedir}/src/main/webapp/js</jsSrcDir>
        <jsTestSrcDir>${project.basedir}/src/test/jasmine/js</jsTestSrcDir>
    </configuration>
</plugin>

And inside the root pom file under tag I have added following entry:

<plugin>
    <groupId>com.github.searls</groupId>
    <artifactId>jasmine-maven-plugin</artifactId>
    <version>1.3.1.1</version>
    <extensions>true</extensions>
</plugin>

But after executing mvn jasmine:bdd command I am not able to view the jasmine test output in at the http://localhost:8234 url.

I think the configuration is not correct.

Can anyone help me to configure the jasmine-maven-plugin for the above mentioned project structure? Thanks!

John Hascall
  • 9,176
  • 6
  • 48
  • 72
bolar
  • 183
  • 3
  • 8
  • Did you figure out how to set up Maven / jasmine ? I am trying to do the same and have stuck a wall. Thanks Jay – jayaram S Jan 07 '14 at 15:40
  • In your browser, try exploring the localhost:8234/src path. This shows you the files served by phantomjs. Probably the files from your dependency (common) are not served. I am also looking for a solution... – kpentchev Aug 17 '15 at 14:30

1 Answers1

0

I configured it in this way and its working for me

 <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <skipJasmineTests>${js-tests.skip}</skipJasmineTests>
                <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
                <!--<webDriverCapabilities>
                  <capability>
                    <name>phantomjs.binary.path</name>
                    <value>${project.basedir}/target/phantomjs-maven-plugin/phantomjs-2.1.1-linux-x86_64/bin/phantomjs</value>
                  </capability>
                </webDriverCapabilities>-->
                <jsSrcDir>${project.basedir}/src/main/webapp</jsSrcDir>
                <jsTestSrcDir>${project.basedir}/src/main/webapp/tests/spec</jsTestSrcDir>
                <preloadSources>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/jquery-latest.min.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular.min.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular-mocks.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular-resource.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/jasmine-jquery.js</source>
                    <source>${project.basedir}/src/main/webapp/app/app.js</source>
                </preloadSources>
                <sourceIncludes>
                  <include>${project.basedir}/src/main/webapp/*.js</include>
                </sourceIncludes>
            </configuration>
        </plugin>
athi
  • 1
  • 2