Hello I have a question regarding the use of custo...
# e2e-testing
c
Hello I have a question regarding the use of custom classes with cypess e2e. I'm using Cypress with Typescript and have a Web-Page consisting of loads of different forms. I want to capsule every form and it's corresponding inputs into a custom class, which I then wanna use to write custom commands for easily checking different interactions of the forms. E.g.: I have a form consisting of three inputs with the ID's [firstname, lastname, birthplace]. I write a custom typescript class:
Copy code
class Form{
  firstname?: string
  lastname?: string
  birthplace?: string

  constructor(...){...}

  setAllWrong(){
    this.firstname = ""
    this.lastname = ""
    this.birthplace = ""
  }
}
Now I declare a custom command:
Copy code
Cypress.Commands.add(
    'fill_all_correct',
    (data: Form) => {
        ...
    }
)
And define it insinde the `index.ts`:
Copy code
declare namespace Cypress {
  interface Chainable{
      fill_all_correct(data: Form): Chainable<Element>,
  }
}
Cypress is now giving me a
ReferenceError: Form is not defined
when using it inside a test.
Copy code
specify('Test', () => {
         const form= new Form()
         ...
    }
Importing the
Form
Class inside the test, command and index file leaves me with an
Type 'Chainable' is not generic.
inside the
index.ts
. Can anybody identify what I may be doing wrong and what I should do instead ? I hope I could picture the problem for all of you.