Typescript: Cannot both import onlyOn and use cy.onlyOn
See original GitHub issueIn v2.6.0, Typescript threw errors when onlyOn
was imported, but worked correctly for cy.onlyOn
. Now in v2.6.1 (after https://github.com/cypress-io/cypress-skip-test/pull/143), Typescript correctly types the onlyOn
import, but cy.onlyOn
does not have a type.
Is there any way to get both of these to work with Typescript?
import { onlyOn } from '@cypress/skip-test'; // error here in 2.6.0: File '.../node_modules/@cypress/skip-test/index.d.ts' is not a module.
onlyOn('integration', () => {
describe('stuff', () => {
cy.onlyOn('mac'); // Error here in 2.6.1: Property 'onlyOn' does not exist on type 'cy & EventEmitter'
})
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Typescript error when importing from @cypress/skip-test #91
Importing like this import { onlyOn, skipOn } from '@cypress/skip-test'; ... Got error when using TypeScript too. Using. cy.
Read more >Cypress doesn't see custom cy. commands - Stack Overflow
Here is how I get TypeScript to see my custom commands: commands.ts declare namespace Cypress { interface Chainable<Subject> ...
Read more >Best Practices - Cypress Documentation
Best Practice: Use data-* attributes to provide context to your selectors and isolate them from CSS or JS changes. Every test you write...
Read more >Use TypeScript With Cypress - Gleb Bahmutov
How to write Cypress.io end-to-end tests in TypeScript is a question that comes up again ... VSCode cannot find global variable cy anymore....
Read more >The 32+ ways of selective testing with Cypress: a unified ...
Handle the environments in config files, and define a custom environment variable · Abstract away the logic in the test · Use it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to successfully import both by exporting the global scope in my
support/index.d.ts
.Try the following:
You can also find a minimal reproducible example here: https://github.com/conversaShawn/using-cypress-skip-test-plugin/tree/onlyOn
Add to your cypress.d.ts file