Test: Implement universal module setup/teardown#635
Conversation
|
Just took a very quick look but seems good to me. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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