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

Cypress dependencies resolved using the user's tsconfig.json rules #14646

Open
Andarist opened this issue Jan 20, 2021 · 7 comments
Open

Cypress dependencies resolved using the user's tsconfig.json rules #14646

Andarist opened this issue Jan 20, 2021 · 7 comments
Labels
E2E Issue related to end-to-end testing topic: typescript Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@Andarist
Copy link
Contributor

Andarist commented Jan 20, 2021

Current behavior

Cypress server installs ts-node through this:

if (!tsRegistered) {
registerTsNode(projectRoot, pluginsFile)

and this affects file resolution logic when running Cypress. For many situations, this is desirable and works just fine without the user having to configure stuff automatically.

However, this can also affect how things from within Cypress are resolved and this can end up with a very hard to debug problem - especially given the fact that it can happen at random at any time (after adding some files to the project or when installing a new version of Cypress).

Desired behavior

This should be seamless for the user - tsconfig.json in the user's project should not influence the resolution of Cypress' dependencies.

Test code to reproduce

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src"
  }
}

project structure

├── source
│   └── debug.ts
└── tsconfig.json

Given this structure, any require('debug') - from within the project, its node_modules but also from within Cypress directory that lives completely outside of the project - will resolve to <root>/source/debug.ts and this might crash at runtime as you expect completely different interface of the 'debug' module than the one that is exported by the local debug.ts.

This is not exclusive to debug module - any dependency of yours is error-prone to this if only the user creates a filename conflicting with a node module pkg name.

Here you can find a repro case presenting the issue:
https://github.com/Andarist/cypress-ts-base-url-problem
just run this to see the error:

git clone git@github.com:Andarist/cypress-ts-base-url-problem.git && cd cypress-ts-base-url-problem && yarn && yarn cypress:open

Versions

6.3.0

@jennifer-shehane
Copy link
Member

@Andarist Could you provide a repo with an example of the conflict resolution of deps situation you're describing?

@Andarist
Copy link
Contributor Author

Andarist commented Jan 21, 2021

Sure thing - I've added a repro case to the main post, you can check it out here: https://github.com/Andarist/cypress-ts-base-url-problem

@bovas85
Copy link

bovas85 commented Oct 27, 2021

seems that between v7 and v7.7 / 8 something has changed further in the way paths are resolved.
Aliases are breaking for my repo which were not in v7.5
image
The only reasonable change I can see around this section (assuming it is the culprit) is around the resolve util here where the resolve package is not being used anymore, using require.resolve instead

@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 May 17, 2023
@Andarist
Copy link
Contributor Author

I upgraded Cypress to v12 in the provided repro and I can confirm that the issue is still there: Andarist/cypress-ts-base-url-problem@37288ce

@nagash77
Copy link
Contributor

@thank you @Andarist for confirming this is still an issue. I will update the ticket.

@nagash77 nagash77 removed the stale no activity on this issue for a long period label May 18, 2023
@chrisbreiding
Copy link
Contributor

I have replicated your problem in the latest version of Cypress and will forward this ticket to the appropriate team. They will evaluate the priority of this ticket and consider their capacity to pick it up. Please note that this does not guarantee that this issue will be resolved.

@chrisbreiding chrisbreiding removed their assignment May 18, 2023
@chrisbreiding chrisbreiding added type: bug E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing topic: typescript Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet
Development

No branches or pull requests

6 participants