Frage

I would need tips about testing javascript with QUnit.

For instance one needs to include the QUnit library as well as the test file when testing but those files must not be included in production.

How can one deal with this issue and conditionally include those files possibly using Spring profiles?

For your information, I use Spring + Thymeleaf.

War es hilfreich?

Lösung

Use spring.profiles.active to toggle the QUnit profile in one of the following places:

  • system environment variables
  • JVM system properties
  • servlet context parameters in web.xml
  • JNDI

For example, the web.xml can be set to the production profile:

<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>

But the command-line can override it:

-Dspring.profiles.active="QUnit"

References

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top