How to add images to mochawesome report using Codeceptjs?

Viewed 2652

I'm doing E2E Tests on my own and I found really useful node libraries such as CodeceptJS, WebdriverIO and mocha (mochawesome).

Mochawesome permit to add images in the report but in the way that is explained in its docs with addContext https://www.npmjs.com/package/mochawesome doesn't work with CodeceptJS.

I didn't find any reference about this feature used in CodeceptJS, I only found a git request https://github.com/Codeception/CodeceptJS/issues/379

Is there a way to add images to mochawesome reported generated by mocha using CodeceptJS?

I have my file_test.js with one Before, one After and one Scenario. What I did is const addContext = require('mochawesome/addContext');

and than add the 'addContext(this,imagePath)' function but I get error

[mochawesome] Error adding context: Invalid test object.

2 Answers

I think the this object you're looking for is this.ctx in Codeceptjs.

Try with addContext(this.ctx, imagePath)

Related