qunit: Prepare testrunner for QUnit 2

Authored by Krinkle on Jul 17 2017, 7:29 PM.


qunit: Prepare testrunner for QUnit 2

  • Nested modules:
    • Support for Sinon extension was fixed by Ib17bbbef45b2bd.
    • Support for Fixture extension was still broken, masked by the use of a local variable that made the handler not fail when setup ran twice in a row. Fixed using the same moduleStack.length check.
    • Add regression test.
  • beforeEach/afterEach:
    • Added in 1.16, with compat for setup/teardown. Our wrapper adds its own setup/teardown, and preserves any original one. However, it didn't account for beforeEach/afterEach, so it ends up sending both but only one is used.
    • Fix to support both on the incoming localEnv object, and also switch our wrapper to use beforeEach/afterEach in prep for QUnit 2.0.
    • Fix our wrappers to preserve return value since QUnit 2 allows beforeEach and afterEach hooks to be asynchronous by returning a Promise, similar to how one can do from QUnit.test().
    • Add regression test.
  • Centralise makeSafeEnv logic
    • We always create our own env object to pass to orgModule(). Document why this is (to avoid recursion).
    • Add regression test.
  • Custom assertion methods:
    • Use this.pushResult instead of the deprecated QUnit.push() method. This also improves the in-browser reporting of errors by properly supporting 'negative' results for notHtmlEqual reporter.

Bug: T170515
Change-Id: If4141df10eae55cbe8a5ca7a26707be1cd7b9217