P粉8324905102023-09-06 16:45:08
solved. Can't do it in Cypress. I used an environment variable "DEVELOPMENT=1" to append the input element to the DOM, but only during testing.
const inputEl = document.createElement("input"); if (process.env.DEVELOPMENT) { document.getElementById("root").appendChild(inputEl); } inputEl.type = "file"; inputEl.multiple = true; inputEl.click(); inputEl.onchange = (e) => { ... }