Automation testing javascript in a maven-based project

I have a maven based Java project that also contains some javascript functions that I would like to test. I use QUnit (but can switch to a different js testing framework) to write tests, but I have to run index.htmlto see the tests running in a browser window.

Is there a current and working maven plugin that will run these tests for me and ideally present the results along with the usual test junit servers that I already have?

I already tried to use what currently exists, but most of the solutions are old and with broken documentation. The closest I could get was to use https://github.com/mxro/java-qunit , but it runs all js tests in one test junit and stops on the first crash.

+4
source share
1 answer

Running Maven JS Tests

Frontend Maven Plugin, npm. - , - , , . :

    <plugin>
      <groupId>com.github.eirslett</groupId>
      <artifactId>frontend-maven-plugin</artifactId>
      <version>0.0.24</version>
      <executions>
        <execution>
          <id>Install NodeJS and NPM</id>
          <goals>
            <goal>install-node-and-npm</goal>
            <goal>npm</goal>
          </goals>
          <configuration>
            <nodeVersion>v0.12.7</nodeVersion>
            <npmVersion>2.11.3</npmVersion>
          </configuration>
        </execution>
      </executions>
    </plugin>

:

        <execution>
          <id>UI Unit Tests</id>
          <goals>
            <goal>karma</goal>
          </goals>
          <configuration>
            <karmaConfPath>${project.basedir}/src/test/unit-js/karma.conf.js</karmaConfPath>
            <skip>${unit.ui.tests.skip}</skip>
          </configuration>
        </execution>

Protractor ( npm):

        <execution>
          <id>UI Component Tests</id>
          <goals>
            <goal>npm</goal>
          </goals>
          <phase>test</phase>
          <configuration>
            <arguments>run component</arguments>
            <skip>${component.ui.tests.skip}</skip>
          </configuration>
        </execution>

. JS- (, Karma, Jasmine), . xUnit CI (, Jenkins) . Allure , ( , ).

+3

Source: https://habr.com/ru/post/1624237/


All Articles