-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document event life cycle #1797
Comments
This is what I'm seeing, but it's not what the current docs imply should happen:
This says to me that a top-level import { module, test } from 'qunit';
module('Top-level module', function(hooks) {
hooks.before(function() {
console.log('>> top-level before');
});
hooks.beforeEach(function() {
console.log('>> top-level beforeEach');
});
module('Nested module', function(hooks) {
hooks.before(function() {
console.log('>> nested before');
});
hooks.beforeEach(function() {
console.log('>> nested beforeEach');
});
test('log', function() {});
});
}); If the docs are correct, and the hooks of parent modules are run before the hooks added to the current module that the test is part of, I would expect to see this:
However, what I actually see is:
Frustratingly, I actually want the expected behaviour in one of my suites, but regardless, it would be good to have clarity on the order - so thanks for documenting it 🙂 . |
@BillyRayPreachersSon That text is referring to order within a single hook. "before", "beforeEach", "afterEach", and "after", are four different hooks. This is important as it allows children to build on the work of parents, yet also allow each test to cleanly inherent the module state. For compatibility, and based on many years of use cases being expressed in satisfactory ways, we'd not likely change this. But, those docs can definitely be clearer. If you provide a more detailed example of what you're trying to do, I'd be happy to review that for you and see if we can make it more intuitive. I'm sure you don't need help to make it work, but I wouldn't want you to feel the end result is counter-intuitive. Hence I'd like to see an example, and look for what may've led to that as an expectation, and to perhaps improve something aside or in addition (without breaking change) to better accommodate that! |
We have:
While each is well-documented, and describes when it runs, and how (sync or async), we don't have yet provided an explicit overview of the overall order of events. Where this matters most is:
QUnit.begin()
andQUnit.on('runStart')
which logically run at the same time. Idem forQUnit.done()
andQUnit.on('runEnd')
. Consider a sentence like "QUnit.config.urlConfig
modifications must be made before QUnit.begin". Does that meanrunStart
is fine, or is that too late? And is that supported or accidental?hooks.afterEach
andQUnit.testDone()
, where the order is not obvious per se, ref New test reporter hook #1475.Life cycle
I wrote up the following to get us started.
QUnit.on('runStart')
[reporter, sync]QUnit.begin()
[plugin, async-await]QUnit.on('suiteStart')
[reporter, sync]QUnit.moduleStart()
[plugin, async-await]QUnit.on('testStart')
[reporter, sync]QUnit.testStart()
[plugin, async-await]hooks.before()
[testing, async-await]QUnit.hooks.beforeEach()
[plugin, async-await]hooks.beforeEach()
[testing, async-await]QUnit.test()
function [testing, async-await]QUnit.log()
[plugin, sync]hooks.afterEach()
[testing, async-await]QUnit.hooks.afterEach()
[plugin, async-await]hooks.after()
[testing, async-await]QUnit.on('testEnd')
[reporter, sync]QUnit.testDone()
[plugin, async-await]QUnit.on('suiteEnd')
[reporter, sync]QUnit.moduleDone()
[plugin, async-await]QUnit.on('runEnd')
[reporter, sync]QUnit.done()
[plugin, async-await]Would a table be clearer?
QUnit.on('runStart')
QUnit.begin()
QUnit.on('suiteStart')
QUnit.moduleStart()
QUnit.on('testStart')
QUnit.testStart()
hooks.before()
QUnit.hooks.beforeEach()
hooks.beforeEach()
QUnit.test()
functionQUnit.log()
hooks.afterEach()
QUnit.hooks.afterEach()
hooks.after()
QUnit.on('testEnd')
QUnit.testDone()
QUnit.on('suiteEnd')
QUnit.moduleDone()
QUnit.on('runEnd')
QUnit.done()
The text was updated successfully, but these errors were encountered: