Повторное использование хуков с разными варами - PullRequest
0 голосов
/ 06 августа 2020

Возможно ли в 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')

  })
})
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...