mochawesome如何合并测试报告_详细报告Cypress / Mochawesome

Has anyone had much experience of generating good detailed reports from Cypress tests using Mochawesome as the report engine?

I've followed the info on the Mochawesome GIT page but what I get is rather dull!!

I'd like to be able to include the odd screen-shot and the output from the assertions - here's the current cypress.json file......

{

"projectId": "haw8v6",

"baseUrl": "https://obmng.dbm.guestline.net/",

"chromeWebSecurity": false,

"reporter" : "mochawesome",

"reporterOptions" : {

"reportFilename" : "DBM Smoke-Test",

"overwrite": true,

"inline": true

}

}

I've been toying with var addContext = require('mochawesome/addContext'); but with little joy.

Suggestions gratefully received.

Thanks

As per request below - very basic example of addContext

var addContext = require('mochawesome/addContext');

describe('DBM Smoketests', function() {

it('E2E Hotel2 WorldPay System', function() {

cy.visit('https://obmng.dbm.guestline.net/');

cy.url().should('include','/obmng.dbm');

addContext(this,'URL is correct');

//loads hotel 2

cy.get('.jss189 > div > .jss69 > .jss230').click();

解决方案

After much hacking about, I found a way to use Mochawesome addContext in Cypress.

Note, you can only make one addContext call per test (this is a Mochawesome limitation).

describe('DBM Smoketests', function() {

it('E2E Hotel2 WorldPay System', function() {

cy.visit('https://obmng.dbm.guestline.net/');

cy.url().should('include','/obmng.dbm');

Cypress.on('test:after:run', (test) => {

addContext({ test }, {

title: 'This is my context title',

value: 'This is my context value'

})

});

});

});

The second param is the context to be attached to the test, and it must have non-empty title and a value properties.

What you get in the mochawesome.json output is

...

"suites": [

{

...

"tests": [

{

"title": "E2E Hotel2 WorldPay System",

...

"context": "{\n \"title\": \"This is my context title\",\n \"value\": \"This is my context value\"\n}",

"code": "...",

...

}

],

In mochawesome.html, on clicking the test you get

Additional Test Context

This is my context title:

This is my context value

I have not tried it out with value types other than string.

Note for anyone starting out with Mochawesome in Cypress, it looks like you can only get a Mochawesome report with running cypress run, not with cypress open - although there may be a way around this using mocha's multiple reporter functionality.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值