So I have this code:
describe('main describe', function() {
afterEach(function() {
//this.prop === undefined
});
describe('sub', function() {
it('should do something', function() {
this.prop = 'test';
});
});
});
I don't know why this.prop
in the main
afterEach
is undefined
because the follow code work as expected:
describe('main describe', function() {
afterEach(function() {
//this.prop === 'test'
});
it('should do something', function() {
this.prop = 'test';
});
});
Why does the first code not work as I though it would where this.prop should equal 'test'
and not undefined
?
Is the this
keyword tied to only the describe
function it is directly contained it?