Skip to content

jesussegado/example-e2e-nestjs-socket.io

Repository files navigation

Test e2e with NestJs and Socket.io

In this project, you will see a example of how to test webSocket(socket.io) in a nestjs project. Example obtained from nestjs project (02-gateway sample).

Nest Logo Socket.io Logo

Links for docummentation

Example

npm install
npm run e2e

it should show this result

> nest-typescript-starter@1.0.0 e2e /home/username/socketExample
> jest --config=jest.e2e.json --maxWorkers=1 --detectOpenHandles

 PASS  e2e/events/events.e2e.spec.ts
  Events
    should return a correct event
      ✓ when socket is connected (99ms)
      ✓ when socket send normal data (74ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        1.65s, estimated 2s
Ran all test suites.