cypress-file-upload not working
See original GitHub issuecypress-file-upload plugin was working fine but has stopped working since last week.
Here is the upload command i am using
cy.fixture(fileName, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then(fileContent => {
cy.get('.file-upload').upload(
{ fileContent, fileName, mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', encoding: 'utf8' },
{ subjectType: 'drag-n-drop', force: true },
);
});
})
The error i am getting is
> CypressError: cy.then() timed out after waiting '50000ms'.
Your callback function returned a promise which never resolved.
The callback function was:
function(u){try{var y=(void 0===(F=a)&&(F={}),void 0===(A=j)&&(A={}),Object.assign({},A,F)),g=y.subjectType,h=y.subjectNature,E=y.force,O=y.allowEmpty,P=y.events;return function(e){var t=e.subjectType,o=e.subjectNature,i=e.force,s=e.allowEmpty,a=e.events;if(-1===Object.values(n).indexOf(t))throw new T(f);if(-1===Object.values(r).indexOf(o))throw new T(l);if("boolean"!=typeof i)throw new T(p);if("boolean"!=typeof s)throw new T(d);if(!Array.isArray(a)||!a.every(function(e){return"string"==typeof e}))throw new T(b)}({subjectType:g,subjectNature:h,force:E,allowEmpty:O,events:P}),function(e){var t=e.subject;if(!t||!t[0]||!w[e.subjectType][e.subjectNature](t[0]))throw new T(c)}({subject:e,subjectNature:h,subjectType:g}),function(e,t){(Array.isArray(e)?e:[e]).forEach(function(e){var n=e.fileContent;if(!(t?!n:n)||!e.fileName||!e.mimeType)throw new T(v)})}(t,O),Promise.resolve(function(e){var t=e.validator,n=e.constructor;return Cypress.Promise.all(e.files.map(function(e){var r=e.fileContent,s=e.fileName,a=e.mimeType,u=e.encoding;void 0===u&&(u=function(e){var t={};return t[o.JSON]=i.UTF8,t[o.JS]=i.UTF8,t[o.COFFEE]=i.UTF8,t[o.HTML]=i.UTF8,t[o.TXT]=i.UTF8,t[o.CSV]=i.UTF8,t[o.PNG]=i.BASE64,t[o.JPG]=i.BASE64,t[o.JPEG]=i.BASE64,t[o.GIF]=i.BASE64,t[o.TIF]=i.BASE64,t[o.TIFF]=i.BASE64,t[o.ZIP]=i.BASE64,t[o.PDF]=i.UTF8,t[o.VCF]=i.UTF8,t[e.slice(e.lastIndexOf(".")+1)]}(s));try{return t({fileContent:r,fileName:s,mimeType:a,encoding:u}),Promise.resolve(function(e){var t=e.fileContent,n=e.mimeType,r=e.encoding,o={};return o[i.ASCII]=function(){return Promise.resolve(t)},o[i.UTF8]=function(){return Promise.resolve(t)},o[i.UTF_8]=function(){return Promise.resolve(t)},o[i.BASE64]=function(){return Cypress.Blob.base64StringToBlob(t,n)},o.default=function(){return Cypress.Blob.base64StringToBlob(t,n)},(o[r]||o.default)()}({fileContent:r,mimeType:a,encoding:u})).then(function(e){return n([e],s,{type:a})})}catch(e){return Promise.reject(e)}}))}({files:Array.isArray(t)?t:[t],validator:function(e){return function(e){if(!e||-1===Object.values(i).indexOf(e))throw new T(m)}(e.encoding)},constructor:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(u.File,[null].concat(e)))}})).then(function(t){var n;Cypress.log({name:"upload",displayName:"UPLOAD",message:t.map(function(e){return e.name}).join(", "),consoleProps:function(){return{subjectType:g,subjectNature:h,files:t,force:E,allowEmpty:O,events:P}}}),(0,s[(n={subjectType:g,subjectNature:h}).subjectType][n.subjectNature])({window:u,subject:e,force:E,events:P},{files:t})})}catch(e){return Promise.reject(e)}var F,A}
Cypress version ^4.1.0 cypress-file-upload version ^3.5.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
cypress-file-upload attachFile is not a function - Stack Overflow
I am working with TypeScript. I had to import it in support/index.ts .
Read more >Issues · abramenal/cypress-file-upload - GitHub
cypress -file-upload with subjectType: "drag-n-drop" does not work on Chrome & Electron but works fine with Firefox. #352 opened on Dec 25, 2021...
Read more >Uploading files made easy with the .selectFile command
selectFile() command, new in Cypress 9.3.0. Selecting files in an HTML5 input elementWith the new .selectFile() command, you.
Read more >How to upload a file in Cypress? - YouTube
cypress # upload #automationbroIn this tutorial, we will learn how to upload a file in Cypress. We will cover different examples to show...
Read more >Cypress basics: Uploading a file - Filip Hric
Starting with version 9.3.0, Cypress has a .selectFile() command which can handle all the file uploads you'll need. The usage is simple:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting this issue. However,
cypress-file-upload
is not maintained by the Cypress.io team. Seeing as you have already reported the issue on the correct repo for that plugin, I’m going to go ahead and close this issue.@panache-chinmay
try adding invoke(‘show’) and trigger:
cy.get(‘input[type=“file”]’).invoke(‘show’); cy.get(‘input[type=“file”]’).attachFile(fileName).trigger(‘input’);