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

Module API examples incorrect for Yarn Plug'n'Play #5248

Closed
MikeMcC399 opened this issue May 16, 2023 · 6 comments · Fixed by #5254
Closed

Module API examples incorrect for Yarn Plug'n'Play #5248

MikeMcC399 opened this issue May 16, 2023 · 6 comments · Fixed by #5254
Assignees
Labels
content: rewrite triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@MikeMcC399
Copy link
Contributor

Subject

Guides > Module API

Description

https://docs.cypress.io/guides/guides/module-api

For Yarn Plug'n'Play the command node e2e-open-tests.js needs to be executed as:

yarn node e2e-open-tests.js
@nagash77 nagash77 added the triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. label May 16, 2023
@elylucas
Copy link
Contributor

@MikeMcC399 what is the suggestion here? It doesn't appear we are using yarn in any of the commands here

@MikeMcC399
Copy link
Contributor Author

@elylucas

The command in the documentation node e2e-open-tests.js requires that Cypress has been installed. There are six different ways to do this (npm, pnpm, Yarn Classic, then Yarn Modern with its three different nodeLinker options: pnp, node-modules and pnpm) and all of them except Yarn Modern Plug'n'Play work by just specifying node. If you have however installed Cypress with Yarn Modern in Plug'n'Play mode you need to preface the call with yarn.

I was looking at this in conjunction with the introduction of Yarn Modern Plug'n'Play support in github-action and the absence of this information threw me to begin with until I got deeper into it. I didn't even know if Module API was compatible with Yarn Modern Plug'n'Play from reading the Module API documentation.

package \ command node yarn node
npm y y
pnpm y y
Yarn Classic y y
Yarn Modern pnp x y
Yarn Modern node-modules y y
Yarn Modern pnpm y y

The relevant bit of the Yarn Modern in Plug'n'Play mode documentation says:

For some remaining edge cases, a small setup may be required:

If you need to run an arbitrary Node script, use yarn node as the interpreter, instead of node. This will be enough to register the .pnp.cjs file as a runtime dependency.

@MikeMcC399
Copy link
Contributor Author

So the suggestion would be to add a comment to preface the command with yarn when Yarn Plug'n'Play is being used, with a reference to Yarn's documentation page https://yarnpkg.com/features/pnp,

@elylucas
Copy link
Contributor

Sorry, not too familiar with yarn pnp. Is this something that a yarn person would just know they have to do if they are using pnp? Would this change entail updating all the shell examples to have a yarn pnp usage as well, or a note to yarn pnp users somewhere?

@MikeMcC399
Copy link
Contributor Author

I'll make a concrete proposal in a PR for minimal changes to the docs. I think just a note would be sufficient without updating every single example.

@MikeMcC399
Copy link
Contributor Author

Sorry, not too familiar with yarn pnp.

That makes two of us!

Is this something that a yarn person would just know they have to do if they are using pnp?

I can't really answer that as I wouldn't consider myself to be a "yarn person". It's probably better not to assume too much prior knowledge.

In any case I've now submitted a suggestion as PR #5254 for you to take a look at. There are currently several issues in Cypress with Yarn Plug'n'Play so I had to go back to [email protected] to demonstrate it. I've tried to keep the text short and simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content: rewrite triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants