0

I have to upload a file from a different folder than /fixtures. If I use attachFile it always adds the path cypress/fixtures in front of it.

cy.get('input[type="file"]').attachFile(this.uploadFileName );
        cy.get('#file-submit').click();

Where this.uploadFileName has an absolute path to the file.

The file is generated before, so it is not really a fixture anyway.

Jonas
  • 166
  • 1
  • 13
  • 2
    I think attachFile expects the file to be placed in the fixtures folder, also referring to the answers here: https://stackoverflow.com/a/58948308/6135684. If you say the file is generated before, then maybe you can copy it to the fixtures folder after it is created and then call attachFile. – Sebastiano Schwarz Jan 13 '22 at 10:07
  • Yes, that is one solution. I don't like it, though. It is not a fixture! And I can't believe that it is not possible to change the folders?! – Jonas Jan 13 '22 at 14:49

1 Answers1

0

Currently, attachFile can only import file from the fixtures folder. Hence, the generated file has to be imported into the fixture file (via task and fs.copy()).

Jonas
  • 166
  • 1
  • 13