Reading/Web/QUnit test guidelines

Some guidelines to bear in mind when writing Unit tests on Reading/Web extensions.


 * Do not use calledOnce, calledTwice etc...
 * Calling our constructors have side effects. Tests verify that these side effects happen. assert.ok just tells us yes or no, not how many times - made it hard to debug. Downside: reads less like English/less human readable but on plus side when test fails tells you the difference betteen expectation and actual. To optimise for debugging we use callCount - this allows us to see how many calls are in fact made when a test fails.
 * We should write assertion messages.
 * When a test fails we know why it fails. The message `1 !== 2` is less meaningful then `1 !== 2; The API should be called one time."
 * Use assert.async rather than $.Deferred.resolve when possible.
 * Asynchronous tests should return a Promise. Use helper functions where possible to keep code simple.
 * Use fake objects where possible. Do not stub the prototype. Especially with regards to mw.Api which can cause HTTP requests
 * Avoid doing this.sandbox.stub ( Api.prototype, 'ajax' ).returns - instead pass a FakeApi as a parameter. If code doesn't support this, it should!

Under discussion

 * We could use eslint to enforce some of these practices, but it may be overkill.