Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An SBT plugin for running jasmine tests in your build.
JavaScript Other
tag: 0.2.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


An SBT plugin for running jasmine tests in your build.

Getting the plugin

The most convenient way of using this plugin is to add a source dependency in a scala file under project/project:

lazy val plugins = Project("plugins", file("."))

you will also need to import the plugin's settings in the usual way:

seq(jasmineSettings : _*)

Running the plugin

Override the following settings setting in your build:

  • appJsDir - the root directory where your application javascript lives
  • appJsLibDir - the root directory where you put javascript library files thast your application uses (e.g jquery)
  • jasmineTestDir - the directory that contains your jasmine tests, jasmine will look for /specs and /mocks sub directories
  • jasmineConfFile - the test.dependencies.js configuration file that loads the required application js and lib js files into the test context.

For a project laid out as follows:

|-- main
|   `-- webapp
|       `-- static
|           `-- js
|               `-- samples
|                   |-- <app js files here>
|                   `-- lib
|                       `-- <js library files here>
`-- test
    `-- webapp
        `-- static
            `-- js
                |-- mocks
                |   `-- <jasmine mock js files here>
                |-- specs
                |   |-- <jasmine spec js files here>
                `-- test.dependencies.js

The project configuration would be:

appJsDir <+= sourceDirectory { src => src / "main" / "webapp" / "static" / "js" / "samples"}

appJsLibDir <+= sourceDirectory { src => src / "main" / "webapp" / "static" / "js" / "samples" / "lib" }

jasmineTestDir <+= sourceDirectory { src => src / "test" / "webapp" / "static" / "js" }

jasmineConfFile <+= sourceDirectory { src => src / "test" / "webapp" / "static" / "js" / "test.dependencies.js" }

You can now run the jasmine task to run the tests.

Paths exposed to your tests

The following path variables are available to your javascript (in test.dependencies.js and the tests):

  • EnvJasmine.testDir = the jasmineTestDir (note no trailing slash on this path)
  • EnvJasmine.mocksDir = EnvJasmine.testDir / mocks
  • EnvJasmine.specsDir = EnvJasmine.testDir / specs
  • EnvJasmine.rootDir = the appJsDir
  • EnvJasmine.libDir = the appJsLibRoot

N.B. all path variables have a trailing slash so you don't need to add them yourself when building paths. Thus to load the query library as in your test.dependencies.js file you would add the following line:

EnvJasmine.loadGlobal(EnvJasmine.libDir + "jquery-1.4.4.js");

Running as part of test

To automatically run the jasmine plugin as part of your project's test phase you can add the following to you build.sbt:

(test in Test) <<= (test in Test) dependsOn (jasmine)


To release a new version, tag it and push the tag to github.

git tag -a 1.XXX
git push --tags
Something went wrong with that request. Please try again.