allure.createAttachment exception error - 无法读取未定义的属性'currentStep'

问题描述 投票:0回答:2

我可以成功地为诱惑报告添加屏幕截图,但是我收到以下异常错误:

错误:

TypeError: Cannot read property 'currentStep' of undefined
    at Allure.addAttachment (/Users//xxx/xxx/xxx/node_modules/allure-js-commons/index.js:86:45)
    at Allure.createAttachment (/Users/xxx/xxx/xxx/node_modules/allure-js-commons/runtime.js:48:29)
    at /Users/xxx/xxx/xxx/lib/class/class-name.js:30:20
    at process._tickCallback (internal/process/next_tick.js:68:7)

类:

 browser.takeScreenshot().then(function (png) {
            allure.createAttachment(title, new Buffer(png, 'base64'));
        }).catch((error: any) => console.log(error));
protractor mocha allure
2个回答
0
投票
const allure = require('mocha-allure-reporter');

allure是一个全局标识符,由记者注入您的代码。

将以下行添加到文件顶部以告诉Typescript

declare const allure: any;

0
投票

我认为createAttachment需要一个回调函数而不是直接传递的缓冲区。

您可以尝试更改代码以反映以下内容

browser.takeScreenshot().then(function (png) {
    allure.createAttachment('Screenshot', function () {
        return new Buffer(png, 'base64')
    }, 'image/png')()
}).catch((error: any) => console.log(error));
© www.soinside.com 2019 - 2024. All rights reserved.