Reputation: 181
When trying to npm install -D cypress-xpath into a Cypress project [require('cypress-xpath') added to my cypress/support/index.js] with the cypress-cucumber-preprocessor already installed I am getting the below Error in the plugins > index.js file for "/// <reference types="cypress" />"
?
Cannot find type definition file for 'cypress'.ts(2688)
Added to plugins > index.js file
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
package.json file
"devdependencies": {
"cypress": "^8.3.1",
"cypress-cucumber-preprocessor": "^4.2.0"
},
"Dependencies": {
"cypress-xpath": "^1.6.2"
}
support > index.js file
require('cypress-xpath')
When running:
npx cypress open
The plugins file is missing or invalid.
Your pluginsFile is set to C:\Users\Delwin\VSCode\Cypress\Cucumber1\cypress\plugins\index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js, .ts, or .coffee file.
Or you might have renamed the extension of your pluginsFile. If that's the case, restart the test runner.
Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.
Error: Cannot find module 'cypress-cucumber-preprocessor'
Upvotes: 18
Views: 24027
Reputation: 11
I added the following tsconfig.json file an ran npm i -D @types/cypress@latest
worked for me.
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
Upvotes: 1
Reputation: 1
My problem got sloved by writing
reference types="@cypress/xpath"
instead of
reference types="cypress-xpath"
Upvotes: 0
Reputation: 308
I tried everything, but installing cypress in the project root path and creating "jsconfig.json" in the project root folder, solved the problem.
jsconfig.json ->
{
"include": ["./node_modules/cypress", "cypress/**/*.js"]
}
Upvotes: 0
Reputation: 15945
My problem was solved by installing latest cypress types
npm i -D @types/cypress@latest
Upvotes: 16
Reputation: 91
I had same error and I fixed by installing cypress, https://docs.cypress.io/guides/getting-started/installing-cypress
Upvotes: 0