2017-07-27 52 views
0

我想要做的是console.log如果在AVA测试中出现故障,但我找不到有关如何执行此操作的任何文档 - 如果可能的话。有没有办法在Ava中检测AssertionError

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'); 
}); 

回答

相关问题