qunit
qunit copied to clipboard
Share 'before' hook test environment with child module
Tell us about your runtime:
- QUnit version: 2.6.2
- What environment are you running QUnit in? (e.g., browser, Node): browser
- How are you running QUnit? (e.g., script, testem, Grunt): ember-qunit
What are you trying to do?
module('parent', function(hooks) {
hooks.before(function() {
this.hello = 'world';
});
test('outer', function(assert) {
assert.equal(this.hello, 'world'); // pass
});
module('child', function() {
test('inner', function(assert) {
assert.equal(this.hello, 'world'); // fails
});
});
});
What did you expect to happen?
Expecting nested child modules to share test environment with parent module.
What actually happened?
Nested child module have it's own test environment object.
This is a practical issue that would be resolved by implementing #869.
I've confirmed beforeEach is shared as expected, and that before still is not.
https://codepen.io/Krinkle/pen/JjXJgoz
Changing this is imho considered a breaking change, but a good one to make in the 3.0 release.
TODO: Figure out how we can help users prepare for this ahead of the QUnit 3.0 release so that any difference in behaviour can be smoothened out and warned for.