-
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
Test: Implement universal module setup/teardown #635
Conversation
Just took a very quick look but seems good to me. |
var translate = { | ||
beforeEach: "setup", | ||
afterEach: "teardown" | ||
}; |
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.
this translate object is temporary until we deprecate and remove QUnit.module's setup/teardown names for beforeEach/afterEach
5636dca
to
1797086
Compare
I didn't yet run this test, so something may be wrong, but it should work like this: QUnit.config.beforeEach = function( assert ) {
assert.deepEqual( Object.keys( this ), [ "helper" ] );
};
QUnit.module("context object", {
beforeEach: function( assert ) {
assert.deepEqual( Object.keys( this ), [ "helper" ] );
this.prop = "foobar";
},
helper: function() {}
});
QUnit.test("keys", function( assert ) {
assert.deepEqual( Object.keys( this ), [ "helper", "prop" ] );
}); See also qunitjs/api.qunitjs.com#63 |
16ebe40
to
982063e
Compare
@@ -8,7 +8,7 @@ function Test( settings ) { | |||
Test.count = 0; | |||
|
|||
Test.prototype = { | |||
setup: function() { | |||
beforeEach: function() { |
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.
I'm okay with renaming these methods, but the "each" part doesn't really make sense, since they are called just once for each Test
instance. We can also just leave the names as-is (Test#setup and Test#teardown), since these have a completely different scope. If we rename, then "before" and "after" should be good.
bc490e9
to
cf4321b
Compare
Rebased with suggested changes:
|
846b027
to
fa96fdf
Compare
QUnit.module setup and teardown functions are now deprecated as they were moved to beforeEach/afterEach. Tests were added to confirm they still work while deprecated. beforeEach and afterEach are no longer exposed to the test context as setup/teardown were accidentaly. Ref qunitjs#635
QUnit.module tests were moved - with some improvements - to a new test file modules.js Some other tests were also removed because they were revealed as unnecessary tests. Ref qunitjs#635
fa96fdf
to
74d566f
Compare
Looks good, let's land it. |
Now we just need the API docs to land when we release 1.16. |
Late to the party but just a note: I'm glad we chose "hooks" as that is consistent with Mocha's terminology. |
@JamesMGreene we checked on their documentation before choosing the name. |
\o/ |
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
Deprecates setup/teardown. Ref qunitjs/qunit#635 Fixes #70 Closes #76
This implements the equivalent of setup/teardown methods that are define once for the entire testsuite, but run for each test. To make this easier to understand, we've went from setup/teardown to beforeEach/afterEach, renaming the existing module properties at the same time (in a separate commit).
Fixes #633