You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey all, I am trying to wrap my head around the contexts in the before hooks.
One discrepancy I noticed was the following
As you can see, for the first before hook in the top-level describe "currentTest" is undefined as we would probably expect, since before() hooks don't pertain to a particular test.
But what I didn't except was in the nested describe, the before hook 'this' value has "currentTest" defined. When I inspected with the debugger I could verify this. Why is this the case? Perhaps explaining this might help me understand Mocha contexts. Thanks!
The text was updated successfully, but these errors were encountered:
here is the original test code that generated the above:
describe('a',function(){before(function(){console.log('before this a:',this.parent);});beforeEach(function(){console.log('beforeEach this a:',this.parent);});it('a',function(done){console.log('it this a:',this.parent);done();});describe('b',function(){before(function(){console.log('before this b:',this.parent);});beforeEach(function(){console.log('beforeEach this b:',this.parent);});it('b',function(done){console.log('it this b:',this.parent);done();});});});
thanks, yeah np I just wanted to make sure because that would throw me way off in understanding what was going on, that's funny because I commented on #1638 without really seeing the bug myself, another software dejavu moment LOL
Hey all, I am trying to wrap my head around the contexts in the before hooks.
One discrepancy I noticed was the following
As you can see, for the first before hook in the top-level describe "currentTest" is undefined as we would probably expect, since before() hooks don't pertain to a particular test.
But what I didn't except was in the nested describe, the before hook 'this' value has "currentTest" defined. When I inspected with the debugger I could verify this. Why is this the case? Perhaps explaining this might help me understand Mocha contexts. Thanks!
The text was updated successfully, but these errors were encountered: