question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid clashing global types between Cypress and Jest

See original GitHub issue

Hello. Thank you for this library. Describe the bug I use cypress-fail-fast in a project with common cypress config for other projects. It has jest test for custom cypress commands. After install cypress-fail-fast I have typescript error “Property ‘toEqual’ does not exist on type ‘Assertion’. Did you mean ‘equal’? ts(2551) index. d. ts (206, 9): ‘equal’ is declared here.” If delete /// <reference types="cypress" /> in the plugin. d. ts and index. d. ts errors disappears. So I suggest delete these two lines from cypress-fail-fast. I tried it and it is ok.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
javierbreacommented, Aug 21, 2022

Hi, @javierbrea! Thank you for detail explanation. Your suggestion about purpose of my repository exactly right. Created tsconfig for jest tests helped me, but if you will have more information about this issue, for example, why another plugin did not this typescript error, write in this issue.

You’re welcome @aleksey-ilin 😃

Well, other plugins may not produce this conflict due to multiple reasons:

  • Other plugins may don’t have dependency with Cypress types. This one does because it is extending Cypress’ TestConfigOverrides interface in order to provide custom options to specs, and in the Node.js side it needs to extend Cypress plugin options.
  • Other plugins may don’t even have TypeScript types. For example, the other plugin you are using: cypress-image-snapshot
  • You may be using other plugins, but you don’t import them from your Jest tests. This one neither produces a conflict if you don’t import it in your Jest tests, and you have TypeScript configured properly.

And, finally, I don’t know if other plugins define the dependency with Cypress, which produces the conflict. But, as mentioned in my previous comment, it is a real dependency, so, I think that it shouldn’t be removed to “fix” a conflict between Jest and Cypress. That conflict is not a problem of this plugin, and removing the dependency here would be only a workaround.

0reactions
aleksey-ilincommented, Aug 21, 2022

Hi, @javierbrea! Thank you for detail explanation. Your suggestion about purpose of my repository exactly right. Created tsconfig for jest tests helped me, but if you will have more information about this issue, for example, why another plugin did not this typescript error, write in this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Cypress 10 global TypeScript type conflicts with Jest ...
Current behavior The following new global TypeScript type for expect in ... Avoid clashing global types between Cypress and Jest ...
Read more >
Cypress causing type errors in jest assertions - Stack Overflow
I ran into this problem yesterday. It seems that what you are saying is correct, cypress and jest both declares types for expect...
Read more >
TypeScript - Cypress Documentation
Clashing types with Jest. If you are using both Jest and Cypress in the same project, the TypeScript types registered globally by the...
Read more >
Cypress and Jest `expect` functions conflict in IDEA, tests ...
Cypress and Jest `expect` functions conflict in IDEA, tests execute fine on the command line.
Read more >
Jest's configuration can be defined in the package ... - ADocLib
Avoid clashing global types between Cypress and Jest by using localcypress library. Global variables are the worst thing in programming but.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found