Reputation: 1465
What's the difference between these two tests:
beforeEach(doSomething)
describe("i am the only root describe in this test file", () => {
// many test cases...
})
describe("i am the only root describe in this test file", () => {
beforeEach(doSomething)
// many test cases...
})
Upvotes: 3
Views: 900
Reputation: 1465
If put beforeEach
in a describe, it runs before each test in this block. If put it in the root level, it runs before all tests in all test files.
See https://github.com/demo-drive-learn/mocha-root-pre-hook, or check this demo.
Upvotes: 2