Setup js unit test and code coverage framework
(1) Use frontend-maven-plugin to integrate frontend development
(2) Use jest as test tool
(3) Use webpack to create webapp bundle
(4) Coverage data is saved in target/jscoverage
Issue-ID: POLICY-2311
Signed-off-by: huaxing <huaxing.jin@est.tech>
Change-Id: I34fb7487c1e0ca29114eb7accba8bb7c4812da34
diff --git a/gui-pdp-monitoring/pom.xml b/gui-pdp-monitoring/pom.xml
index 553958c..b4ef307 100644
--- a/gui-pdp-monitoring/pom.xml
+++ b/gui-pdp-monitoring/pom.xml
@@ -30,6 +30,10 @@
<name>${project.artifactId}</name>
<description>GUI for monitoring Pdps Statistics</description>
+ <properties>
+ <webapp.dir>src/webapp</webapp.dir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.onap.policy.common</groupId>
@@ -76,6 +80,90 @@
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<plugins>
<plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ <configuration>
+ <nodeVersion>v9.9.0</nodeVersion>
+ <installDirectory>${webapp.dir}</installDirectory>
+ <workingDirectory>${webapp.dir}</workingDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>install node</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <configuration>
+ <nodeVersion>v10.16.0</nodeVersion>
+ <npmVersion>6.9.0</npmVersion>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>npm test</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>test</arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>webpack build</id>
+ <goals>
+ <goal>webpack</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>Copy frontend build to target</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/classes/webapp</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${webapp.dir}/dist</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${webapp.dir}/node</directory>
+ </fileset>
+ <fileset>
+ <directory>${webapp.dir}/node_modules</directory>
+ </fileset>
+ <fileset>
+ <directory>${webapp.dir}/dist/</directory>
+ <includes>bundle.js</includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>