Javascript ava.js中的多个回调

Javascript ava.js中的多个回调,javascript,ava,Javascript,Ava,我有一个回调,我想看看它是否被调用了两次 我已经研究了t.plan,在文章中,它说这是t.plan的一个很好的用例,但是您必须明确定义t.end()。但在我的情况下,它是相同的回调 这怎么可能呢?我会这样做: test.cb('called twice', t => { let remaining = 2 runCode(() => { remaining-- if (remaining === 0) { t.end() } }) })

我有一个回调,我想看看它是否被调用了两次

我已经研究了
t.plan
,在文章中,它说这是
t.plan
的一个很好的用例,但是您必须明确定义
t.end()
。但在我的情况下,它是相同的回调

这怎么可能呢?

我会这样做:

test.cb('called twice', t => {
  let remaining = 2
  runCode(() => {
    remaining--
    if (remaining === 0) {
      t.end()
    }
  })
})