Closed ismail-codinglab closed 3 years ago
I still see this issue with cypress@6.5.0
and cypress-file-upload@5.0.2
.
Also if it wasn't clear from @ismail-codinglab's report, you can work around this by using the object notation and passing mimeType like so:
- cy.find('input[type="file"]').attachFile('./picture.png')
+ cy.find('input[type="file"]').attachFile({ filePath: './picture.png', mimeType: mime.getType('./picture.png') })
Hey there!
I just come with a similar problem. The thing was working yesterday, but today after I've done some changes it broke.
The thing I did was simply adding tsconfig.json
as it is suggested in Cypress documentation.
The outcome was that Cypress was using wrong package version (because I have a couple of them in the project) due to baseUrl
set to ../node_modules
.
When I did like so (notice removed baseUrl
):
{
"compilerOptions": {
"allowJs": true,
"outDir": "ts-dist",
"types": ["cypress", "@testing-library/cypress", "cypress-file-upload"]
},
"include": [
"**/*.*"
],
"exclude": ["ts-dist"]
}
Then it stopped complaining.
It seems to also work with jsconfig.json
(with VSCode type suggestions):
{
"compilerOptions": {
"types": ["cypress", "@testing-library/cypress", "cypress-file-upload"]
},
"include": [
"**/*.*"
]
}
I haven't dug deeper, but it seems it may be related more to Cypress using tsconfig.json
.
cypress-file-upload
has the proper version of mime
at node_modules/cypress-file-upload/node_modules/mime
, but when baseUrl
is set to ../node_modules
it simply loads node_modules/mime
which is an older version in my case (this one has lookup
instead of getType
)
Maybe it can help you find the root problem!
@abramenal with the issue located, a reproducable example and exact method identified. Do you think it's possible to get a fix out the door?
I am seeing this issue as well - Cypress 6.6.0 and cypress-file-upload 5.0.2. @slinkardbrandon i tried adding the mimeType and unfortunately that didnt work for me. i get an error mime is not defined
I think these are 2 separate issues:
mime is not defined
should've been addressed in v5.0.4
with fixing the build configurationi.getType is not a function
might be related to tsconfig
, and in this I'm not sure how to fix this properlyI was thinking about adding whole mime library into package's bundle. This way it'll become bigger, but there will be no way to mess up with different versions/configurations. This has also been added in v5.0.4
so both issues should be solved now.
Looking forward further feedback if it's working, or any ideas on what might be a better fix.
Might be also related to #301
So mime dependency is now bundled within command's source code, and #302 introduces a replacement for all node.js internals. Hence, the package will not have a single dependency required.
UPD: Released in v5.0.7
Current behavior:
Desired behavior:
Be able to use file without specifying mimetype
Steps to reproduce: (app code and test code)
I was not able to reproduce it on cypress tiny test
If i add the
mimeType
property it doesn't fail anymoreVersions
Cypress v5.3.0 cypress-file-upload v4.1.1.