Automation Testcafe custom reporter没有';无法从此.formatError返回
我正在尝试为testcafe实现一个定制的reporter。如果testcase中存在错误并且调用了this.formatError,则它不会从this.formatError返回。只是无限期地挂在那里,我需要手动ctrl-c来停止testcafe进程。但是,如果我删除此.formatError并重试,它将正常工作。原因可能是什么 下面是reportTestDone()的代码Automation Testcafe custom reporter没有';无法从此.formatError返回,automation,automated-tests,report,e2e-testing,testcafe,Automation,Automated Tests,Report,E2e Testing,Testcafe,我正在尝试为testcafe实现一个定制的reporter。如果testcase中存在错误并且调用了this.formatError,则它不会从this.formatError返回。只是无限期地挂在那里,我需要手动ctrl-c来停止testcafe进程。但是,如果我删除此.formatError并重试,它将正常工作。原因可能是什么 下面是reportTestDone()的代码 reportTestDone(名称、testRunInfo、meta){ const errors=testRunInf
reportTestDone(名称、testRunInfo、meta){
const errors=testRunInfo.errs;
const warnings=testRunInfo.warnings;
const hasErrors=!!errors.length;
const hasWarnings=!!warnings.length;
const result=hasErrors?this.chalk.red('失败')
:此.粉笔.绿色('passed');
const title=`${result}${name}@${meta.page}`;
这个。写(标题)
.newline();
如果(有错误){
this.write('错误:')
.newline();
errors.forEach((error,idx)=>{
这是setIndent(4)
.write(此.formatError(错误,${idx+1}')//{
这条新线()
.写(警告);
});
}
这个.setIndent(0);
}
好的,问题出在createErrorDecorator()上。生成报告程序时,它也为createErrorDecorator()创建了代码。删除此代码后,它就可以工作了。感谢您分享您的发现。我建议您将其作为答案发布。
reportTestDone (name, testRunInfo, meta) {
const errors = testRunInfo.errs;
const warnings = testRunInfo.warnings;
const hasErrors = !!errors.length;
const hasWarnings = !!warnings.length;
const result = hasErrors ? this.chalk.red('failed')
: this.chalk.green('passed');
const title = `${result} ${name} @ ${meta.page}`;
this.write(title)
.newline();
if (hasErrors) {
this.write('Errors:')
.newline();
errors.forEach((error, idx) => {
this.setIndent(4)
.write(this.formatError(error, `${idx + 1} `)) //<-- this line is the problem
.write(error.errMsg)
.newline();
});
this.setIndent(0);
}
if (hasWarnings) {
this.newline()
.write('Warnings:');
warnings.forEach(warning => {
this.newline()
.write(warning);
});
}
this.setIndent(0);
}