Skip to content

Make QUnit.config.beforeEach/afterEach functions rather than setters #665

@JamesMGreene

Description

@JamesMGreene

As I discussed with the rest of the QUnit core team in Chicago, I think that QUnit.config.{beforeEach|afterEach} should be changed to be functions rather than setters.

This is beneficial in the following ways:

  1. Allows consumers to easily supply more than one beforeEach/afterEach callback.
  2. Allow plugins such as custom assertions that currently have to use hacky hooks via the QUnit.testStart/QUnit.testDone logging callbacks to achieve global beforeEach/afterEach behavior to get a proper extension point with access to the correct Test and Assert contexts rather than needing to rely on QUnit.config.current. Clear evidence of this can be seen in the JamesMGreene/qunit-assert-step @ qunit-assert-step.js#L21-L26.
  3. Will be required for API consistency-sake anyway [in v2.x] if my forthcoming PR proposal for Issue Allow nested suites (modules) #543 (nested suites) is accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions