WebdriverIO自定义报告程序-TypeError:无法读取未定义的属性“ write” /“ complete”

时间:2019-02-22 23:11:20

标签: javascript report webstorm webdriver-io

我正在WebdriverIO中实现自定义报告程序。在学习了一个教程(https://webdriver.io/docs/customreporter.html)之后,我编写了以下代码:

let Reporter = require ('@wdio/reporter').default;
Reporter.reporterName = 'HTMLReporter';

module.exports = class HTMLReporter extends Reporter {
    constructor (options) {
        options = Object.assign(options, { stdout: true });
        super(options);
    }

    onTestPass (test) {
        this.write(`Congratulations! Your test "${test.title}" passed!`);
    }
};

但是,运行此代码时,出现错误TypeError: Cannot read property 'write' of undefinedwrite行中的this.write('Congratulations! Your test "${test.title}" passed!');命令似乎存在问题。

我可以通过将this.write('Congratulations! Your test "${test.title}" passed!');更改为console.log('Congratulations! Your test "${test.title}" passed!');来绕过此错误,但是当我运行此代码时,我得到了错误TypeError: Cannot read property 'complete' of undefined。为什么会出现这些错误?如何修复我的代码以使其正确运行?

1 个答案:

答案 0 :(得分:0)

由于我遇到了同样的问题,所以我决定更换:

Get-ChildItem C:\temp\test\3*.sql | Rename-Item -NewName {$_.Name -replace "_NOT_DONE", ""}

具有:

msoEncodingUTF8

它按预期工作