Skip to content
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

[Bug?]: Cypress server is not able to resolve custom reporters with Yarn PNP #3837

Closed
1 task done
massimeddu-sonic opened this issue Dec 3, 2021 · 2 comments
Closed
1 task done
Labels
bug Something isn't working stale Issues that didn't get attention

Comments

@massimeddu-sonic
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

After migrating my project to Yarn PNP, cypress is not able anymore to find cypress-multi-reporters, giving the following error message:

yarn cypress run --browser electron

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

We searched for the reporter in these paths:

- /src/clients/web/cypress-multi-reporters
- /src/clients/web/node_modules/cypress-multi-reporters

The error we received was:

Cannot find module '/src/clients/web/node_modules/cypress-multi-reporters'
Require stack:
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/packages/server/lib/reporter.js
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/packages/server/lib/project-base.js
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/packages/server/lib/open_project.js
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/packages/server/lib/cypress.js
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/packages/server/index.js
- /home/<user>/.cache/Cypress/9.0.0/Cypress/resources/app/index.js

Learn more at https://on.cypress.io/reporters

To reproduce

Setup a project with:

package.json

"scripts": {
   "cypress:open": "cypress open --browser electron",
}
[...]
"devDependencies": {
    "cypress": "^9.0.0",
    "cypress-multi-reporters": "^1.5.0",
  },

cypress.json

{
  "baseUrl": "http://localhost:3000",
  "videoCompression": false,
  "reporter": "cypress-multi-reporters",
  "reporterOptions": {
    "configFile": "cypress-reporter-config.json"
  }
}

then run yarn run cypress:open

Environment

-v      
3.1.0

node --version
v16.13.0

Additional context

Upstream issue on cypress: cypress-io/cypress#18922

Cypress have a CLI tool that is installed in the project directory and a server that is installed in the user home directory. The custom reported are installed in the project directory.

The code that resolves the custom reporters is:

https://github.com/cypress-io/cypress/blob/0b5f451a9bce73bb80db0f2d8e48d8f2ab7b772d/packages/server/lib/reporter.js#L530-L554

I've tried to change this line of code from:

p = path.resolve(projectRoot, reporterName)

to

p = require.resolve(reporterName, { paths: [projectRoot] })

but it looks like that the Yarn PNP version of the require.resolve function is not passed from the Cypress CLI to the Cypress Server.

It looks like that the cypress CLI is creating the server process using the Node child process library here:

https://github.com/cypress-io/cypress/blob/6b15468579b539cd6f6bf3049fdc3ad8a1a414a3/cli/lib/exec/spawn.js#L157

Do you know if there is any way to pass the PNP context to the Node child process?

@massimeddu-sonic massimeddu-sonic added the bug Something isn't working label Dec 3, 2021
@yarnbot
Copy link
Collaborator

yarnbot commented Jan 2, 2022

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

@yarnbot yarnbot added the stale Issues that didn't get attention label Jan 2, 2022
@yarnbot yarnbot closed this as completed Jan 7, 2022
@Joelasaur
Copy link

I am having this issue as well, but it seems like this is a bug with the package, not Yarn. I'll raise this issue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale Issues that didn't get attention
Projects
None yet
Development

No branches or pull requests

3 participants