有没有办法在Ava中检测断言错误

有没有办法在Ava中检测断言错误,ava,Ava,如果AVA测试失败,我想做的是console.log,但如果可能的话,我找不到任何关于如何做到这一点的文档 test.afterEach.always(t => { if(t.hasFailure()){ //something like this console.log(JSON.stringify(t.context.someJSON)); } }); test('it fails', t => { t.context

如果AVA测试失败,我想做的是console.log,但如果可能的话,我找不到任何关于如何做到这一点的文档

test.afterEach.always(t => {
  if(t.hasFailure()){                  //something like this
    console.log(JSON.stringify(t.context.someJSON));
  }   
});

test('it fails', t => {
  t.context.someJSON = {sample: 'object'}
  t.fail('forced failure');
});

目前没有办法做到这一点,尽管我们还有一个问题需要解决: