https://cypress.io logo
Hi all, How would you solve the following type er...
# e2e-testing
b
Hi all, How would you solve the following type error, also how would you type to be fine with Typescript and Cypress?
Copy code
API.getAccessCodes(id).then((response: **GetCodesResponse**) => { // error 1
          expect(response.success).to.be.true; // intellisense work here as expected
          expect(response.data.code).to.equal('12345678'); // intellisense work here 
        });

// error 1: 
// No overload matches this call. Argument of type '(response: GetCodesResponse) => void' is not assignable to parameter of type '(this: ObjectLike, currentSubject: Response<any>) => void'.

// API.getAccessCodes(id: string): Cypress.Chainable<Cypress.Response<any>>
getAccessCodes
return the
cy.request()
, and the above example works as expected, however I cannot seem to resolve the issue with the response type, and if I do, TS loses the ability to have intellisense inside the
.then()
6 Views