Возможно ли в Mocha (желательно без каких-либо внешних зависимостей) повторно использовать ловушку beforeEach во вложенном контексте с другими значениями var. Например:
describe('Feature', () => {
var reason = 'New'
beforeEach(() => {
// steps
register(reason)
// more steps
})
it('runs with the steps in the hook with reason=New')
context('when reason is Existing', () => {
var reason = 'Existing'
// don't want to rewrite the hook here again.
it('runs with the steps in the hook but with reason=Existing')
})
context('when reason is Other', () => {
var reason = 'Other'
// don't want to rewrite the hook here again.
it('runs with the steps in the hook but with reason=Other')
})
})