Open Mnigos opened 3 years ago
I tried to create a test but i got error with using socket.io-mock library. I'm using Typescript btw.
socket.io-mock
room.gateway.spec.ts
import { Test, TestingModule } from '@nestjs/testing' import { RoomGateway } from './room.gateway' import { Socket } from 'socket.io' import SocketMock from 'socket.io-mock' let socket: Socket describe('RoomGateway', () => { let roomGateway: RoomGateway beforeEach(async () => { const RoomModule: TestingModule = await Test.createTestingModule({ providers: [RoomGateway], }).compile() socket = SocketMock() roomGateway = RoomModule.get<RoomGateway>(RoomGateway) }) it('Should be defined', () => { expect(roomGateway).toBeDefined() }) it('Should return message that we provide', async () => { expect(roomGateway.handleMessage(socket, 'Hello World')).toEqual({ event: 'message', data: 'Hello World', }) }) })
try import * as MockedSocket from "socket.io-mock
import * as MockedSocket from "socket.io-mock
I tried to create a test but i got error with using
socket.io-mock
library. I'm using Typescript btw.room.gateway.spec.ts