In each spec I have beforeEach
and afterEach
statements. Is it possible to add it somehow globally to avoid code duplication between specs ?
Purpose of beforeEach()
and afterEach()
functions are to add a block of repetitive code that you would need to execute every time you start or complete executing each spec(it
). There are other ways to add generalised code to avoid code repetition, here are few -
describe
), then you can use beforeAll()
and afterAll()
functions that jasmine provides. onPrepare()
and onComplete()
function.beforeLaunch
and afterLaunch
.So it all depends on the scenario that you want to use them in. Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With