Package Development

Packages are used to create reusable widgets, actions and libraries for exams. This section will help you get started using the seed project to create a new Hammer package. For in-depth instructions and training, visit the Tutorials section.

Getting Started

Prerequisites

Highly recommended

Though these are not required, they are recommended installations.

  • NPM Check npm install -g npm-check
    Checks for outdated node modules used by Hammer.
  • NPM Check Updates npm install -g npm-check-updates
    Check for outdated bower components used by your exam.

Windows Users

Hammer uses a private Bower registry to access Hammer packages. If you are on a Windows machine, in order to download and install the Hammer packages from our private repository you will need to download and install Microsoft's Git Credential Manager for Windows

Quick Setup

  1. Create a new repository at the GIT repository. If you do not have a login, please contact Certiport to have one created for you.
  2. Check out your newly created repository: git clone <git_repo_url>
  3. Download the package seed and extracts its contents into your the empty repo direct on your local machine.
  4. Navigate to your project directory in your terminal and run the following command: npm install && node setup and following the setup instructions.
  5. Run http-server from the terminal: http-server
  6. Open http://localhost:8080 in Chrome

You should be up and running at this point with the default seed project.

Installing Hammer packages

Your package SHOULD NOT have any dependencies of other packages, with the exception of hammer-framework and hammer-application which are core packages and used in every exam. You can install additional packages using Bower. Click here to learn more about Bower.. For example, if you needed support for accessibility, you would run the following command:

bower install hammer-accessibility --save-dev

Your packages are installed in the sandbox/bower_components directory.

The --save-dev adds "hammer-layout" to "bower.json" as a dependency. Make sure you use the --save-dev tag and NOT the --save tag.

Checking for Hammer Package Updates

The easiest way to check for possible updates without automatically updating your packages is to use an node module called npm-check-updates.

From the project root

ncu -m bower

To update your packages

ncu -m bower -a
bower update

Compiling code

Compiling your code will compile to src directory to "dist" and "sandbox/bower_components/PACKAGE_NAME". Use the following task"

grunt

Continuous compiling

To have the project compile as you make changes in your source code, run the following task:

grunt watch

Running Unit Tests

Unit tests use the Jasmine framework.

You can run you tests in the browser. This has the advantages in that you can put breakpoints in the specs and the code to find out where issues are. In WebStorm navigate to tests/unit/spec_runner.html and open in Browser (as described in the section Running your project in Chrome) or alternatively you can run http-server if you have it installed.

http-server

Then open http://localhost:8080/tests/unit/spec_runner.html in a browser.

You can optionally run your tests from a command line:

Note: This is still in development.
grunt test

Running your project in the Chrome browser

Chrome is the official browser used for testing and delivery.

Instructions for WebStorm editor

You can run your project directly from WebStorm. Right-click the HTML file in index.html in the project root and select Open in Browser under the menu options.

Instructions for other editors

If you are an alternative editor such as Atom, Sublime or other, you should install http-server, a node module

npm install http-server -g

Then initiate the server from the project root and open the url provided in Chrome.

http-server

Click here for more information on http-server