I have a ReactJS Typescript project with NPM and VSCode.
I am getting the following syntax error in VSCode, even though all my Cypress tests run correctly.
Error: Cannot find name 'cy'
How can I fix?
I tried the following solution and still receiving syntax errors,
npm install eslint-plugin-cypress --save-dev
"eslintConfig": {
"extends": [
"plugin:cypress/recommended"
]
},
3
Answers
For Typescript configuration, Add this to tsconfig.json inside your cypress root folder:
If using
// @ts-check
on a Javascript project, you can specify type libraries in jsconfig.jsonRef: JS Projects Utilizing TypeScript
You can use a triple-slash directive in individual files (only valid at the top of the spec file)
This is used to declare a dependency on a package, in this case the Cypress package.