An example project that runs Karma driven JS tests during a Maven build with Webjars dependencies
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
README.md
package.json
pom.xml

README.md

Maven+Karma+Webjars

This is an example project that runs JavaScript unit tests (in this case Jasmine tests) driven by the Karma test runner during a Maven build. It also uses Webjars to manage web-resource dependencies.

This type of setup might be encountered in a Java service + Web UI project for example, or in an enterprise environment where CI builds are standardised around a Java + Maven workflow.

For more information check out this blog post describing the example.

Technologies / libraries used

  • Java 1.7+
  • Servlet 3.0
  • Maven 3+
  • Webjars
  • maven-frontend-plugin
  • Node.js
  • Karma
  • Jasmine
  • AngularJS

Getting started

Required environment

To build and run this project you will need the following environment:

  • Java 1.7+ (required for Jetty)
  • Maven 3.0+ (tested on Maven 3.0.5)

Optionally:

  • An IDE (e.g. Eclipse)
  • Node.js (if you want to run other Node packages outside the CI build)

Running locally

Run the project using the Jetty configuration specified in the POM file:

>> mvn jetty:run

Then access the project at:

http://localhost:8080/maven-karma-webjars-example/index.html

Note you can also run the application on any Servlet 3.0 compliant container (e.g. Apache Tomcat etc.).

Running the CI build

The full CI build, including JS unit test execution, can be run via Maven:

>> mvn clean install

License

This project and all of its contents are release under the Apache 2.0 License.