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

318
Views
TypeError: this.io.in(...).emit is not a function

I mocked in and emit to test this.io.in(room).emit(eventName, result); using jest

this.io.in(room).emit(eventName, result);

this.io.in(room) is working well but I am not sure how to deal with .emit(eventName, result);

here is code

export interface ServerToClientEvents {
 
  [EVENTNAME]: (payload: payload[]) => void;
}
import {   BroadcastOperator, Server } from "socket.io";
import { ServerToClientEvents } from "../../common/Interfaces";

export class MockIo extends Server {
  hasEmitted = false;
  hasEmittedData: string[] = [];
  hasEmittedEventName: string | symbol = "";
  room: string | string[];

  constructor() {
    super();
  }

  emit(event: string | symbol, ...args: any[]): boolean {
    this.hasEmitted = true;
    this.hasEmittedData = args;
    this.hasEmittedEventName = event;
    return true;
  }
 
   in(room: string | string[]): BroadcastOperator<ServerToClientEvents,any> {
     this.room = room;

      return this.emit.bind(this) ;
   }
  
}
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!