YOU54F / cypress-multi-reporters

A maintained fork of mocha-multi-reporters compatible with mocha 6+ and below
MIT License
74 stars 6 forks source link

Monorepo's force redundant installations #137

Closed spicemix closed 1 year ago

spicemix commented 3 years ago

Expected behavior

Finds cypress-multi-reporters in any package.json/node_modules anywhere higher in the enclosing directories. Even if a package.json or node_modules is found, keep searching upwards in enclosing directories.

Actual behavior

Could not load reporter by name: cypress-multi-reporters

We searched for the reporter in these paths:

Information about the Issue

In monorepos (such as those made by @nrwl/nx that I am using) the tendency is to place shared dependencies in a top-level package.json so they don't have to be duplicated all over the place. cypress-multi-reporters can't find them there, because I have a cypress folder for each app in the monorepo, now each of those needs its own node_modules with redundant copies of cypress-multi-reporters to install and maintain for each.

Steps to reproduce the behavior

  1. Build an Nx-angular monorepo with cypress e2e
  2. install cypress-multi-reporters in the top level package.json
  3. Try to get reports working

And while I'm here allow me to strongly second the feature request of including config in the cypress.json rather than forcing CLI use. Thanks for this handy tool!

YOU54F commented 3 years ago

Hey hey @spicemix , thanks for the report!

I've not used nrwl, but I have heard of it as members of the pact community were asking for support for it too.

Do you have a sample repo you could spin up to reproduce the issue, as it will provide a good playground to provide support.

Even better if you would be keen to make a pull request!

Also I can't take credit for the majority of the code, as I only forked it to update it for later versions of mocha. The original package has been updated, and you may or may not wish to raise the issue there https://github.com/stanleyhlng/mocha-multi-reporters

spicemix commented 3 years ago

Thanks @YOU54F nice response though after I filed this I had enough trouble getting all of these things working I bailed for the time being. If I get back into it I will be sure to follow-up. Monorepos are new to me as well, but are getting very popular so I probably won't be the last! It's possible to work around this in a bunch of ways.

YOU54F commented 3 years ago

No worries @spicemix ! I know the feeling, stuff always gets in the way.

Well free free to mash cobble together whatever you have a stick a link up and if i'm at a loose end I may take a nosey.

cmcnicholas commented 3 years ago

seconded for monorepo support, we have moved to an 18 project (and growing) solution now and are encountering this issue, workaround is to specify a relative path in the cypress config e.g.

{
  // cypress.json
  "reporter": "../../node_modules/cypress-multi-reporters",
  "reporterOptions": {
    "configFile": "reporter-config.json"
  }
}

https://github.com/DKnA/cypress-junit-reporter does work in a monorepo environment so maybe that could allude to changes needed to support this?

YOU54F commented 1 year ago

Will be archiving this repo today, thanks for the issue raising

Code is now held here https://github.com/YOU54F/cypress-plugins/tree/master/cypress-multi-reporters