Cypress-file-upload: [Bug] Not working with TypeScript

Created on 7 May 2020  路  5Comments  路  Source: abramenal/cypress-file-upload

Current behavior:

Added import 'cypress-file-upload'; to my commands.ts

Get this when I run it:
cy.getByAria(...).attachFile is not a function

(Note that getByAria is a command that I've written. )

I've also tried adding this to index.d.ts:

attachFile(fixture: string, processingOpts: any): Chainable<Element>;

Desired behavior:

Works

Versions

Cypress: 4.5.0
cypress-file-upload: 3.5.3

bug

Most helpful comment

@craig-dae I've fixed this issue by adding cypress-file-upload to my ts config file. E.g.: "types": ["cypress", "cypress-file-upload"]

All 5 comments

Does your getByAria return a Chainable>?

Yes. I use it all the time. It's just
Cypress.Commands.add('getByAria', (label) => cy.get([aria-label="${label}"]));

We use it to force ourselves to add aria labels to everything that a user would need to interface with.

@craig-dae I've fixed this issue by adding cypress-file-upload to my ts config file. E.g.: "types": ["cypress", "cypress-file-upload"]

I think the issue was my version number. Seems to be working now. Thanks for your help!

to others still seeing this issue after following @ajfranzoia's fix, remember to restart your IDE

Was this page helpful?
0 / 5 - 0 ratings