Skip to content

Instantly share code, notes, and snippets.

@kevinrobinson
Created June 18, 2013 19:58
Show Gist options
  • Save kevinrobinson/5808736 to your computer and use it in GitHub Desktop.
Save kevinrobinson/5808736 to your computer and use it in GitHub Desktop.
Jasmine beforeEach functions get called for each nested example
describe "setup", =>
@val = 0
beforeEach => @val += 10
afterEach => @val -= 100
describe "when loaded", =>
it "a", => expect(this.val).toEqual 10
it "b", => expect(this.val).toEqual 10
it "c", => expect(this.val).toEqual 10
@kevinrobinson
Copy link
Author

Check it in tryjasmine.com and notice that there are failure. The beforeEach block is running more times than you might expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment