-
Notifications
You must be signed in to change notification settings - Fork 38
Entries: Document before and after module hooks #118
Conversation
</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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
It is looking good, only a single comment above |
5e920c2
to
c10a1b3
Compare
Updated. Let me know if there any other edits. |
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c10a1b3
to
b80675a
Compare
@gibson042 updated to address your comment. |
LGTM. |
b80675a
to
cda8081
Compare
Adds documentation for the
before
/after
module hooks introduced in qunitjs/qunit#919.cc @leobalter