我可以在摩卡超酷的html报告中添加柏树屏幕快照

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

我能够生成摩卡真棒html报告,但一切正常,但我想在html报告中添加屏幕快照,以cypress屏幕截图为例,但想添加html报告。有什么办法可以添加它们?

mocha cypress mochawesome
1个回答
0
投票

考虑mochawesome addContext。这将为报告注入任何价值。我相当确定生成的html报告将显示给定路径的图像。这可能需要进一步阅读addContext。

const { expect } = require('chai');
const addContext = require('mochawesome/addContext');

describe('Cypress tests.', function () {
  before(function () {
    // Perform Cypress things.
    // Take screenshots.
  };

  after(function () {
    const title = 'Screenshot of thing.';
    const value = 'path/to/screenshot.png';
    addContext(this, {
      title,
      value,
    };

  it('Foo should equal batz.', function () {
    // Expect some things.
  };
};
© www.soinside.com 2019 - 2024. All rights reserved.