jquery - Jasmine maven 插件和 jasmine-jquery 不同的结果

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

我的项目是标准的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 


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>

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

这就是我加载夹具的方式


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

这是我的 jasmine-jquery 路径配置


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

最佳答案

我意识到这是一个老问题,只是想在这里记录我的发现。我正在努力自己建立和运行一些同样的东西。我发现运行 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 插件的每个目标创建一个配置文件。希望这对某人有帮助...

关于jquery - Jasmine maven 插件和 jasmine-jquery 不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12321752/

相关文章:

jquery - 在 http 页面上使用 https 的 Ajax

javascript - 如何在选择器上的 jquery 中访问父级

java - Jersey 应用程序 404 未找到错误

java - 在 Maven 子模块中使用 Spring @PropertySource

java - m2e可以安装外部jar文件吗?还是需要安装maven命令行工具?

javascript - 单元测试使用 Karma 和 Jasmine 使用react

javascript - 如果span包含0,Jquery隐藏父标签

javascript - Jasmine 测试运行期间找不到 haml-js 模板

javascript - 如何在 Sinon 中过滤请求

javascript - 如何检查查询字符串是否已存在