> For the complete documentation index, see [llms.txt](https://asad-razvi.gitbook.io/jest-enzyme-recipes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asad-razvi.gitbook.io/jest-enzyme-recipes/jasmine-recipes/how-can-i-run-code-after-each-it-block.md).

# How can I run code before and after each it block?

```javascript
describe('the counter effect', () => {
  let counter = 0
  beforeEach(() => counter++)
  afterEach(() => counter = 0)
  it('should display one', () => expect(counter).toBe(1))
  it('should still display one', () => expect(counter).toBe(1))
})
```
