SSE Session and examples
This commit is contained in:
@@ -101,6 +101,9 @@ const testEventEmitterEmitContinuesAfterListenerThrows = (): void => {
|
||||
const emitter = new EventEmitter<TestEvents>();
|
||||
const secondListener = vi.fn();
|
||||
|
||||
// Spy on the console.error method
|
||||
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
emitter.on('message', (): void => {
|
||||
throw new Error('listener failure');
|
||||
});
|
||||
@@ -110,6 +113,12 @@ const testEventEmitterEmitContinuesAfterListenerThrows = (): void => {
|
||||
|
||||
expect(secondListener).toHaveBeenCalledOnce();
|
||||
expect(secondListener).toHaveBeenCalledWith('hello');
|
||||
|
||||
expect(consoleErrorSpy).toHaveBeenCalledOnce();
|
||||
expect(consoleErrorSpy).toHaveBeenCalledWith(new Error('listener failure'));
|
||||
|
||||
// Remove the mock on console.error
|
||||
consoleErrorSpy.mockRestore();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user