I installed the module @cypress/skip-test and want to use it as a command. The suggestion is to add require('@cypress/skip-test/support')
in the support/index.js file. So when I do that, I am still not able to use it as a custom command. (my file by the way is a typescript file - index.ts). Is there anything else that is needed in order to use it as a cypress custom command?
I get this error when using cy.skipOn(true);
:
TS2339: Property 'skipOn' does not exist on type 'cy & CyEventEmitter'.
CodePudding user response:
The release notes for the library cypress-skip-test need updating.
If you are running a version of Cypress v10 or above, the correct file is /cypress/support/e2e.ts
.
Also the convention for typescript is to use import
, but you may find require()
still works.
// cypress/support/e2e.ts
import '@cypress/skip-test/support'
CodePudding user response:
Firstly, I think the path is wrong. The cypress-skip-test
library is independent of the @cypress
repository,
After install, if you look under /node_modules/@cypress
there is no /skip-test
sub-folder but there is a /node_modules/cypress-skip-test
folder.
So if I switch the paths, I get a working test
// import '@cypress/skip-test/support'
import 'cypress-skip-test/support'
Secondly, for the typescript error - they provide a index.d.ts
type definition which you should add in tsconfig.json
{
"compilerOptions": {
...
},
"types": ["cypress"],
"include": [
"../../node_modules/cypress",
"cypress/**/*.ts",
"node_modules/cypress/types/index.d.ts",
"node_modules/cypress-skip-test/index.d.ts", // this line adds skip-test
]
}