【问题标题】:Jasmine maven plugin and jasmine-jquery different resultsJasmine maven 插件和 jasmine-jquery 不同的结果
【发布时间】:2012-09-01 13:15:43
【问题描述】:

我的项目是标准的 maven java 项目。我正在尝试将 jasmine-maven 插件包含到我的 CI 中。但是当我运行命令mvn clean install 时,它会正确运行测试。但是,如果我运行 mvn jasmine:bdd 并从浏览器运行测试。我的 html 装置未加载。

这是我的项目结构。

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

这是我的 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>

当我从浏览器运行测试时。所有的 html 固定装置都是 404。有没有办法让两种方式都起作用?

这就是我加载夹具的方式

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

这是我的 jasmine-jquery 路径配置

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

【问题讨论】:

  • 你有没有在不设置fixture路径的情况下进行测试。因为你把它放在默认路径中,所以不需要设置它。

标签: jquery maven jasmine jasmine-jquery jasmine-maven-plugin


【解决方案1】:

我意识到这是一个老问题,只是想在这里记录我的发现。我正在努力让一些相同的东西启动并运行自己。我发现运行 bdd 目标时路径是相对于项目的基础,而不是您创建的 jasmine 文件夹。这种结构可能会在 OP 的环境中工作。

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

据我所知,这是known issue

Here's a post about how to work around it using profiles. 基本上,您为 Jasmine 插件的每个目标创建一个配置文件。希望这对某人有所帮助...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    • 1970-01-01
    • 2013-05-07
    相关资源
    最近更新 更多