Created
August 25, 2015 20:02
-
-
Save icirellik/b9968abcecbb9e88dfb2 to your computer and use it in GitHub Desktop.
Pass data between beforeEach, afterEach and it in mocha tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expect = require('expect'); | |
describe.only('Sample', function () { | |
beforeEach(function () { | |
this.currentTest.value = 'Winning!'; | |
}); | |
it('Uses current test data', function () { | |
expect(this.test.value).to.equal('Winning!'); | |
this.test.value = 'Win Later'; | |
}); | |
afterEach(function () { | |
expect(this.currentTest.value).to.equal('Win Later'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, the
this
object only works inside a function, not outside, that's why you should use function instead of arrow in the describe or it.