maf3-test-runner

0.1.0 • Public • Published

MAF3 Test Runner

Build Status

Lint and Unit Testing for the MAF 3 framework

Prerequisites

After creating Your application

  • To get things started it is simplest to install the maf3-test-runner straight away so that the examples directory is available immediately under node_modules/maf3-test-runner
npm install maf3-test-runner
  • Create package.json in the root of the project to specify dependencies and test scripts

    • Copy examples/package.json
    • Replace YOUR_APPLICATION_NAME in the name field
  • Add node_modules and reports to your .gitignore file

node_modules
reports
  • Install dependencies
npm install
  • Create karma.conf.js in the root of the project to configure the Karma test runner

    • Copy examples/karma.conf.js
    • Under preprocessors set the path to the code to be covered by tests
    preprocessors: {
      '*/.html': [],
      'path/to/your/source/code/for/coverage/**/*.js': 'coverage'
    },
    
    • Optionally, change the coverage thresholds ;)
    thresholdReporter: {
      statements: 100,
      branches: 100,
      functions: 100,
      lines: 100
    },
    
  • Create test.html in the root of the project to be the bootstrap for the tests

    • Copy examples/test.html
    • Note the name of the application set to autostart, you will create this application later
  • Create Gruntfile.js in the root of the project to implement the test scripts

    • Copy examples/Gruntfile.js
    • Replace YOUR_APPLICATION_NAME in the files array
  • Create sonar-project.properties in the root of the project to enable sonar analysis

    • Copy examples/sonar-project.properties
    • Replace YOUR_COMPANY_NAME with your comapny name, YOUR_APPLICATION_NAME and YOUR APPLICATION NAME with your application name
  • Create a test application unders apps to contain the tests,

    • Copy examples/apps/com.maf3-test-runner.widget.Test to match the application set to autostart
    • Add the paths to your source files and tests to the includes in Contents/Javascript/init.js
    • Start adding tests!

Running tests, etc...

The following scripts will be available using npm

npm test

Run the tests once

npm run-script watch

Watch the configured files from Gruntfile.js and run tests whenever they change.

npm run-script karma

Start the Karma server and leave it running - useful for debugging as then you can connect any browser to http://localhost:9876 and run the tests or use the debug feature of Karma.

npm run-script karma-run

Will start tests in the connected browsers if the Karma server has been started with npm run-script karma

npm start

Will start a web server exposing the root of your project at http://localhost:8000. Use this to run your application in a browser.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using:

$ npm test

License

Copyright © 2014 Liberty Global

Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i maf3-test-runner

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • pghalliday