I am using Cypress version 12.17.1 with VS Code in Windows 10.
I am trying to write cypress code in Visual Studio Code, but the problem I am facing is that the cypress commands starting with cy
are not suggested as auto-complete (intellisense). For eample, in the below image, the suggestions in should('')
only show when I require the cypress.
Above suggestions only work if I explicitly import the cypress as:
const cypress = require("cypress")
But if I include the above statements in my cypress test file e.g. e2e/test.cy.js, then I get the error Cypress: process is not defined when I try to run my tests.
So basically every time I want to run my tests, I have to delete this line and then run the tests.
Is there a way to avoid the above error, or get the cypress suggestions to work without requiring the cypress package?
2
Answers
I got the issue to resolve by adding the following line at the top to enable intellisense for Cypress JS in VS Code:
This answer helped me: https://stackoverflow.com/a/52440156/7673215
You can also add a
jsconfig.json
to the project root. I usewhere the entry for
"cypress"
is the types defined by Cypress, and the entry for"./cypress/support/index.d.ts"
is for custom commands defined in the project.Or Cypress mentions a "dummy"
tsconfig.json
here cypress-example-todomvc