maf3-test-runner v0.1.0
MAF3 Test Runner
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 theexamples
directory is available immediately undernode_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 thename
field
- Copy
Add
node_modules
andreports
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 },
- Copy
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
- Copy
Create
Gruntfile.js
in the root of the project to implement the test scripts- Copy
examples/Gruntfile.js
- Replace
YOUR_APPLICATION_NAME
in thefiles
array
- Copy
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
andYOUR APPLICATION NAME
with your application name
- Copy
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!
- Copy
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.
10 years ago