fix: resolve reporters using module resolution algorithm (#4536)
- Closes #4536
Additional details
- The explicit join to the project root meant that it effectively disabled the normal module resolution algorithm which would just work™️.
- This has been there since at least https://github.com/cypress-io/cypress/commit/98c4538ddda568a294f665600ff527a0db86b3ab.
- I kept the project root there as the starting point as I wasn't sure whether
__dirnameor the current working directory would be correct. - https://nodejs.org/dist/latest-v18.x/docs/api/modules.html#requireresolverequest-options
- I'd like some help writing a test. What is the best way?
- Also might need to update the error. It has the correct path but it doesn't explain that it uses the module resolution algorithm.
Steps to test
- Setup a small monorepo that uses workspaces.
- Add cypress to the workspace project.
- Add a reporter to the root.
- Run cypress in the workspace project.
- It should find the reporter.
How has the user experience changed?
The behaviour should be the same except that it now searches up properly. It will also look in the global modules.
PR Tasks
- [ ] Have tests been added/updated?
- [ ] Has a PR for user-facing changes been opened in
cypress-documentation? - [ ] Have API changes been updated in the
type definitions?
- Create a Draft Pull Request if your PR is not ready for review. Mark the PR as Ready for Review when you're ready for a Cypress team member to review the PR.
@steinybot Thanks for the contribution! Could you please sign our CLA?
@steinybot is this still in draft or is this ready to review?
I need some help figuring out how to write a test for it. Other than that it is ready for review.
This PR has not had any activity in 180 days. If no activity is detected in the next 14 days, this PR will be closed.
This PR has been closed due to inactivity