mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
bugfix(ws/microservices): add catchError() to observables
This commit is contained in:
35
integration/websockets/e2e/error-gateway.spec.ts
Normal file
35
integration/websockets/e2e/error-gateway.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as io from 'socket.io-client';
|
||||
import { ErrorGateway } from '../src/error.gateway';
|
||||
|
||||
describe('ErrorGateway', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const testingModule = await Test.createTestingModule({
|
||||
providers: [ErrorGateway],
|
||||
}).compile();
|
||||
app = await testingModule.createNestApplication();
|
||||
await app.listenAsync(3000);
|
||||
});
|
||||
|
||||
it(`should handle error`, async () => {
|
||||
const ws = io.connect('http://localhost:8080');
|
||||
ws.emit('push', {
|
||||
test: 'test',
|
||||
});
|
||||
await new Promise(resolve =>
|
||||
ws.on('exception', data => {
|
||||
expect(data).to.be.eql({
|
||||
status: 'error',
|
||||
message: 'test',
|
||||
});
|
||||
resolve();
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => app.close());
|
||||
});
|
||||
Reference in New Issue
Block a user