-
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 and cypress-multi-reporters Yarn 2 PNP support #18922
Comments
@flotwig - mind taking a quick glance at this? I see you worked on #8008, so I have to imagine you know more here than my "looking up what is Yarn PNP". It looks like while we support pnp as part of our standard webpack config, we may not support it for loading custom reporters - does that sound right? |
That's what it seems like, yeah. cypress/packages/server/lib/reporter.js Lines 530 to 554 in 0b5f451
And this code path is not PNP aware. Needs to be made aware of yarn v2's PNP resolver when launched using yarn v2. Similar to #15623 's approach. |
Hi @flotwig , thank you for having look at it. Following the approach of #15623 I've tried to change the line p = path.resolve(projectRoot, reporterName) with p = require.resolve(reporterName, { paths: [projectRoot] }) but unfortunately it seams that it is not working. It looks like that yarn is not able to inject the PnP implementation of "require.resolve" when that code is executed. I don't know if it makes sense since I don't know the internals of cypress, but I suspect that is because this code is executed in the cypress server, and yarn calls the cypress CLI, so somehow the PNP implementation or require.resolve is lost when we pass from cypress CLI to cypress server. Please let me know if you see any way or workaround to fix it, or if I can provide any other debug information. Thank you, |
Hi @flotwig I finally realized that my fix actually works if the Fix is the PR: #19233 |
The same issue affects me using Cypress in a monorepo with hoisting, but without cypress being run from the root. (without using PnP) e.g. Cypress at
My workaround is to create a custom reporter which just re-exports the reporter
This |
Is there any movement on this? |
PINGing with same question as above ... latest node & cypress, using typescript |
Similar to @lexanth we also run @kubijo Our workaround is to create the symlink ourselves before executing cypress tests. We're only executing on linux, so we've added the following script to our
Depending on your local folder structure, you may need to change the path (and probably have a test command with more parameters). We'd still love an official fix for this issue, as this workaround is undesirable. |
Thank you for the help, @ImSaSu, but we're standing firmly in the PnP linker land & of conviction that this should not be that much of a hassle to fix since, for example, |
I also have this issue with yarn workspaces, cypress still looks for the reporter in package's node_module, however yarn has hoisted the reporter package to the root node_module. |
The workaround I am using for this is to just use the relative path to the module. So instead of You could probably also work around this by doing Obviously this is hideous but 🤷 |
There have been attempts for pnp support in the 12.10.0 patch, but I still have issues on the reporter side. Looking at the Cypress internal code, I don't think there's a proper way to fix this outside of cypress. |
This is the same issue as #25960. The fix should be the same, too - what needs to happen is before The reason the fix in #25960 didn't apply here is the This is not possible in userland, I think we need to make a PR here. Luckily it should be easy, since you can just reuse the code I wrote in #26452. If anyone would like to make a PR to this meaning, that'd be great. I can review it, along with some others from the Cypress team. What you'll need to do is add a line or two above here that does the same thing I do in this PR. You should be able to import the methods from @sfsepark would you be interested in making a PR? I can help with adding a test, if you want to pull the repo down, run |
Hello everyone, is someone currently working on this? If not, I could try following @lmiller1990 suggestions (no promises). |
Hi @lmiller1990 I noticed that your commit have been reverted (#26735), so I cannot import your utilities. Will try to replicate your fix by adding the utilities again, but inside the server package. |
Hello everyone, I created this draft PR (#28404), but I am not able to try if it works (see the comment I wrote there). @lmiller1990 would you be able to help writing some tests? I had to turn your utils synchronous because if not the whole process had to become asynchronous and I don't know what impacts it could have elsewhere. |
Hey @ernestostifano - I'm not working on Cypress now, and probably won't be able to prioritize reviewing this one at this point... I'd recommend tagging some contributors who have recently committed to I hope this can get reviewed - Yarn PNP support would be nice. Have you successfully built a Cypress binary from your branch to test it locally? My understanding is the main issues occur once you do a |
@lmiller1990 thanks for your response! I completely understand. I will try building the binary, sounds like a good idea. Thanks! |
Current behavior
After migrating my project to Yarn PNP, cypress is not able anymore to find cypress-multi-reporters, giving the following error message:
Desired behavior
Cypress should be able to resolve the cypress-multi-reporters and run the tests correctly.
Test code to reproduce
package.json
cypress.json
Cypress Version
9.0.0
Other
No response
The text was updated successfully, but these errors were encountered: