Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

342
Views
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('Websocket URL')

        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 :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!