I had been using react-testing-library
as well as @testing-library/jest-dom/extend-expect
. I installed Cypress yesterday, and now I'm getting Typescript errors on all my jest matchers:
Property 'toEqual' doesn't exist on type 'Assertion'. Did you mean 'equal'?
It looks like it's getting the type of expect
from the wrong assertion library or something? Also, expect(...).to.equal(...)
doesn't even work either.
I actually tried installing @types/jest
and yarn appears to have succeeded but it's not listed in my package.json
's devDependencies
.
Here's my tsconfig
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react",
"skipDefaultLibCheck": true,
"types": [
"node",
"cypress",
"jest"
]
},
"include": [
"src"
]
}
I'll also mention that all my cy
calls in my cypress tests are getting a cy is not defined
error from ESLint.
./cypress.config.ts
. Consider to try Marcus Fonseca's answer first – Newsprint