java - Spring Maven 项目中的 Jasmine 测试 :expect jQuery UI autocomplete is not recognized in the spec

标签 java maven jquery-ui jasmine

我最近在我的项目中设置了 Jasmine 测试,并尝试在我的报告中实现和测试自动完成功能。

我正在使用 jQuery UI 自动完成功能并尝试测试该方法调用是否已在我的规范中进行。但测试失败,说无法识别自动完成功能。

在固定装置中,我已经包含了 javascript 文件,因为我的自动完成函数调用位于 document.ready 函数中,并且还包含了所需的 jquery、jquery UI js 文件。

我认为这可能是 Maven 依赖项的问题,因此我在附加固定文件中也包含了依赖项文件。

POM.XML(仅依赖项和插件)

 <dependency>
  <groupId>org.webjars</groupId>
  <artifactId>jasmine-jquery</artifactId>
  <version>2.0.3</version>
  <scope>test</scope>
</dependency>

<pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.github.searls</groupId>
          <artifactId>jasmine-maven-plugin</artifactId>
          <version>2.0</version>
          <executions>
            <execution>
              <goals>
                <goal>test</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <preloadSources>
              <source>webjars/jquery.js</source>
              <source>webjars/jasmine-jquery.js</source>
              <source>http://davidstutz.github.io/bootstrap-multiselect/dist/js/bootstrap-multiselect.js</source>
            </preloadSources>
            <jsSrcDir>src/main/webapp/resources/js</jsSrcDir>
            <jsTestSrcDir>src/test/javascript</jsTestSrcDir>
            <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

夹具文件:

<title>Fixture File for auto complete</title>
</head>
<body>
  <form action="javascript:void(0)" method="get">
    <input type="text" id="searchAutoComplete" />
  </form>

夹具中的脚本标签似乎没有出现在帖子中。但我已在夹具中包含了 js 文件和 jquery-ui.js 文件。

大家认为问题可能是什么以及如何解决?

最佳答案

我修改了pom.xml,如下所示:

 <pluginManagement>
  <plugins>
    <plugin>
      <groupId>com.github.searls</groupId>
      <artifactId>jasmine-maven-plugin</artifactId>
      <version>2.0</version>
      <executions>
        <execution>
          <goals>
            <goal>test</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <preloadSources>
          <source>webjars/jquery.js</source>
          <source>webjars/jasmine-jquery.js</source>
          <source>${project.basedir}/src/main/webapp/resources/js/lib/jquery-ui.min.js</source>
          <source>http://davidstutz.github.io/bootstrap-multiselect/dist/js/bootstrap-multiselect.js</source>
        </preloadSources>
        <jsSrcDir>src/main/webapp/resources/js</jsSrcDir>
        <jsTestSrcDir>src/test/javascript</jsTestSrcDir>
        <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

我已将 jquery-min.js 添加到项目库中,并将路径包含在 pom.xml 中。 这样就可以了。

关于java - Spring Maven 项目中的 Jasmine 测试 :expect jQuery UI autocomplete is not recognized in the spec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40165918/

相关文章:

java - 了解如何使用 visitFrame

java - 为什么在创建一维数组对象时需要定义数组长度?

java - 使用 Stax Parser 将大于 10GB 的巨大 xml 文件拆分成小块

maven-2 - Maven 自动快照更新

Jquery多个动态进度条

java - RxJava : update result of call with results of subsequent calls

java - 为什么导入到eclipse中的maven项目没有得到 "Maven Dependencies"列表?

java - 如何在运行 Tomcat 时获取包版本?

javascript - jquery UI datepicker透明背景

jquery - 更新 jQuery 和 jQuery UI 文件出现错误