Reading/Web/QUnit test guidelines

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


 * Always test the comparison itself;
 * Avoid,   (Sinon.JS); QUnit cannot print useful failure messages in these cases.
 * Prefer,   (Sinon.JS); QUnit can print a useful failure diff.
 * Always use ; never use  . The Wikimedia lint rules require strict   and forbid loose  equality comparisons. This should apply to QUnit as well.
 * Avoid  when tests are synchronous; consider   when asynchronous assertions are necessary. In synchronous tests, tallying the assertion count adds noise without providing much value. For asynchronous tests, setting expectations can help catch programmer errors.
 * Always add an assertion failure message.
 * When a test fails we know why it fails. The message " " is less meaningful then " "
 * Use  rather than   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  - 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.