'CSV file downloaded with Cypress has additional markup in it
I have a link on my page with the following markup.
<a href="http://connect.lndo.site/download/attendees/report/8bfe53cf-eac6-45fb-b8db-83d486d0473a" target="_blank" rel="noopener noreferrer" class="button-0-1-51 button mt" data-name="button">Download as CSV</a>
I am able to select the link, remove the attribute so that clicking it doesn't open a new tab and the file downloads.
My problem is that the one that Cypress is downloading seems to have markup added to the file.
<head> <script type='text/javascript'> document.domain = 'lndo.site'; !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}({"./injection/index.js":function(e,t,n){"use strict";n.r(t);const r=window.Cypress=parent.Cypress;if(!r)throw new Error("Something went terribly wrong and we cannot proceed. We expected to find the global Cypress in the parent window but it is missing!. This should never happen and likely is a bug. Please open an issue!");const o=(()=>{let e,t,n,r;const o=()=>{e=!1,t=!1,n=[],r={}},i=(e,t=[])=>"function"==typeof e?e.apply(window,t):window.eval(e);return o(),{wrap:()=>{const o={setTimeout:window.setTimeout,setInterval:window.setInterval,requestAnimationFrame:window.requestAnimationFrame,clearTimeout:window.clearTimeout,clearInterval:window.clearInterval},a=(e,t)=>o[e].apply(window,t),s=e=>n=>(t&&(r[n]=!0),a(e,[n])),u=t=>(...r)=>{let o,[s,u,...l]=r;return o=a(t,[(...r)=>{if(!e)return i(s,r);n.push({timerId:o,fnOrCode:s,params:r,type:t})},u,...l]),o};window.setTimeout=u("setTimeout"),window.setInterval=u("setInterval"),window.requestAnimationFrame=u("requestAnimationFrame"),window.clearTimeout=s("clearTimeout"),window.clearInterval=s("clearInterval")},reset:o,pause:a=>{e=Boolean(a),e||(t=!0,n.forEach(e=>{const{timerId:t,type:n,fnOrCode:o,params:a}=e;"setInterval"===n&&r[t]||i(o,a)}),o())}}})();r.removeAllListeners("app:timers:reset"),r.removeAllListeners("app:timers:pause"),r.on("app:timers:reset",o.reset),r.on("app:timers:pause",o.pause),o.wrap(),r.action("app:window:before:load",window)},0:function(e,t,n){e.exports=n("./injection/index.js")}}); </script> </head>"Attendee Reference"
I had assumed that the markup was being added because I removed the attribute.
So I tried it without removing the attribute but markup still seems to be being added to the file.
<head> <script type='text/javascript'> document.domain = 'lndo.site'; </script> </head>"Attendee Reference"
Does anyone know why this is happening or how I might be able to fix/stop it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
