-
Currently, the only way to upload a file is from fixtures. In my case I use "xlsx" to create files like this:
As I want to test my code in terms of parsing, reading and validating different kinds of dynamic xlsx files, it would be great to somehow upload files accordingly without having to create tons of xlsx files into fixtures (taking a lot of disk space). What do you think? Do have better ideas? Looking forward to hearing from you!! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I don't think this is quite what you were looking for, but I had a similar goal of not having to create tons of fixtures and found that if I could replicate the format of the file contents that cy.get('<my-file-input-selector>').attachFile({
fileContent: 'Header1,Header2\nvalue A,value B\nvalue C,value D',
fileName: 'LookMaNoRealFile.csv',
mimeType: 'text/csv',
encoding: 'utf-8'
}); |
Beta Was this translation helpful? Give feedback.
-
As mentioned, there is a way to attach raw file content – please see mentioned example, or related section of API docs ;) |
Beta Was this translation helpful? Give feedback.
I don't think this is quite what you were looking for, but I had a similar goal of not having to create tons of fixtures and found that if I could replicate the format of the file contents that
cy.fixture
yields, I didn't need a real file at all. Obviously, this is probably easier for my use case of simplecsv
andtxt
files, but I usedconsole.log
to see what value was being passed to mycy.fixture
callback and came up with something like this: