lironer / cypress-mochawesome-reporter Goto Github PK
View Code? Open in Web Editor NEWZero config Mochawesome reporter for Cypress with screenshots and videos
License: MIT License
Zero config Mochawesome reporter for Cypress with screenshots and videos
License: MIT License
- OS: Mac 11.6
- Node: 16.5.0
- cypress-mochawesome-reporter: 3.0.0
- cypress: 9.5.2
I understand that mochawesome reporter doesn't work in parallel mode. Hence I didn't provide --reporter
command when running in parallel mode. But somehow I still get this error An error was thrown in your plugins file while executing the handler for the after:run event.
I would assume that since I didn't provide --reporter
option in run command line, reporter should not be generating or executing.
npx cypress run --config-file cypress/configs/desktopView.json --browser chrome --spec cypress/integration/404page.spec.js --headless --parallel --record --key XYZ --env grepTags=smoke,grepFilterSpecs=true,grepOmitFiltered=true
Cypress.json
{
"defaultCommandTimeout": 20000,
"retries": {
"runMode": 0,
"openMode": 0
},
"env": {
"FAIL_FAST_PLUGIN": true,
"FAIL_FAST_ENABLED": false
},
"trashAssetsBeforeRuns": false,
"videoUploadOnPasses": false,
"video": true,
"chromeWebSecurity": false
}```
=======================
desktopView.json
{
"extends": "./cypress.json",
"projectId": "b4gpwz",
"screenshotsFolder": "./cypress/screenshots/desktopView",
"videosFolder": "./cypress/videos/desktopView",
"integrationFolder": "./cypress/integration",
"ignoreTestFiles": [
"**/tracking/*.spec.js"
],
"viewportHeight": 800,
"viewportWidth": 1280,
"retries": {
"runMode": 0,
"openMode": 0
}
}
No response
No response
Is your feature request related to a problem? Please describe.
Upgraded from v1 of this and now getting additional logging which isn't wanted
Describe the solution you'd like
Be able to pass queit: true
into reporterOptions
to stop all logging
Describe alternatives you've considered
Additional context
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
I am using v1.3.0. Sorry if it is already implemented in newer version. What I am asking is if spec name can be included in its corresponding result page. At the moment, I see describe's string value as title.
Describe alternatives you've considered
Additional context
Is your feature request related to a problem? Please describe.
Option to convert screenshot to base64, combined with inlineAssets (reportOption) will be possible to generate a single html file and use in some platforms ( like Azure Dev Ops) with tools/extensions that support publish html reports (example: https://marketplace.visualstudio.com/items?itemName=LakshayKaushik.PublishHTMLReports)
Describe the solution you'd like
A report option (For example "ScreenshootToBase64".
Before call reportGenerator.create made this conversion in json files
Additional context
Let me know if this is a good feature, i like to contribute with a PR with this.
- OS: MacOS Monterrey
- Node: 14.18.1
- cypress-mochawesome-reporter: 3.1.0
- cypress: 10.2.0
We have been using Cypress version 9.7.0 with the cypress-mochawesome-reporter and everything is working great.
When upgrading Cypress to 10.2.0, the reporter is now unable to find our reports folder to run the merge feature and create the index.html report.
The Cypress tests run successfully, the screenshots and mochawesome*.json files all generate correctly and are put in the right place. It's just when the final step of generating the html report where there is a failure.
Are there configuration updates needed for the cypress-mochawesome-reporter with the new version of Cypress?
import { defineConfig } from 'cypress';
export default defineConfig({
viewportWidth: 1200,
viewportHeight: 900,
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
pageLoadTimeout: 100000,
reporter: 'cypress-mochawesome-reporter',
retries: {
runMode: 2,
openMode: 0,
},
reporterOptions: {
reportDir: 'cypress/reports',
charts: true,
reportPageTitle: 'Dev Test Suite',
embeddedScreenshots: true,
inlineAssets: true,
},
video: false,
screenshotsFolder: 'cypress/screenshots',
watchForFileChanges: false,
e2e: {
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('cypress-mochawesome-reporter/plugin')(on);
},
baseUrl: 'https://cdn-app-dev.drcedirect.com/',
},
});
Start generate report process
Read and merge jsons from "cypress/reports/.jsons"
options { files: [ 'cypress/reports/.jsons/*.json' ] }
An error was thrown in your plugins file while executing the handler for the after:run event.
The error we received was:
Error: Pattern cypress/reports/.jsons/*.json matched no report files
at ui/node_modules/mochawesome-merge/lib/index.js:15:11
at Array.map (<anonymous>)
at ui/node_modules/mochawesome-merge/lib/utils.js:3:46
at merge (ui/node_modules/mochawesome-merge/lib/index.js:84:17)
at mergeAndCreate (ui/node_modules/cypress-mochawesome-reporter/lib/generateReport.js:12:24)
at generateReport (ui/node_modules/cypress-mochawesome-reporter/lib/generateReport.js:56:20)
at afterRunHook (ui/node_modules/cypress-mochawesome-reporter/lib/index.js:35:9)
at Object.handler (ui/node_modules/cypress-mochawesome-reporter/plugin.js:9:11)
at invoke (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:43:18)
at /Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:59:14
at tryCatcher (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
at Object.wrapChildPromise (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:58:23)
at RunPlugins.execute (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:158:21)
at EventEmitter.<anonymous> (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:257:12)
at EventEmitter.emit (events.js:400:28)
at EventEmitter.emit (domain.js:475:12)
at process.<anonymous> (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
at process.emit (events.js:400:28)
at process.emit (domain.js:475:12)
at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/e/Library/Caches/Cypress/10.2.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:613:40)
at emit (internal/child_process.js:912:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
No response
- OS: ubuntu-latest
- Node: 14.19.0
- cypress-mochawesome-reporter: 6.2.0
- cypress: 9.6.1
Following error thrown when run tests in parallel mode in github workflow:
Error: Pattern /cypress/reports/html/.jsons/*.json matched no report files
"reporter": "cypress-mochawesome-reporter",
No response
No response
- OS: Windows 10
- Node: 16.13.1
- cypress-mochawesome-reporter: 3.2.0
- cypress: 9.6.0
Not able to skip screenshot copying in windows os when source and target of screenshot folder is same. Below is the error message -
An error was thrown in your plugins file while executing the handler for the after:run event.
The error we received was:
Error: Cannot copy 'C:\Users\XXXXXXX\XXXXXX\XXXXXX\cypress\results\AutomationReport_Mochawsome' to a subdirectory of itself, 'cypress\results\AutomationReport_Mochawsome\screenshots'.
at C:\Users\XXXXXXX\XXXXXX\XXXXXX\node_modules\cypress-mochawesome-reporter\node_modules\fs-extra\lib\util\stat.js:60:17
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Cypreess.json
====
{
"projectId": "XXXXXXX",
"env": {
"host" : "XXXXXXX"
},
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"reporterEnabled": "@reportportal/agent-js-cypress, cypress-mochawesome-reporter",
"reportportalAgentJsCypressReporterOptions": {
"autoMerge": "false",
"mode" : "trace",
"debug": true,
"restClientConfig":{
"timeout":3600000
},
"endpoint": "http://localhost:8080/api/v1",
"token": "XXXXXXXXXXXXXXXX",
"launch": "XXXXXXXXXXXXXX",
"project": "XXXXXXXXXXXXX",
"description": "XXXXXXX"
},
"cypressMochawesomeReporterReporterOptions": {
"reportDir": "cypress/results/AutomationReport_Mochawsome",
"charts": true,
"saveJson": true,
"embeddedScreenshots": false,
"inlineAssets": true,
"skipCopyingScreenshots": true,
"reportPageTitle": "CypressTests"
}
},
"screenshotsFolder" : "cypress/results/AutomationReport_Mochawsome",
"screenshotOnRunFailure":false,
"trashAssetsBeforeRuns" : true,
"overwrite": true,
"video" : false,
"chromeWebSecurity": false,
"author": "XXXXXXXXXXXX",
"license": "XXXXXXXXXX",
"retries": {
"runMode": 0,
"openMode": 0
},
"pageLoadTimeout" : 120000,
"numTestsKeptInMemory":0
}
An error was thrown in your plugins file while executing the handler for the after:run event.
The error we received was:
Error: Cannot copy 'C:\Users\XXXXXXX\XXXXXX\XXXXXX\cypress\results\AutomationReport_Mochawsome' to a subdirectory of itself, 'cypress\results\AutomationReport_Mochawsome\screenshots'.
at C:\Users\XXXXXXX\XXXXXX\XXXXXX\node_modules\cypress-mochawesome-reporter\node_modules\fs-extra\lib\util\stat.js:60:17
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Referred this issue, as per the PR, the issue is fixed but still not working in windows - #52
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
I would like an option to display percentage along side the pie chart, on top right of the report.
Describe alternatives you've considered
Display a bar of percentage of passed/failed tests.
Additional context
I have configured this plugin it worked fine the first time when I run the report
Later due to my framework configuration I have put the below code in plugin/index.js
module.exports = (on, config) => {
on('after:run', (results) => {
const exec = require('child_process').execSync
try{
exec('npx jrm cypress/mergedreport.xml ./cypress/reports/junit/*.xml');
}
catch(error){
console.log(error);
}
});
}
The above code is nothing to do with HTML reporters though, but final HTML is not getting generated because of the above code.
Kindly fix the bug. I was thinking to write a detailed article about multiple reporters using this plugin but this bug is stopping me.
So the issue here is if I override before:run and after:run to write some code this doesn't work
- OS: Ubuntu 20
- Node: 16.13.2
- cypress-mochawesome-reporter: latest
- cypress: 10
Cypress fails to run after loading require('cypress-mochawesome-reporter/plugin')(on)
.
import {defineConfig} from 'cypress';
const configuration = {
chromeWebSecurity: false,
defaultCommandTimeout: 30000,
execTimeout: 60000,
reporter: 'cypress-mochawesome-reporter',
retries: {
runMode: 2,
},
screenshotOnRunFailure: false,
taskTimeout: 60000,
video: false,
viewportWidth: 1280,
};
export default defineConfig({
...configuration,
e2e: {
baseUrl: 'http://localhost:3000',
env: {
API_BASE_URL: 'http://localhost:8080',
},
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
return require('./cypress/plugins/index.ts').default(on, config);
},
},
});
Your configFile is invalid: /home/runner/work/unstoppable-domains-website/unstoppable-domains-website/e2e/cypress.config.ts
It threw an error when required, check the stack trace below:
ReferenceError: Cypress is not defined
at Object.<anonymous> (/home/runner/work/unstoppable-domains-website/unstoppable-domains-website/node_modules/cypress-mochawesome-reporter/register.js:4:27)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .js] (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/ts-node/src/index.ts:1445:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/work/unstoppable-domains-website/unstoppable-domains-website/e2e/cypress.config.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/ts-node/src/index.ts:1455:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/ts-node/src/index.ts:1458:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadFile (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)
at EventEmitter.<anonymous> (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)
at EventEmitter.emit (node:events:390:28)
at EventEmitter.emit (node:domain:475:12)
at process.<anonymous> (/home/runner/.cache/Cypress/10.3.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
support/e2e.ts
import 'cypress-mochawesome-reporter/register';
import './commands';
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test.
return false;
});
beforeEach(() => {
// firebase uses indexDB to store logged in users.
void cy.clearIndexedDb();
cy.clearLocalStorage();
cy.clearCookies();
cy.task('db:seed');
});
- OS: Windows 10
- Node: 16
- cypress-mochawesome-reporter: 2.3.0
- cypress: 9.1.1
Nothing fancy: Followed your article https://liron-er.medium.com/cypress-html-reports-with-screenshots-made-easy-315a4c86c552, pretty basic stuff. I'm creating snapshots with
cy
.visit(path)
.matchImageSnapshot();
{
"reporter": "cypress-mochawesome-reporter"
}
====================================================================================================
(Run Starting)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cypress: 9.1.1 โ
โ Browser: Chrome 96 (headless) โ
โ Node Version: v16.13.0 (C:\Program Files\nodejs\node.exe) โ
โ Specs: 1 found (visual-regression.ts) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Remove output folder D:\git\the-company-directory\projecten\the-project-directory\src\cypress\reports\html
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Running: visual-regression.ts (1 of 1)
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
screenshots
1) should match for https://website.project-test.nl/paginatypen/formulier/uitgebreid-formulier/
โ should match for https://website.project-test.nl/paginatypen/tijdlijn/tijdlijn-opmaak-uitgebreid/
1 passing (14s)
1 failing
1) screenshots
should match for https://website.project-test.nl/paginatypen/formulier/uitgebreid-formulier/:
Error: Image was 0.04794551138901295% different from saved snapshot with 2147 different pixels.
See diff for details: D:\git\the-company-directory\projecten\the-project-directory\src\cypress\snapshots\visual-regression.ts\__diff_output__\screenshots -- should match for httpswebsite.project-test.nlpaginatypenformulieruitgebreid-formulier.diff.png
at Context.eval (https://website.project-test.nl/__cypress/tests?p=cypress\support\index.js:2055:17)
[mochawesome] Report JSON saved to D:\git\the-company-directory\projecten\the-project-directory\src\cypress\reports\html\.jsons\mochawesome.json
(Results)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tests: 2 โ
โ Passing: 1 โ
โ Failing: 1 โ
โ Pending: 0 โ
โ Skipped: 0 โ
โ Screenshots: 3 โ
โ Video: false โ
โ Duration: 14 seconds โ
โ Spec Ran: visual-regression.ts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(Screenshots)
- D:\git\the-company-directory\projecten\the-project-directory\src\cypress\snapshots\vis (1000x4478)
ual-regression.ts\__diff_output__\screenshots -- should match for httpswebsite.project-
test.nlpaginatypenformulieruitgebreid-formulier.diff.png
- D:\git\the-company-directory\projecten\the-project-directory\src\cypress\screenshots\v (1280x720)
isual-regression.ts\screenshots -- should match for httpswebsite.project-test.nlpaginat
ypenformulieruitgebreid-formulier (failed).png
- D:\git\the-company-directory\projecten\the-project-directory\src\cypress\snapshots\vis (1000x1467)
ual-regression.ts\screenshots -- should match for httpswebsite.project-test.nlpaginatyp
entijdlijntijdlijn-opmaak-uitgebreid.snap.png
Read and merge jsons from "D:\git\the-company-directory\projecten\the-project-directory\src\cypress\reports\html\.jsons"
Copy screenshots folder from "D:\git\the-company-directory\projecten\the-project-directory\src\cypress\screenshots" to "D:\git\the-company-directory\projecten\the-project-directory\src\cypress\reports\html\screenshots"
Enhance report
Create HTML report
HTML report successfully created!
D:\git\the-company-directory\projecten\the-project-directory\src\cypress\reports\html\index.html
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ร visual-regression.ts 00:14 2 1 1 - - โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ร 1 of 1 failed (100%) 00:14 2 1 1 - -
PS D:\git\the-company-directory\projecten\the-project-directory\src>
The snapshots and diff's do exist:
/cypress/snapshots/visual-regression.ts/__diff_output__/screenshots -- should match for httpswebsite.project-test.nlpaginatypenformulieruitgebreid-formulier.diff.png
/cypress/snapshots/visual-regression.ts/screenshots -- should match for httpswebsite.project-test.nlpaginatypenformulieruitgebreid-formulier.snap.png
/cypress/snapshots/visual-regression.ts/screenshots -- should match for httpswebsite.project-test.nlpaginatypentijdlijntijdlijn-opmaak-uitgebreid.snap.png
I'm unable to determine whether this package or mochawesome-report-generator is responsible, but someone else opened an issue there: adamgruber/mochawesome-report-generator#183
Hi, not sure if this is the correct place to ask this but are there any limitations\caveats with using this reporter when running tests in Cypress in parallel mode?
Can this reporter be made aware of report files across multiple nodes and know how to combine these?
Hi, is it possible to get video's embedded as links or something similar into the generated HTML report?
Thanks
After migration of cypress (from 9.2.1 to 10.3.1) and cypress-mochawesome-reporter (from 2.3.0 to 3.2.0), I get this error An error was thrown in your plugins file while executing the handler for the after:run event.
When I try the previous version, all is working fine but with last version, I don't understand how to fix this issue.
And I get this issue on my both environment.
cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
// Global
includeShadowDom: true,
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
reportDir: 'projects/switchboard-editor-app/cypress/report',
charts: true,
html: true,
json: true,
embeddedScreenshots: true,
inlineAssets: true,
debug: true
},
retries: {
runMode: 2,
openMode: 0
},
// Timeouts
defaultCommandTimeout: 15000,
// Folders / Files
fixturesFolder: 'projects/switchboard-editor-app/cypress/fixtures',
// Screenshots
screenshotsFolder: 'projects/switchboard-editor-app/cypress/screenshots',
// Videos
videosFolder: 'projects/switchboard-editor-app/cypress/videos',
video: false,
// Viewport
viewportWidth: 1280,
viewportHeight: 1024,
// e2e
e2e: {
baseUrl: 'http://localhost:4200/',
supportFile: 'projects/switchboard-editor-app/cypress/support/index.ts',
specPattern: 'projects/switchboard-editor-app/cypress/integration/*.ts',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setupNodeEvents: (on: Cypress.PluginEvents, config) => {
require('cypress-mochawesome-reporter/plugin')(on);
on(
'before:browser:launch',
(browser = {} as Cypress.Browser, launchOptions) => {
if (browser.family === 'chromium') {
const addIfNotPresent = (args: string[], arg: string): void => {
const index = args.indexOf(arg);
if (index < 0) {
args.push(arg);
}
};
const removeIfPresent = (args: string[], arg: string): void => {
const index = args.indexOf(arg);
if (index > -1) {
args.splice(index, 1);
}
};
removeIfPresent(launchOptions.args, '--disable-gpu');
addIfNotPresent(launchOptions.args, '--headless');
addIfNotPresent(launchOptions.args, '--use-gl=desktop');
addIfNotPresent(launchOptions.args, '--ignore-gpu-blocklist');
console.log(launchOptions.args);
}
return launchOptions;
}
);
}
}
});
cypress-mochawesome-reporter.log
No response
Is your feature request related to a problem? Please describe.
I need to Archive my reports with timestamps, i tried "overwrite": false in reporterOptions but it didn't work. as it is removing output folder before running tests
If you can stop removing output folder and control it with the help of overwrite flag, it will be great
How can I have multiple reporters? I want do add cypress-mochawesome-reporter, but I need to keep junit reporter for the corporate needs
- OS: Windows
- Node: 16.10.0
- cypress-mochawesome-reporter: 3.1.0
- cypress: 8.7.0
Trying to implement reports with embedded screenshots, but I'm receiving an error no such file or directory
on trying to read the screenshot file. I did some research myself and the paths set by the register.js
file are not correct on Windows. The Cypress config uses unix-like paths like ../../folder/where/screenshots/are
(because we run CI on Linux agents), but running it locally the incoming filenames have a Windows path with Windows path separators like ..\..\folder\where\screenshots\are
.
Inside method saveScreenshotReference
in register.js
you're roughly String.replace
-ing these both values, to get a relative path to the image file, without the value of screenShotFolder
. This replace
is simply not working on Windows, because the two values have no overlap because of the non-matching path separators.
It's fixable by using details.path.split('\\').join('/');
on the incoming filepath of the image, but then I would make the assumption given config paths are always unix-style, and I may be introducing other issues elsewhere. Hence the fact I didn't offer a PR, but opened an issue.
{
...,
"videosFolder": "../../dist/cypress/apps/my-app-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/my-app-e2e/screenshots",
"downloadsFolder": "../../dist/cypress/apps/my-app-e2e/downloads",
...
}
{
"reportFilename": "[datetime]-[status]-report",
"timestamp": "yyyy-mm-dd-HH:MM:ss",
"reportDir": "../../dist/cypress/apps/my-app-e2e/reports",
"charts": true,
"embeddedScreenshots": true,
"inlineAssets": true,
"debug": true
}
Start generate report process
Read and merge jsons from "..\..\dist\cypress\apps\my-app-e2e\reports\.jsons"
Enhance report
An error was thrown in your plugins file while executing the handler for the 'after:run' event.
The error we received was:
Error: ENOENT: no such file or directory, open '..\..\dist\cypress\apps\dist\cypress\apps\my-app-e2e\screenshots\test\test.spec.js\Suite -- Test (failed).png'
at Object.openSync (fs.js:498:3)
at Object.func [as openSync] (electron/js2c/asar_bundle.js:5:1846)
at Object.readFileSync (fs.js:394:35)
at Object.e.readFileSync (electron/js2c/asar_bundle.js:5:8872)
at convertImageToBase64 (\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:111:52)
No response
- OS: Windows 10
- Node: v16.13.0
- cypress-mochawesome-reporter: 8.1.0
- cypress: 8.1.0
I just cloned the repository, then launch npm install
in the simple repository.
After that I launch cypress via the npx cypress run
I got an error Error: Cannot find module 'fs-extra'
Retry everything, got the same error. Don't know what's going on here...
{
"reporter": "cypress-mochawesome-reporter",
"video": false,
"retries": 1,
"reporterOptions": {
"reportDir": "test-report",
"charts": true,
"reportPageTitle": "custom-title",
"embeddedScreenshots": true,
"inlineAssets": true,
"saveAllAttempts": false
}
}
Your pluginsFile is invalid: C:\Users\guest1810\Documents\TLPZ\Cypress samples\cypress-mochawesome-reporter\examples\mochawesome-flags\cypress\plugins\index.js
It threw an error when required, check the stack trace below:
Error: Cannot find module 'fs-extra'
Require stack:
- C:\Users\guest1810\Documents\TLPZ\Cypress samples\cypress-mochawesome-reporter\lib\index.js
- C:\Users\guest1810\Documents\TLPZ\Cypress samples\cypress-mochawesome-reporter\examples\mochawesome-flags\cypress\plugins\index.js
- C:\Users\guest1810\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js
- C:\Users\guest1810\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\plugins\child\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\guest1810\Documents\TLPZ\Cypress samples\cypress-mochawesome-reporter\lib\index.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\guest1810\Documents\TLPZ\Cypress samples\cypress-mochawesome-reporter\examples\mochawesome-flags\cypress\plugins\index.js:1:41)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
No response
Great works ๐
I would like to ask for a feature:
Is your feature request related to a problem? Please describe.
In our project, we are using the following config from cypress.json
file:
screenshotsFolder
videosFolder
This plugin should also take these configs into account together with cypress default and CLI arguments.
Describe the solution you'd like
cypress.json
filereporterOptions
(for mochawesome
) from cypress.json
Describe alternatives you've considered
Additional context
Is your feature request related to a problem? Please describe.
I want to reduce the number of generated files as there could be many screenshots taken during tests.
Describe the solution you'd like
when I put to cypress.json
"screenshotsFolder": "cypress/reports/html/screenshots"
then copying screenshots may be redundant, but the reporter is failing in that case:
Read and merge jsons from "/Users/krystian.panek/Projects/xxx/test/aem/functional/cypress/reports/html/.jsons"
Copy screenshots folder from "/Users/krystian.panek/Projects/xxx/test/aem/functional/cypress/reports/html/screenshots" to "/Users/krystian.panek/Projects/xxx/test/aem/functional/cypress/reports/html/screenshots"
An error was thrown in your plugins file while executing the handler for the 'after:run' event.
The error we received was:
Error: Source and destination must not be the same.
at /Users/krystian.panek/Projects/xxx/test/aem/functional/node_modules/cypress-mochawesome-reporter/node_modules/fs-extra/lib/util/stat.js:39:17
at cb (util.js:207:31)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
error Command failed with exit code 1.
how about adding the following option?
skipCopyingScreenshots: true // by default false
- OS: Ubuntu 22.04
- Node: 17.6.0
- cypress-mochawesome-reporter: 2.3.0
- cypress: 9.3.1
I noticed on the npm audit the next output
Inefficient Regular Expression Complexity in validator.js - GHSA-qgmg-gppg-76g5
No fix available
node_modules/validator
mochawesome-report-generator 1.1.1 - 5.2.0
Depends on vulnerable versions of validator
Depends on vulnerable versions of yargs
node_modules/mochawesome-report-generator
cypress-mochawesome-reporter *
Depends on vulnerable versions of mochawesome-report-generator
node_modules/cypress-mochawesome-reporter
mochawesome 2.1.0 - 6.3.1
Depends on vulnerable versions of mochawesome-report-generator
node_modules/mochawesome
{
"viewportHeight": 1080,
"viewportWidth": 1920,
"component": {
"viewportHeight": 1024,
"viewportWidth": 1280
},
"ignoreTestFiles": "**/*.md",
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/reports",
"charts": true,
"reportPageTitle": "STC App Team Checklist",
"embeddedScreenshots": true,
"inlineAssets": true
},
"video": false
}
No response
No response
Hi, the report is not able attach failed screenshots when the spec file contains embedded "describe ". please see below example
describe("Cypress Testing", () => {
describe('Test scenario', function () {
it('positive testing', function () {
cy.log("test ");
});
});
Using "cypress": "7.7.0", and "cypress-mochawesome-reporter": "3.0.0"
Codebase Github link: CypressUIAutomation
Is your feature request related to a problem? Please describe.
I use the plugin @cypress/webpack-preprocessor to convert typescript to javascript.
After I run my tests, a report is created for me that contains the transpiled Javascript.
cy.login(_support_testmodel__WEBPACK_IMPORTED_MODULE_0__["default"].visitUrl);
cy.wait('@legalDataRequest').then(function () {
_support_testmodel__WEBPACK_IMPORTED_MODULE_0__["default"].editChairman();
_support_testmodel__WEBPACK_IMPORTED_MODULE_0__["default"].submitForm();
_support_testmodel__WEBPACK_IMPORTED_MODULE_0__["default"].validateEditedChairmanValue();
});
Dependencies:
{
"cypress": "8.3.1",
"cypress-mochawesome-reporter": "^2.3.0",
"@cypress/webpack-preprocessor": "5.9.1"
}
Is there a way to display the actual typescript code?
cy.login(testmodel.visitUrl);
cy.wait('@legalDataRequest').then(function () {
testmodel.editChairman();
testmodel.submitForm();
testmodel.validateEditedChairmanValue();
});`
Describe the bug
failed test screenshot is missing in final html report but normal screenshot attached by default'
Expected behavior
Html report must include failed screenshot as well
Environment
cypress-mochawesome-reporter
version: <2.0.1>
cypress
version: <6.5.0>
Describe the bug
After upgraded to Cypress 7.1.0 I get an error (see below)
Rolling back Cypress to 7.0.1 things work again.
Expected behavior
Should work as before.
Environment
cypress-mochawesome-reporter
version: 2.0.1
cypress
version: 7.1.0
Additional context
jpriest@home : ~/www/cypress (master *=)$ npx cypress run --headless --spec "cypress/integration/foo/bar.spec.js"
The function exported by the plugins file threw an error.
We invoked the function exported by `/Users/jpriest/www/cypress/cypress/plugins/index.js`, but it threw an error.
Error: Cannot find module 'cypress-mochawesome-reporter/lib'
Require stack:
- /Users/jpriest/www/cypress/cypress/plugins/index.js
- /Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
at Module._load (internal/modules/cjs/loader.js:732:27)
at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at module.exports (/Users/jpriest/www/cypress/cypress/plugins/index.js:21:2)
at /Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:90:12
at tryCatcher (/Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
at load (/Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:87:7)
at EventEmitter.<anonymous> (/Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:198:5)
at EventEmitter.emit (events.js:315:20)
at process.<anonymous> (/Users/jpriest/Library/Caches/Cypress/7.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
at process.emit (events.js:315:20)
at emit (internal/child_process.js:903:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
I'm not sure if this is an issue or intended behaviour, if so, then i was not able to find how to change configuration to get it working again. See below screenshots and then related content from files: plugins\index.js: and support\index.ts:
Actual report:
Report generated with version 2.2.1:
plugins\index.js:
module.exports = (on, config) => { require('cypress-mochawesome-reporter/plugin')(on);};
support\index.ts:
import 'cypress-mochawesome-reporter/register';
import addContext from "mochawesome/addContext";
Cypress.Screenshot.defaults({screenshotOnRunFailure: false,});
function generateScreenshotName(test) {
const MAX_SPEC_NAME_LENGTH = 220;
return [test.fullTitle().slice(0, MAX_SPEC_NAME_LENGTH)," (failed) ",test.hookName,]
.filter(Boolean)
.join("")
.trim();
}
afterEach(function() {
if (this.currentTest.state === "failed") {
cy.screenshot(generateScreenshotName(this.currentTest), {
capture: "runner",
});
}
});
Cypress.on("test:after:run", (test, runnable) => {
if (test.fail == true) {
addContext({ test }, ${generateScreenshotName(runnable)}.png
);
}
return;
});
Describe the bug
by giving as 'reportDir' option another value than the default one, (aka cypress/reports). report auto-generation fails
As an example, I put "reportDir": "./results/html"
And the, at the end of the execution :
Read and merge jsons from "results\html\.jsons"
An error was thrown in your plugins file while executing the handler for the 'after:run' event.
The error we received was:
Error: Pattern results\html\.jsons/*.json matched no report files
and yes i confirm,
mochawesome.json files are generated inside cypress/reports/html/.jsons
folder*
Expected behavior
I think it may generate mochawesome*.json in a folder according to reportDir
option, not using a 'default value'
Environment
....
+-- @nrwl/[email protected]
+-- @nrwl/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
....
cypress.json
:
{
... other config here ...
"reporter": "../node_modules/cypress-multi-reporters",
"reporterOptions": {
"reporterEnabled": "../node_modules/cypress-mochawesome-reporter, ../node_modules/mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "./results/junit/results-[hash].xml",
"testsuitesTitle": "Reporting-UI"
},
"cypressMochawesomeReporterReporterOptions": {
"charts": true,
"reportPageTitle": "Reporting-UI",
"embeddedScreenshots": true,
"reportDir": "./results/html"
}
}
}
We donot see json files of results, is it possible to post execution results to slack?
- OS: Windows10
- Node: v16.14.2
- cypress-mochawesome-reporter: 3.2.0
- cypress-image-snapshot: 4.0.1
- cypress: 8.5.0
The path for the embedded snapshots seems to be wrong:
C:\screenshotsFolder\C:\full\path\to\snapshots...>
This leads to the error:
Error: ENOENT: no such file or directory, open 'C:\Users\stephanm\Projects\ConfigEditor\E2E\screenshots\C:\Users\stephanm\Projects\ConfigEditor\E2E\snapshots\process-flow\story273618\tc289099.spec.js_diff_output_\289099 [SUTC] Template visualization - SaveResetCancel -- 289099 [SUTC] Template visualization - SaveResetCancel (failed).diff.png'
I guess the path.join(screenshotsDir, imagePath); in enhanceReport.js convertImageToBase64() is wrong/ unnessary
This wrong joinment of the path doesn't matter if the screenshotsDir and the starting of the imagePath are equal, like it is for normal screenshots. But for snapshots, where the paths are different, it fails.
cypress.json:
{
"baseUrl": "http://localhost:4200",
"chromeWebSecurity": false,
"testFiles": "**/*.spec.js",
"video": false,
"screenshotsFolder": "screenshots",
"downloadsFolder": "downloads",
"viewportWidth": 1700,
"viewportHeight": 950,
"watchForFileChanges": false,
"defaultCommandTimeout": 15000,
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporter.json"
},
"env": {
"coverage": false
},
"retries": {
"runMode": 0,
"openMode": 0
}
}
reporter.json:
{
"reporterEnabled": "cypress-mochawesome-reporter, mocha-junit-reporter, cypress-image-snapshot/reporter",
"cypressMochawesomeReporterReporterOptions": {
"reportDir": "reports",
"charts": true,
"reportPageTitle": "E2E Tests",
"embeddedScreenshots": true,
"debug": true,
"inlineAssets": true,
"outputs": true
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "reports-ci/junit/results-[hash].xml",
"attachments" : true,
"outputs" : true,
"consoleTo": true
}
}
(Screenshots)
- C:\Users\stephanm\Projects\ConfigEditor\E2E\snapshots\process-flow\story273618\t (1280x720)
c289099.spec.js\__diff_output__\289099 [SUTC] Template visualization - SaveReset
Cancel -- 289099 [SUTC] Template visualization - SaveResetCancel (failed).diff.p
ng
override after:run
Start generate report process
Read and merge jsons from "reports\.jsons"
Enhance report
An error was thrown in your plugins file while executing the handler for the after:run event.
The error we received was:
Error: ENOENT: no such file or directory, open 'C:\Users\stephanm\Projects\ConfigEditor\E2E\screenshots\C:\Users\stephanm\Projects\ConfigEditor\E2E\snapshots\process-flow\story273618\tc289099.spec.js\__diff_output__\289099 [SUTC] Template visualization - SaveResetCancel -- 289099 [SUTC] Template visualization - SaveResetCancel (failed).diff.png'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at convertImageToBase64 (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:111:52)
at C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:104:11
at Array.map (<anonymous>)
at createScreenshotsContextList (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:100:22)
at attachScreenshotsToTestContext (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:76:9)
at C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:34:24
at Array.forEach (<anonymous>)
at C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:32:19
at Array.forEach (<anonymous>)
at attachScreenshotsToSuiteTestsContext (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:31:12)
at C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:16:7
at Array.forEach (<anonymous>)
at enhanceReport (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:6:18)
at mergeAndCreate (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:19:3)
at async Promise.all (index 0)
at async generateReport (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:62:22)
at async afterRunHook (C:\Users\stephanm\Projects\ConfigEditor\E2E\node_modules\cypress-mochawesome-reporter\lib\index.js:35:3)
at async Object.handler (C:\Users\stephanm\Projects\ConfigEditor\E2E\cypress\plugins\index.js:127:5)
the same error happens also on the server CI
Error: ENOENT: no such file or directory, open '\\XXX.com\esroadmap\GUIDev\TestResults\FE\E2E\683650_merge\e2e_ci-processflow\XXX.com\esroadmap\GUIDev\TestResults\FE\E2E\683650_merge\snapshots\process-flow\story273618\tc289097.spec.js\TC289097.snap.png'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at convertImageToBase64 (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:111:52)
at D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:104:11
at Array.map (<anonymous>)
at createScreenshotsContextList (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:100:22)
at attachScreenshotsToTestContext (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:76:9)
at D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:34:24
at Array.forEach (<anonymous>)
at D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:32:19
at Array.forEach (<anonymous>)
at attachScreenshotsToSuiteTestsContext (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:31:12)
at D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:16:7
at Array.forEach (<anonymous>)
at enhanceReport (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\enhanceReport.js:6:18)
at mergeAndCreate (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:19:3)
at async Promise.all (index 0)
at async generateReport (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:62:22)
at async afterRunHook (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\node_modules\cypress-mochawesome-reporter\lib\index.js:35:3)
at async Object.handler (D:\Apps\Agents\esconfig-test-agent4\_work\334\s\E2E\cypress\plugins\index.js:127:5)
If I remove the path.join then Snapshots work fine and are embedded
function convertImageToBase64(screenshotsDir, imagePath) {
// const imgPath = path.join(screenshotsDir, imagePath);
const contents = 'data:image/png;base64, ' + fse.readFileSync(imagePath, { encoding: 'base64' });
return contents;
}
But then Screenshots doesn't work due to the normalized screenshot path in register.js
const normalizedScreenshotPath = details.path.replace(screenshotsFolder, '');
It only works for me if I remove the replacement of the screenshotFolder in register.js and the path.join in enhanceReport.js
function saveScreenshotReference(details) {
const normalizedScreenshotPath = details.path;// .replace(screenshotsFolder, '');
const title = normalizedScreenshotPath.includes('(failed)') ? 'Failed screenshot' : 'Screenshot';
if (!Cypress.Mochawesome) {
Cypress.Mochawesome = createMochawesomeObject();
}
Cypress.Mochawesome.currentAttemptScreenshots.push({ title, value: normalizedScreenshotPath });
}
Is your feature request related to a problem? Please describe.
The HTML target report directory is hard-fixed to cypress/reports/html
but I want to specify a custom one.
Describe the solution you'd like
Specify the directory where HTML report file is written by an option in reporter config (outputFolder
for example).
Describe alternatives you've considered
I don't have alternatives as long as I know.
Environment
cypress-mochawesome-reporter version: 1.3.0
cypress version: 6.7.1
Additional context
(My environment is in WSL2 and Node Docker image)
Hi Team, I want to include the total test count, passed count and failed count in a email . i am triggering the cypress test from a jenkins/gitlab pipeline
I am unable to access index.json created by mochawesome reporter which i want to parse to draft the email
I have the following setting in cypress.json
file:
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"saveJson": false
},
I see this message in Jenkins' console log: [mochawesome] Report JSON saved to /tmp/jenkins/workspace/ession-Cypress_parallelExecution/cypress/cypress/reports/desktopView/.jsons/mochawesome.json
Hi,
Thanks so much for the plugin! We just start using the plugin recently and it works pretty well! The only one bug that I found is that when the error is thrown on test hook (before
, after
etc), the link to the screenshot is incorrect because cypress decided to append name like -- after all hook (failed).png
to the file name. Would you accept a PR to fix the issue? Thank you!
Describe the bug
overwrite
flag is ignored since the output directory is cleared before every run
Expected behavior
Expect results to continue to be added to the results directory without being deleted first.
Environment
cypress-mochawesome-reporter
version: 2.1.1
cypress
version: 7.5.0
Please run this command inside your project and paste its contents here (it automatically copies to your clipboard)
npx envinfo --system --binaries --markdown | npx clipboard-cli
Need to install the following packages:
envinfo
Ok to proceed? (y)
Additional context
Describe the bug
When generate report, the config file cypress.json
is parsed to take account of reporter options, looking for special keys reporterEnabled
and cypressMochawesomeReporterReporterOptions
to be compliant with cypress-multi-reporter
reporter, but completely ignore configuration if the real cypress-multi-reporter
reporter config file is relocated with configFile
option.
Expected behavior
When generate report, this reporter is fully compatible with cypress-multi-reporter
reporter options and take account of relocated config file specified with configFile
option key.
Environment
cypress-mochawesome-reporter
version: 1.3.0
cypress
version: 6.7.1
Please run this command inside your project and paste its contents here (it automatically copies to your clipboard)
npx envinfo --system --binaries --markdown | npx clipboard-cli
Additional context
(My environment is in WSL2 and Node Docker image)
According to the documentation, it's possible to add test context to Mochawesome reports: https://github.com/adamgruber/mochawesome#adding-test-context
So I tried to do it on top of cypress-mochawesome-reporter
as described in Mochawesome README. But it does nothing.
Could it be possible to have a way to add test context?
Thank you very much for your help ๐
Versions that don't work.
- OS: Mac 11.6
- Node: 16.5.0
- cypress-mochawesome-reporter: 3.0.0
- cypress: 9.7.2
- mochawesome: 7.1.2
Versions that works
- OS: Mac 11.6
- Node: 16.14.0
- cypress-mochawesome-reporter: 2.3.0
- cypress: 9.7.2
- mochawesome: 6.3.1
Please see the issue I logged with mochawesome. I am not sure who is the culprit.
The config file below is the working versions one. See Environment section for non-working versions.
{
"name": "automation-testing",
"version": "1.0.0",
"description": "Automation Testing using js",
"main": "index.js",
"scripts": {
"test": "cypress"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.12.1",
"cypress": "9.5.2",
"cypress-fail-fast": "3.4.1"
},
"dependencies": {
"@babel/core": "7.11.6",
"chai": "4.2.0",
"chai-string": "^1.5.0",
"cypress-file-upload": "5.0.5",
"cypress-localstorage-commands": "1.7.0",
"cypress-mochawesome-reporter": "2.3.0",
"cypress-terminal-report": "^2.2.0",
"deepmerge": "^4.2.2",
"lodash": "^4.17.21",
"lodash.clonedeep": "4.5.0",
"mocha": "9.2.2",
"mochawesome": "6.3.1",
"path": "^0.12.7",
"uuid": "^8.3.0"
}
}
No response
No response
When I try to install this package its giving
"npm ERR! code Unknown system error -83npm ERR! code Unknown system error -83"
My node version is 12.18.1
- OS: Windows 11
- Node: 16.16
- cypress-mochawesome-reporter: 3.2.2
- cypress: 10.6.0
When a test fails and the HTML report is generated, even when the reporter option 'embeddedScreenshots' is set to true the image in the HTML report is just a link.
I was under the impression that the screenshot would be added to the HTML report file as a Base64 string.
Let me know if there is any other information you need. Thanks
If using my project, run yarn install
then run yarn cy:runExample
See example report:
report_file_example.zip
Here is the full example project if it's any help:
CypressE2Ev10-Example.zip
cypress.config.js contents:
const { defineConfig } = require('cypress');
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
})
)
require('cypress-mochawesome-reporter/plugin')(on);
return config;
}
module.exports = defineConfig({
e2e: {
setupNodeEvents,
specPattern: '**/*.feature',
excludeSpecPattern: '*.js',
supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
watchForFileChanges: true,
baseUrl: 'https://www.npmjs.com/',
fullUrl: 'https://www.npmjs.com/package/cypress-mochawesome-reporter'
},
reporter: 'cypress-multi-reporters',
reporterOptions: {
reporterEnabled: "cypress-mochawesome-reporter, spec, mocha-junit-reporter",
cypressmochawesomereporterOptions: {
reportDir: "cypress/reports/html",
charts: true,
reportPageTitle: "Cypress E2E Tests",
embeddedScreenshots: true,
inlineAssets: true,
saveAllAttempts: false,
saveHtml: true,
reportTitle: "Cypress E2E Tests"
},
mochaJunitReporterReporterOptions: {
mochaFile: "test-report-xml/results-[hash].xml"
}
},
chromeWebSecurity: false,
experimentalSourceRewriting: false,
video: false,
screenshotsFolder: 'cypress/reports/html/screenshots',
modifyObstructiveCode: true,
pageLoadTimeout: 120000,
defaultCommandTimeout: 30000,
});
No response
No response
- OS: Win 10
- Node: 12.17.0
- cypress-mochawesome-reporter: 2.3.0
- cypress: 7.5
I found onAfterScreenshot
only work after a non-failure screenshot is taken
so on v2.3.0, the reporter will not handle the screenshot which is taken by Cypress automatically when there is a failure
the function saveScreenshotReference
will not run
// lib/enhanceReport.js attachScreenshotsToTestContext
const screenshotsContextIndex = parsedContext.findIndex(
(c) => typeof c === 'object' && c.value && c.title === 'cypress-mochawesome-reporter-screenshots' // โ this will not work
);
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"saveJson": true,
"embeddedScreenshots": true
},
No response
No response
Describe the bug
Using version 2.1.1, I get this error when running npm run cypress:report
. Works fine for 1.3.0.
Extract from "/.npm/_logs/2021-06-15T22_29_08_472Z-debug.log"
10 silly lifecycle [email protected] cypress:report: Args: [ '-c', 'generate-mochawesome-report' ]
11 info lifecycle [email protected] cypress:report: Failed to exec cypress:report script
12 verbose stack Error: [email protected] cypress:report:generate-mochawesome-report
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:315:20)
12 verbose stack at maybeClose (internal/child_process.js:1021:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
15 verbose Darwin 20.1.0
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cypress:report"
17 verbose node v12.18.4
18 verbose npm v6.14.10
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error [email protected] cypress:report:generate-mochawesome-report
23 error spawn ENOENT
24 error Failed at the [email protected] cypress:report script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Expected behavior
Environment
cypress-mochawesome-reporter
version: <VERSION>
cypress
version: <VERSION>
Please run this command inside your project and paste its contents here (it automatically copies to your clipboard)
npx envinfo --system --binaries --markdown | npx clipboard-cli
Additional context
Is it possible to add reporter options like --charts? if not, will be supported soon?
Hello ๐ I'm writing on behalf of the Cypress DX team. We wanted to notify you that some changes may need to be made to this plugin to ensure that it works in Cypress 10.
For more information, here is our official plugin update guide.
"devDependencies": {
"cypress-mochawesome-reporter": "^2.3.0",
"mocha": "^9.2.0"
},
"dependencies": {
"cypress": "^3.3.2",
"cypress-cucumber-preprocessor": "^4.3.1",
"cypress-multi-reporters": "^1.5.0",
"junit-report-merger": "^3.0.2",
"mocha-junit-reporter": "^2.0.2",
"node": "^17.0.1"
},
When i run a test only a json file put into the report folder
{
"projectId": "9zqwhi",
"defaultCommandTimeout": 12000,
"pageLoadTimeout": 16000,
"testFiles": "**/*.{feature,features,js}",
"env": {
"url": "https://www.kapu.hu/"
},
"screenshotOnRunFailure": true,
"video": false,
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/report",
"charts": true,
"reportPageTitle": "citle",
"embeddedScreenshots": true
}
}
No response
No response
- OS: Windows 10 enterprise
- Node: v14.15.0
- cypress-mochawesome-reporter: 3.0.1
- cypress: 8.7.0
The issue is related to the
cypress-mochawesome-reporter: { "version": "3.0.1"}
this version has a strict check for the reporter name in the config.js file, see the code here
if (config.reporter === 'cypress-mochawesome-reporter') { return opts; }
It is a failing and logging a message that "cypress-mochawesome-reporter is not an active reporter" since we are providing the path of the package in our node module.
I am only using this reporter.
However, due to our project setup, we need the flexibility to pass the reporter value as a path along with the package name.
such as,
"reporter": "../../node_modules/cypress-mochawesome-reporter",
see the cypress.json file set up here
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": false,
"videosFolder": "../../cypress-reports/videos",
"screenshotsFolder": "../../cypress-reports/screenshots",
"chromeWebSecurity": false,
"reporter": "../../node_modules/cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "../../cypress-reports",
"embeddedScreenshots": true,
"overwrite": false,
"charts": true,
"showSkipped": true,
"saveJson": true
}
}
cypress-mochawesome-reporter is not the active reporter, ignore before run hook.
cypress-mochawesome-reporter is not the active reporter, ignore after run hook.
It should not be failing if we pass the path of the package as reporter.
The issue:
Currently I'm trying to implement Cypress and Testrail integration. In order to do that, I am planning to use this reporter. But as long as cypress-mochawesome-reporter delete the initial json files with the results, I'm unable to continue.
Question/Feature I'd like to see:
Any way how I can save both the html report and initial json files?
Thanks in advance!
Is your feature request related to a problem? Please describe.
Hello, excellent library ๐
In cypress there is this thing called Test Retries, where if a test failes, it will automatically try again. It will take a screenshot for every failed attempt. At the moment I'm only seeing the last attempt screenshot, however in some tests the state has changed so the retry will fail because of a different reason. Would it be possible to include the screenshots from every try?
Describe the solution you'd like
Lets say I have "retries": 2,
in my config, I would like the see included in the html file the original, attempt 1 and attempt 2 screenshots.
Currently I think the reporter only attach screenshots for failed tests, I think would be helpful to add the screenshots for passed tests that are taken on the fly as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.