I'm trying to stub a midi file in a Cypress intercept. From the URL I am deriving a fixture to load and use in the reply. I am doing something like:
cy.intercept("**/MIDI/*", (req) => {
const fixtureName = get_last_part_of(req.url) // This will yield a fixture like 1.mid
req.reply( {
headers: {
'content-type': "audio/sp-midi"
},
fixture: "midi/" + fixtureName
})
When I load this file I get an error in the browser logs about an invalid MIDI file:
ERROR Error: Uncaught (in promise): Bad MIDI file. Expected 'MTrk', got: 'MTr'
at resolvePromise (polyfills.js:8576:21)
at polyfills.js:8485:11
I think this is because the 1.mid
is treated as utf-8
, but I want it to be treated as binary
. Is there a way to specify this in the reply
?
I've tried reading the file directly in the intercept but because I am using cy.visit that invokes the intercept, I am getting an error.