I am implementing a custom Cypress command in TypeScript:
// support/commands.ts
const login = () => {
console.log(\'Logging in...\');
};
Cypress.Command
Here is what I use and I do not have to add ///
at the top of every file.
I have my custom typings under
///
declare namespace Cypress {
interface Chainable {
getByDataTest(tag: string): Chainable
}
}
And my
looks like
{
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"typeRoots": ["./support"]
},
"include": ["**/*.ts"]
}
And TypeScript is finally happy
describe('when I want to select by data test tag', () => {
it('should select by data test tag', () => {
cy.getByDataTest('yolo').should('exist')
});
});