Skip to content

Commit

Permalink
refactor: avoid using expect.assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Feb 1, 2023
1 parent 9884889 commit e0df2d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2115,24 +2115,27 @@ describe('events', () => {
});

it('should emit the websocket connection error', (done) => {
expect.assertions(3);
const gotErr = jest.fn();
createClient({
url: 'ws://localhost/i/dont/exist',
lazy: false,
retryAttempts: 0,
onNonLazyError: (err) => {
// connection error
expect((err as ErrorEvent).message).toContain('connect ECONNREFUSED');
expect(gotErr).toBeCalledTimes(2);
done();
},
on: {
closed: (err) => {
// websocket closed
expect((err as CloseEvent).code).toBe(1006);
gotErr();
},
error: (err) => {
// connection error
expect((err as ErrorEvent).message).toContain('connect ECONNREFUSED');
gotErr();
},
},
});
Expand Down

0 comments on commit e0df2d4

Please sign in to comment.