Imagine a test with global hooks, and a Parent and Child module that use hooks also. The execution order is:
1. Parent module runs the before hook.
2. Every test in the Parent module inherits context from the before hook, and repeats as follows: call global beforeEach, parent beforeEach, the actual test, parent afterEach, and lastly the global afterEach.
3. The Child module inherits context from the Parent before hook, and then runs its own before hook.
4. Every test in the Child module inherits context from this before hook, and repeats as follows: call global beforeEach, parent beforeEach, child beforeEach, the actual test, child afterEach, parent afterEach, and lastly the global afterEach.
Ever wondered how beforeEach works in a unit test framework?
qunitjs.com/lifecycle/
While people generally guess right, this demonstrates that the order is guaranteed, and showcases what's possible when you depend on it.
Thanks to FND, Jan D, and NullVoxPopuli for their help!
#qunit