I ran into this problem yesterday. It seems that what you are saying is correct, cypress and jest both declares types for expect
. In this case the cypress declaration seem to be the one that is picked up. Here’s an issue from the cypress repo regarding this:
https://github.com/cypress-io/cypress/issues/1603
The solution mentioned in there worked for me. You need to exclude the jest spec files from in tsconfig.json
and then declare a tsconfig.spec.json
where they are explicitly included again.
tsconfig.json:
{
...,
"exclude": [
"**/*.spec.ts"
]
}
tsconfig.spec.json:
{
"extends": "./tsconfig.json",
"include": [
"**/*.spec.ts"
],
...
}
With this in place, both my (angular 8) app compiles fine and I can run the jest tests without issue. Here’s another example mentioned in the issue with a similar fix being implemented:
https://github.com/neiltownsley/react-typescript-cypress/pull/1/files#diff-e5e546dd2eb0351f813d63d1b39dbc48R29