【问题标题】:Testing javascript with QUnit and conditional inclusion使用 QUnit 和条件包含测试 javascript
【发布时间】:2012-11-23 01:00:35
【问题描述】:

我需要有关使用 QUnit 测试 javascript 的提示。

例如,在测试时需要包含 QUnit 库和测试文件,但这些文件不得包含在生产环境中

如何处理这个问题并有条件地包含这些文件可能使用 Spring 配置文件?

供您参考,我使用 Spring + Thymeleaf。

【问题讨论】:

  • 你用什么来构建你的应用程序?

标签: spring maven spring-mvc qunit thymeleaf


【解决方案1】:

使用spring.profiles.active 在以下位置之一切换 QUnit 配置文件:

  • 系统环境变量
  • JVM 系统属性
  • web.xml 中的 servlet 上下文参数
  • JNDI

例如,可以将 web.xml 设置为生产配置文件:

<servlet>
      <servlet-name>dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
          <param-name>spring.profiles.active</param-name>
          <param-value>production</param-value>
      </init-param>
  </servlet>

但是命令行可以覆盖它:

-Dspring.profiles.active="QUnit"

参考文献

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多