Skip to content

JavaScript testing with Maven

oleh-maikovych edited this page Sep 24, 2014 · 9 revisions

This is a step-by-step instruction for integrating Jasmine testing framework with maven.

Requirements

  • JDK 1.6+
  • Maven 3.0.4+

Step 1: Configure POM file

Augment plgins section of the project's pom file with the following instructions:

		<plugins>
			<plugin>
				<groupId>com.github.searls</groupId>
				<artifactId>jasmine-maven-plugin</artifactId>
				<version>1.3.1.5</version>
				<executions>
					<execution>
						<goals>
							<goal>test</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
					<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
					<jsSrcDir>src/main/web/ua/com/fielden/platform/web</jsSrcDir>
					<jsTestSrcDir>src/test/web/ua/com/fielden/platform/web</jsTestSrcDir>
					<customRunnerConfiguration>src/test/web/ua/com/fielden/platform/web/app/testspike/jasmine.txt</customRunnerConfiguration>
					<preloadSources>
						<source>vendor/require.js</source>
					</preloadSources>
				</configuration>
			</plugin>
		</plugins>

This instructions tells Maven to use maven-jasmin-plugin for testing JavaScript code.

Step 2: Download and install PhantomJS

Download PhantomJS for preferred operating system from http://phantomjs.org/download.html and install it. After the installation please make sure that phantomjs executable is in your system's PATH by running phantomjs command in the terminal.

Clone this wiki locally