Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Entries: Document before and after module hooks #118

Merged
merged 1 commit into from
Apr 19, 2016

Conversation

trentmwillis
Copy link
Member

Adds documentation for the before/after module hooks introduced in qunitjs/qunit#919.

cc @leobalter

</p>
<p>
The module's callback is invoked with the test environment as its <code>this</code> context, with the environment's properties copied to the module's tests, hooks, and nested modules. Note that changes on tests' <code>this</code> won't affect sibling tests, where <code>this</code> will be reset to the same value for each test.
The module's callback is invoked with the test environment as its <code>this</code> context, with the environment's properties copied to the module's tests, hooks, and nested modules. Note that changes on tests' <code>this</code> are not preserved between sibling tests, except when made in the <code>before</code> hook. In all other cases, <code>this</code> will be reset to the initial value for each test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except when made in the <code>before</code> hook. The phrase is already a reference for changes on each test not affecting sibling tests, the before hook is not one of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will remove that.

@leobalter
Copy link
Member

It is looking good, only a single comment above

@trentmwillis
Copy link
Member Author

Updated. Let me know if there any other edits.

@leobalter
Copy link
Member

It LGTM. @gibson042, would you like to check?

@@ -36,13 +42,13 @@
If <code>QUnit.module</code> is defined without a <code>nested</code> callback argument, all subsequently defined tests will be grouped into the module until another module is defined.
</p>
<p>
Modules with grouped test functions allow defining nested modules, and QUnit will run tests on the parent module before going deep on the nested ones, even if they're declared first. The <code>beforeEach</code> and <code>afterEach</code> callbacks on a nested module call will stack (<a href="https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29">LIFO - last in, first out</a>) to the parent hooks.
Modules with grouped test functions allow defining nested modules, and QUnit will run tests on the parent module before going deep on the nested ones, even if they're declared first. Any hook callbacks on a nested module call will stack (<a href="https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29">LIFO - last in, first out</a>) to the parent hooks.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preexisting issue, but only the "after" hooks form a stack—"before" hooks form a queue. This might be better characterized as the parent hooks wrapping nested ones.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will correct that.

@trentmwillis
Copy link
Member Author

@gibson042 updated to address your comment.

@gibson042
Copy link
Member

LGTM.

@leobalter leobalter merged commit 249f4a7 into qunitjs:master Apr 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

4 participants