Skip to content

Instantly share code, notes, and snippets.

@papandreou
Created January 1, 2016 22:19
Show Gist options
  • Save papandreou/ba5b3a41c8456fed9ce7 to your computer and use it in GitHub Desktop.
Save papandreou/ba5b3a41c8456fed9ce7 to your computer and use it in GitHub Desktop.
Attach after and afterEach inside it block
it('should foo', function () {
console.log("it foo");
after(function () {
console.log("after foo");
});
afterEach(function () {
console.log("afterEach foo");
});
});
it('should quux', function () {
console.log("it bar");
after(function () {
console.log("after quux");
});
afterEach(function () {
console.log("afterEach quux");
});
});
it('should baz', function () {
console.log("it quux");
after(function () {
console.log("after baz");
throw new Error('fail after baz');
});
afterEach(function () {
console.log("afterEach baz");
});
});
it foo
✓ should foo
afterEach foo
it bar
✓ should quux
afterEach foo
afterEach quux
it quux
✓ should baz
afterEach foo
afterEach quux
afterEach baz
after foo
after quux
after baz
1) "after all" hook for "should baz"
3 passing (5ms)
1 failing
1) "after all" hook for "should baz":
Error: fail after baz
at Context.<anonymous> (foo.js:27:15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment