jest/before

Setup and Teardown

Setup and teardown functions

jest
before
setup

Command

beforeEach(() => { ... })

Explanation

Setup and teardown functions help prepare test environment and clean up after tests.

Examples

Run before each test

beforeEach(() => { ... })

Run once before all tests

beforeAll(() => { ... })

Run after each test

afterEach(() => { ... })