cypress-mochawesome-reporter
cypress-mochawesome-reporter copied to clipboard
After migration of cypress and cypress-mochawesome-reporter, a reporter after:run event occurs
Environment
- OS: Red Hat Enterprise Linux release 8.4 and Windows 10
- Node: 14.16.0 and 16.15.1
- cypress-mochawesome-reporter: 3.2.0
- cypress: 10.3.1
What happened?
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.
Config file
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;
}
);
}
}
});
Relevant log output
cypress-mochawesome-reporter.log
Anything else?
No response
I'm having the same issue. Any idea on how to fix this?
override after:run
Start generate report process
Read and merge jsons from "reports\.jsons"
Screenshots folder "C:\xxxxxxx\top-level\cypress\reports\screenshots" not found, nothing to copy
An error was thrown in your plugins file while executing the handler for the after:run event.
The error we received was:
Error: Pattern reports\.jsons/*.json matched no report files
at C:\xxxxxxx\top-level\cypress\node_modules\mochawesome-merge\lib\index.js:14:11
at Array.map (<anonymous>)
at C:\xxxxxxx\top-level\cypress\node_modules\mochawesome-merge\lib\utils.js:3:46
at merge (C:\xxxxxxx\top-level\cypress\node_modules\mochawesome-merge\lib\index.js:82:17)
at mergeAndCreate (C:\xxxxxxx\top-level\cypress\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:12:24)
at generateReport (C:\xxxxxxx\top-level\cypress\node_modules\cypress-mochawesome-reporter\lib\generateReport.js:56:20)
at afterRunHook (C:\xxxxxxx\top-level\cypress\node_modules\cypress-mochawesome-reporter\lib\index.js:35:9)
at Object.handler (C:\xxxxxxx\top-level\cypress\cypress.config.js:24:15)
at invoke (C:\Users\P93003672-la\AppData\Local\Cypress\Cache\10.3.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:43:18)
at C:\Users\P93003672-la\AppData\Local\Cypress\Cache\10.3.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:59:14
Please create a repo with the problem and steps to reproduce the issue so I can have a look.
Thanks.
Hi @LironEr
I have made 2 tests
- the first is with a single and simple anuglar app: test-cypress-on-simple-angular-app.zip
In that case, the generation of the report working fine
- the secon is with an angular workspace with a lib and an app where cypress config file is only in the app test-cypress-on-workspace-angular-app.zip
In that case, the generation of the report failed
In summary: I think it is due to the folder configuration and the reporter doesn't really support any other folder than the default one (and it works previous version of cypress and reporter).
Based on the second test, I made a third test: I moved the cypress.config.ts to the workspace root and everything works. So is it a problem of the reporter or of cypress itself?
Hi @LironEr I have just test the fix and it seems it is working fine! Thanks a lot for your work!
Hi @LironEr thanks for the fix.
Released in v3.2.1
Thank you for the detailed issue, really helped me to understand the problem and how to solve it (: