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

test: protect yarn modern pnp example against cypress script redefinition #967

Merged
merged 5 commits into from
Jul 27, 2023

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented Jul 17, 2023

For the Yarn Modern Plug'n'Plug example this PR changes the command used to run Cypress from

  • command: yarn cypress run

to

  • command: yarn run --binaries-only cypress run

This makes sure that the Cypress binary is called instead of a possible user-defined script with the name of cypress.

This follows on from issue #941 where it emerged that users had been defining such a script name which effectively overwrites the cypress name. When there is a script and a binary with the same name yarn run (Yarn Classic and Modern) selects the script. Yarn Modern offers the --binaries-only option to make the choice deterministic. Yarn Classic does not offer this option.

Verification

Run the following local and GitHub tests.

Run them again after temporarily adding a script to examples/yarn-modern-pnp/package.json where cypress is defined as cypress open :

  "scripts": {
    "cypress": "cypress open",
    "test": "cypress run"
  },

Local test

cd examples/yarn-modern-pnp
yarn
yarn run --binaries-only cypress run

Confirm that Cypress runs in headless mode and that the Cypress app does not open.

GitHub test

Manually run .github/workflows/example-yarn-modern-pnp.yml with the above cypress script defined.

Confirm that the workflow runs to completion in headless mode and does not hang up.

Reference

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 marked this pull request as ready for review July 17, 2023 18:24
@nagash77 nagash77 self-assigned this Jul 17, 2023
@nagash77 nagash77 merged commit 79310d5 into cypress-io:master Jul 27, 2023
112 checks passed
@MikeMcC399 MikeMcC399 deleted the yarn-pnp-binaries branch July 27, 2023 15:19
@nagash77 nagash77 removed their assignment Aug 7, 2023
@github-actions
Copy link

🎉 This PR is included in version 5.8.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants