An example of unit testing and code coverage for jQuery plugin.
https://github.com/thorst/Code-Coverage-Qunit
- Fork and clone the repo.
- Run
npm install
to install all dependencies (including grunt). - Run
npm run
to know what you can do.
- Browser: Access to ./test/index.html.
- Command Line: Run
npm test
. You can also get code coverage.
$ npm test
> [email protected] test /path/to/folder
> grunt qunit
Running "qunit:files" (qunit) task
Testing test/index.html .OK
>> 3 assertions passed (66ms)
>> Coverage:
>> - Lines: 100%
>> - Statements: 100%
>> - Functions: 100%
>> - Branches: 100%
Done.
Run npm test
like above.
Then access to ./coverage/lcov-report/index.html to get the datails.
Yuusaku Miyazaki [email protected]