diff --git a/src/index.test.ts b/src/index.test.ts index 79eb05f..fcb8a00 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -613,6 +613,7 @@ test('Should abort previous request', async () => { appName: 'web', }; const client = new UnleashClient(config); + await client.start(); client.updateContext({ userId: '123' }); // abort 1 client.updateContext({ userId: '456' }); // abort 2 @@ -622,6 +623,25 @@ test('Should abort previous request', async () => { abortSpy.mockRestore(); }); +test('Should not trigger error on abort', async () => { + fetchMock.mockResponse(JSON.stringify(data)); + + const config: IConfig = { + url: 'http://localhost/test', + clientKey: '12', + appName: 'web', + }; + const client = new UnleashClient(config); + client.on(EVENTS.ERROR, () => { + throw new Error('abort should not trigger error'); + }); + + await client.start(); + + fetchMock.mockAbort(); + await client.updateContext({ userId: '789' }); +}); + test.each([400, 401, 403, 404, 429, 500, 502, 503])( 'Should publish error when fetch receives a %d error', async (errorCode) => {