-
Notifications
You must be signed in to change notification settings - Fork 783
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
Support global test-level setup/teardown callbacks #633
Comments
It's a step in the right direction but I'd also like to see similar methods like " In the greater context, if we add per-module
|
I reviewed this suggestion in the PR I closed and discussed it with Leo. The main reason why I think that this is a bad idea is the rather loose runtime behaviour of modules. The rerun-failed-tests-first ("rerun") feature of QUnit means that any test from any module can ran before other tests in the same module. From that perspective, a setup that runs only once per module makes no sense, since its impossible to reason about when that should run in the "rerun" case. If that makes sense, the naming discussion shouldn't be necessary. Otherwise I'll get back to that as needed. |
Hmm, OK, I can definitely see the potential conflicts between the So, moving on, my next question would be: is QUnit.config.setup = fn;
QUnit.setup = fn;
QUnit.module.setup = fn; |
The advantage I see of using Otherwise the three options you suggest are pretty much equivalent, I don't see any drawbacks to either of them. |
I'm not overly concerned about it, was just curious about the rationale. Honestly, regardless of where we put it among these 3 options, I'm not sure if a new user would be able to intuitively understand the purpose of methods named e.g. some possible confusions:
Correct interpretation: "Set up for every test" So... maybe |
That is a good point. We're working on the implementation and struggle to find better names. How about picking something from other frameworks thats a lot more explicit, like "beforeEach" and "afterEach"? That'll be inconsitent with the setup/teardown of module, but we could rename those (with the usual deprecation process...). |
I personally really like the terminology of Another thing to keep in mind with all of this is the fairly closely related/integrated changes needed for #543. |
|
Ignoring #543 for a moment, it looks like we agree on Once we have consensus on the nested modules, we can land this as-is or adapt accordingly. |
Sounds like a plan. 👍 |
Following pull #635. Having global setup/teardown could be useful. But do we need to rename them from setup/teardown to beforeEach/afterEach? I'm not sure I see the value or justification in "renaming them at the same time". The module-specific setup/teardown hasn't changed in behaviour or signature, we'd be deprecating that for no reason other than the name. Aside from the naming, there's nothing here that requires existing code to change, that's quite valuable from an API point of of view to maintain. What's the advantage of "beforeEach" and "afterEach"? |
The only reason for the rename is consistency with the new methods we're adding, which also match the naming in other libraries. There's no other change. We considered using setup/teardown for both, but that is far from intuitive. I think its better to fix the naming now, while we're migrating other APIs, then keeping the inconsistent naming around forever. Btw., since you wrote "could be useful", here's another usecase for this ticket, in my second comment: qunitjs/api.qunitjs.com#63 |
@Krinkle does the comment above address your concerns? |
Between locating the hooks in `QUnit` or `QUnit.config` and making them simple setters and callback lists (like QUnit.done et al) and upcoming plans for nested suites, we decided not to release this feature, for now. I'm keeping the abstractions for hooks in place, so it should be trivial to bring this back in whatever form we decide on later. Effectively reverts 5ee31a0 and follow-up commits. Fixes qunitjs#665 Ref qunitjs#633 Ref qunitjs#635 Ref qunitjs#647
Between locating the hooks in `QUnit` or `QUnit.config` and making them simple setters and callback lists (like QUnit.done et al) and upcoming plans for nested suites, we decided not to release this feature, for now. I'm keeping the abstractions for hooks in place, so it should be trivial to bring this back in whatever form we decide on later. Effectively reverts 5ee31a0 and follow-up commits. Fixes qunitjs#665 Ref qunitjs#633 Ref qunitjs#635 Ref qunitjs#647
As originally discussed in #471, it is useful to have setup and teardown callbacks for each test that can be defined globally. For example, in ember the monkey-patching of
QUnit.module
could be replaced.As an API I'm suggesting a simple property assignment. This ensures that there is only one place to do this (avoid scattering global setup/teardown across files) and it can be disabled (set to null):
This would be simple to document as part of QUnit.config.
The text was updated successfully, but these errors were encountered: