Cannot set properties of undefined (setting ‘listeners’) mock socket library when mocking web socket in Cypress

I have a mock server in my cypress test file

const getServer = () => {
    return new Cypress.Promise(resolve => {
        const mockServer = Server('wss://notifier.shoutout.social/')

        let mockSocket
        mockServer.on('connection', (socketHandle) => {
           resolve(socketHandle)
        })
    })
}
const socketPromise =  getServer()

Every time I want to send a message to my client from my web socket I am calling it with a cy.wrap using

cy.wrap(socketPromise).then((mockSocket) => {
    mockSocket.send({fixture: 'WebSocketMocks/WebSocketInitialised.json'})
})

But I get this error coming from the mock socket library in my stack trace

 var EventTarget = function EventTarget() {
> 742 |   this.listeners = {};
      | ^
  743 | };

Cheers 🙂