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

Yarn 3 + cypress.config.ts does not work #25958

Open
lmiller1990 opened this issue Feb 27, 2023 · 5 comments
Open

Yarn 3 + cypress.config.ts does not work #25958

lmiller1990 opened this issue Feb 27, 2023 · 5 comments
Labels
package manager: yarn Issues relating to yarn prevent-stale mark an issue so it is ignored by stale[bot]

Comments

@lmiller1990
Copy link
Contributor

lmiller1990 commented Feb 27, 2023

Ref: #22747 -> #22747 (comment)

If you are using Yarn 3 with TypeScript and have a cypress.config.ts, it will error when opening Cypress, no matter what. You cannot work around the issue. The only fix would be to use js or mjs extensions. There's an example here: #25959

Repro: yarn3.zip

Ideally, we should correctly consume the cypress.config.ts using the strategy we use for any package manager other than Yarn 3, which seems to work great. Based on some research, this may not be possible (or maybe it is?) using our current strategy, which uses loader API for ESM and require API for CJS. I suspect the CJS might be easier to work out.

Neither works with TS and Yarn 3.

May be relevant: yarnpkg/berry#4044

@nemonemi
Copy link

@lmiller1990 have you solved it?

vihangm pushed a commit to pixie-io/pixie that referenced this issue Aug 1, 2023
Summary: Update Cypress from 9.x to 12.x, and perform all relevant
migrations.
Changes are the results of [10.0
migration](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-100),
[11.0
migration](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-110),
and [12.0
migration](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-120)
guides.
The reason for using `cypress.config.mjs` instead of `cypress.config.ts`
is that the latter is not working with Yarn 3 yet
([1](cypress-io/cypress#24209),
[2](cypress-io/cypress#22747),
[3](cypress-io/cypress#25958)). If that
changes, we can revisit.
Notably, one of the larger changes is that test isolation is now on by
default. This means the page is refreshed between each test rather than
each suite, so some tests needed to be reconfigured to work with that
paradigm.
Cypress' UI has gotten a major refresh as well, so I changed the
commands to account for it.

Relevant Issues: N/A

Type of change: /kind cleanup

Test Plan: Follow instructions in `src/ui/cypress/README.md`. In
particular, try `yarn run cypress:run:chrome`. All of the tests should
pass, totally headlessly.

Signed-off-by: Nick Lanam <nlanam@pixielabs.ai>
@lmiller1990
Copy link
Contributor Author

I don't think so, but there are work arounds. Those don't work for you?

@nspire909
Copy link

I got this to work without changing my cypress.config.ts by using ts-import.

yarn install ts-import@^4.0.0-beta.10

I created a cypress.config.js with the following contents:

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { loadSync, LoadMode } = require('ts-import');

module.exports = loadSync('./cypress.config.ts', { mode: LoadMode.Compile, useCache: false });

And then updated cypressConfig to point to cypress.config.js instead.

Note: useCache: false doesn't seem to work and it still writes files to disk that will need to be gitignored. Also the cache seems to always be used & changed code won't get recompiled, which was initially causing me issues. Make sure to delete the cache when making changes to cypress.config.ts or anything it may import.

I doubt using ts-import is the way to go to fix this problem internally, especially given the weird caching behavior. But at least allowed me to migrate to Yarn 3 PnP w/o losing TS support in my config files.

@nemonemi
Copy link

nemonemi commented Oct 19, 2023

After a couple of months of using the Yarn PnP actively, I've had several issues that made it not worth our while and reverted back to the node-modules mode.
Some of them were VScode support-related issues, and pipeline failing and cutting out the output, so you cannot debug it, all the possible debugging output options were turned on but to no avail.

I hope you have a better and productive time with it.

francisduvivier added a commit to francisduvivier/cypress-data-generator-tests that referenced this issue Nov 15, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Apr 17, 2024
@jennifer-shehane jennifer-shehane added prevent-stale mark an issue so it is ignored by stale[bot] and removed stale no activity on this issue for a long period labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package manager: yarn Issues relating to yarn prevent-stale mark an issue so it is ignored by stale[bot]
Projects
None yet
Development

No branches or pull requests

5 participants