How do I "think in QUnit" with my own JavaScript libraries?
github, javascript, local-storage, qunit, unit-testing
Solution
Travis-ci is indeed a good way to trigger tests, including for client-side libraries.
The answer "Using Travis-CI for client-side JavaScript libraries?" give a good examples of such tests, in `kort/kort/tree/develop/test/client`, which includes QUnit in its `index.hml` file. The key is to use Grunt.js.
An example of Travis job: kort/kort/jobs/3266208 does include running QUnit.
4 years later, update following the bounty:
You can see unit tests maintained overtime in the FredrikNoren/ungit, which uses Travis.
But since you are not on GitHub, you can use alternatives like GitLab-CI (using you very own GitLab CE -- Community Edition -- server if you want)
See more with that approach in "GitLab Frontend testing standards and style guidelines": those best practices applied to the GitLab project itself could by applied to your projects as well. You can see their unit test policy.
Problem
How do I "think in Qunit" with my own JavaScript libraries ? I'm familiar with developing in javascript, but now I'd like to start using Qunit (with my applications in HTML/JavaScript). I make my own libraries. I use public functions and private functions. I also use asynchronous functions (event listeners and callbacks) similar to jQuery: ``` var mylib; (function() { //... })(); ``` I don't know how to organize that. Here are a few questions to clarify the kind of answers I'm seeking: - How do I unit test private functions? - How do I combine hundreds of tests? - In your experience, what's the best method for organizing the tests? Should I use several HTML files? How should I split the tests between JavaScript files? Are there QUnit plugins that you recommend for unit testing? With GitHub, can I use QUnit automatically when I commit? How do you set that up? Maybe with travis-ci? How do I unit test asynchronous functions? Specifically, what if the functions have a link with LocalStorage (HTML5 Storage) and can interact with other pages (like this)? How can I test that? Should I use an object variable instead of the LocalStorage? I visited the official website http://qunitjs.com/, but I don't think that the documentation is a good starting point.