
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
cypress-mochawesome-reporter
Advanced tools
Zero config Mochawesome reporter for Cypress with screenshots
Zero config Mochawesome reporter for Cypress with screenshots attached to tests.
reporter version | cypress version | reporter branch |
---|---|---|
v4 | node >= 22 >= 6.7.0 >= 6.2.0 with experimentalRunEvents: true | main |
v3 | node >= 14 >= 6.7.0 >= 6.2.0 with experimentalRunEvents: true | v3 |
v2 | >= 6.7.0 >= 6.2.0 with experimentalRunEvents: true | v2 |
v1 | >= 4.0.0 | v1 |
This setup tutorial works with Cypress >= v10, looking for older version setup? here
install cypress-mochawesome-reporter
npm i --save-dev cypress-mochawesome-reporter
or
yarn add -D cypress-mochawesome-reporter
Change cypress reporter & setup hooks
Edit config file (cypress.config.js
by default)
const { defineConfig } = require('cypress');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
},
},
});
If you are override before:run
or after:run
hooks, use this:
const { defineConfig } = require('cypress');
const { beforeRunHook, afterRunHook } = require('cypress-mochawesome-reporter/lib');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
on('before:run', async (details) => {
console.log('override before:run');
await beforeRunHook(details);
});
on('after:run', async () => {
console.log('override after:run');
await afterRunHook();
});
},
},
});
Add to cypress/support/e2e.js
import 'cypress-mochawesome-reporter/register';
(optional, if your are using cypress-cucumber-preprocessor
) Add to cypress/support/step_definitions/index.js
import 'cypress-mochawesome-reporter/cucumberSupport';
⚠️
cypress-cucumber-preprocessor
uses the same hooks ascypress-mochawesome-reporter
, you also need to install cypress-on-fix. Full example of usingcypress-mochawesome-reporter
withcypress-cucumber-preprocessor
can be found here.
run cypress
If you want to customize your HTML report with mochawesome-report-generator flags just add the flags you want to reporterOptions
const { defineConfig } = require('cypress');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
charts: true,
reportPageTitle: 'custom-title',
embeddedScreenshots: true,
inlineAssets: true,
saveAllAttempts: false,
},
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
},
},
});
Additional reporter options:
name | type | default | description |
---|---|---|---|
embeddedScreenshots | boolean | false | Embedded external screenshots into HTML using base64, use with inlineAssets option to produce a single HTML file |
ignoreVideos | boolean | false | Will not copy videos recorded by Cypress nor show them in the mochawesome report. Requires that Cypress config option video is set to true for the option to have any effectBecause mochawesome doesn't support context per spec file, each test will have the whole spec file video. More info can be found here |
videoOnFailOnly | boolean | false | If Videos are recorded and added to the report, setting this to true will add the videos only to tests with failures.Do note that this will NOT cause video's to only record failed tests, just they not be added to passed tests in the mochawesome report |
quiet | boolean | false | Silence console messages |
saveAllAttempts | boolean | true | Save screenshots of all test attempts, set to false to save only the last attempt |
debug | boolean | false | Creates log file with debug data |
saveJson | boolean | false | Keeps the json file used to create html report |
Add extra information to the report manually by using cy.addTestContext()
as seen in the simple-typescript example test 2
cypress-mochawesome-reporter
cypress-multi-reporters
mochawesome-report-generator
flagscypress.json
cypress-mochawesome-reporter
with typescriptcypress-mochawesome-reporter
with cypress-parallel
cypress-mochawesome-reporter
with cypress-cucumber-preprocessor
Run npm i
in root directory then:
cd examples/<example-project>
npm i
npm test
Mochawesome is a standalone reporter for Mocha tests that generates a visually appealing HTML report. It is similar to cypress-mochawesome-reporter but is not specifically designed for Cypress. It can be used with any Mocha-based testing framework.
Cypress-multi-reporters allows you to use multiple reporters for your Cypress tests. It can be used to combine different reporting formats, such as JSON and HTML, into a single test run. While it does not provide the same level of visual detail as cypress-mochawesome-reporter, it offers flexibility in combining different reporting tools.
Cypress-junit-reporter is a reporter that generates JUnit XML reports for Cypress tests. It is useful for integrating Cypress test results with CI/CD pipelines that require JUnit format. Unlike cypress-mochawesome-reporter, it focuses on XML output rather than HTML.
FAQs
Zero config Mochawesome reporter for Cypress with screenshots
The npm package cypress-mochawesome-reporter receives a total of 283,502 weekly downloads. As such, cypress-mochawesome-reporter popularity was classified as popular.
We found that cypress-mochawesome-reporter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.