-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress + Reporter Plugin in nested projects. Could not load reporter by name: reporter #4536
Comments
Also stumbled on the same issue! |
Same issue here. My cypress.json file:
Doing Actually installing mocha doesn't fix the issue at all. Halfway through the test run, I'm getting mocha related errors.
Is this because the version of mocha I am installing is independent from what Cypress and/or Mochawesome is using? This issue has been listed as fixed as of 3.0.0, but I'm on 3.4.0 and still getting it. #1192 Alright I'm going to try the fix authored by YOU54F, see if it works #3537 Actually just downgrading to Mocha 5.2 fixed the issue for me |
@Joelasaur the problem is because cypress tries to execute Mochawesome inside foo/node_modules. So I just write a workaround script to run cypress, to define the Mochawesome configuration on the script: const cypress = require('cypress');
const fs_extra = require('fs-extra');
const { merge } = require('mochawesome-merge');
const generator = require('mochawesome-report-generator');
const project = process.env.PROJECT;
const reportDir = `./results/${project}/reports`;
const mochawesome_options = {
'timestamp': false,
'reportDir': reportDir,
'overwrite': false,
'html': false,
'json': true
};
const cypress_options = {
config: {
'fileServerFolder': `./source/${project}`,
'fixturesFolder': `./source/${project}/cypress/fixtures`,
'integrationFolder': `./source/${project}/cypress/integration`,
'pluginsFile': `./source/${project}/cypress/plugins/index.js`,
'supportFile': `./source/${project}/cypress/support/index.js`,
'screenshotsFolder': `./results/${project}/screenshots`,
'videosFolder': `./results/${project}/videos`,
'video': false,
'reporter': 'mochawesome',
'reporterOptions': mochawesome_options
},
// spec: './source/foo/cypress/integration/examples/actions*.spec.js'
};
async function runTests() {
try {
await fs_extra.emptyDir(reportDir);
await cypress.run(cypress_options);
const jsonReport = await merge({ reportDir: reportDir });
await generator.create(jsonReport, mochawesome_options);
} catch (error) {
console.error(error);
} finally {
process.exit(0);
}
}
runTests(); The workaround also needs to have a And you can execute the project using This workaround solution is pushed on the project I written before https://github.com/danyfu/cy_mocha_awesome_nested_folders_tests |
Thanks for sharing @Danyfu but this workaround would mean having to rely on a run script and losing the ability to run default cli commands. Would be great if cypress could also search for |
@adamtay, You're right!. That's why I need to select the project to run cypress via node environment parameter. Having a node modules for each project can be an excessive amount of storage. |
We had the same issue with the {
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/cypress-teamcity-reporter",
"**/cypress-teamcity-reporter/**"
]
},
} |
Setting the relative path to mochawesome.js worked fine for me:
|
Cypress is doing something special here which is messing it up. The loader by default searches upwards and so naturally should work in nested projects. Looks as though it was the fix for #658 which breaks this. |
Actually no it was there much longer than that. It looks as though it has been that way for a long time, at least as far back as 98c4538 |
Current behavior:
Based on the project: https://github.com/cypress-io/cypress-test-nested-projects
I'm trying to use a reporter (In these case mochawesome)to generate report logs of my runs in cypress, but it always expected the reporter was installed inside the nested project so cypress never run the tests.
Image with the error that throw:
Here is a example repo where you can test this behavior: https://github.com/danyfu/cy_mocha_awesome_nested_folders_tests
Desired behavior:
Cypress runs with the desired reporter without the nested level of the project.
Steps to reproduce: (app code and test code)
Execute npm run cy:run:foo
This is what nested project
foo/cypress.json
has:Versions
cypress: ^3.3.1
Chrome: Version 74.0.3729.169 (Official Build) (64-bit)
OS: MacOS 10.14.5 (Mojave)
The text was updated successfully, but these errors were encountered: