Reputation: 391
I am bit confused. Should beforeAll
/beforeEach
/afterAll
/afterEach
be inside describe
or outside?
Example:
describe('unamed', () => {
beforeAll(async () => {
//
})
})
Vs
beforeAll(async () => {
//
})
describe('unamed', () => {
//
})
Which is correct? Or doesn't matter?
Upvotes: 3
Views: 1566
Reputation: 312066
If you have a before/after function at the top level of the file, it will apply to all the tests in the file. If you have them inside a describe
scope, they only apply to the tests under that describe
scope.
Upvotes: 4