diff --git a/package-lock.json b/package-lock.json index c8578b82..de6e2880 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "eslint": "^8.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.25.4", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "fetch-mock": "^9.11.0", "jest": "^26.6.3", "jest-websocket-mock": "^2.3.0", @@ -2948,19 +2948,19 @@ "dev": true }, "node_modules/eslint-plugin-jest": { - "version": "26.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.9.0.tgz", - "integrity": "sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng==", + "version": "27.0.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.0.4.tgz", + "integrity": "sha512-BuvY78pHMpMJ6Cio7sKg6jrqEcnRYPUc4Nlihku4vKx3FjlmMINSX4vcYokZIe+8TKcyr1aI5Kq7vYwgJNdQSA==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.10.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { "@typescript-eslint/eslint-plugin": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "@typescript-eslint/eslint-plugin": { @@ -10689,9 +10689,9 @@ } }, "eslint-plugin-jest": { - "version": "26.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.9.0.tgz", - "integrity": "sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng==", + "version": "27.0.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.0.4.tgz", + "integrity": "sha512-BuvY78pHMpMJ6Cio7sKg6jrqEcnRYPUc4Nlihku4vKx3FjlmMINSX4vcYokZIe+8TKcyr1aI5Kq7vYwgJNdQSA==", "dev": true, "requires": { "@typescript-eslint/utils": "^5.10.0" diff --git a/package.json b/package.json index 03572598..c72fcef3 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint": "^8.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.25.4", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "fetch-mock": "^9.11.0", "jest": "^26.6.3", "jest-websocket-mock": "^2.3.0", diff --git a/test/cache/fallbackCache.test.ts b/test/cache/fallbackCache.test.ts index d51c2b38..c66ed315 100644 --- a/test/cache/fallbackCache.test.ts +++ b/test/cache/fallbackCache.test.ts @@ -20,13 +20,13 @@ describe('An fallback cache', () => { expect(cache.get()).toBeNull(); - expect(firstCache.get).toBeCalledTimes(1); - expect(secondCache.get).toBeCalledTimes(1); + expect(firstCache.get).toHaveBeenCalledTimes(1); + expect(secondCache.get).toHaveBeenCalledTimes(1); expect(cache.get()).toBe('foo'); - expect(firstCache.get).toBeCalledTimes(2); - expect(secondCache.get).toBeCalledTimes(1); + expect(firstCache.get).toHaveBeenCalledTimes(2); + expect(secondCache.get).toHaveBeenCalledTimes(1); }); test('should store data into all underlying caches', async () => { @@ -46,10 +46,10 @@ describe('An fallback cache', () => { cache.put('bar'); - expect(firstCache.put).toBeCalledTimes(1); - expect(firstCache.put).toBeCalledWith('bar'); - expect(secondCache.put).toBeCalledTimes(1); - expect(secondCache.put).toBeCalledWith('bar'); + expect(firstCache.put).toHaveBeenCalledTimes(1); + expect(firstCache.put).toHaveBeenCalledWith('bar'); + expect(secondCache.put).toHaveBeenCalledTimes(1); + expect(secondCache.put).toHaveBeenCalledWith('bar'); }); test('should clear all underlying caches', async () => { @@ -69,7 +69,7 @@ describe('An fallback cache', () => { cache.clear(); - expect(firstCache.clear).toBeCalledTimes(1); - expect(secondCache.clear).toBeCalledTimes(1); + expect(firstCache.clear).toHaveBeenCalledTimes(1); + expect(secondCache.clear).toHaveBeenCalledTimes(1); }); }); diff --git a/test/channel/encodedChannel.test.ts b/test/channel/encodedChannel.test.ts index 32f9a1df..052e4ab6 100644 --- a/test/channel/encodedChannel.test.ts +++ b/test/channel/encodedChannel.test.ts @@ -20,12 +20,12 @@ describe('An encoded channel', () => { test('should encode and then publish the message', async () => { await channel.publish('ping'); - expect(outputChannel.publish).toBeCalledWith('ping-pong'); + expect(outputChannel.publish).toHaveBeenCalledWith('ping-pong'); }); test('should close the output channel on close', async () => { await channel.close(); - expect(outputChannel.close).toBeCalled(); + expect(outputChannel.close).toHaveBeenCalled(); }); }); diff --git a/test/channel/retryChannel.test.ts b/test/channel/retryChannel.test.ts index f1284926..ac0f3565 100644 --- a/test/channel/retryChannel.test.ts +++ b/test/channel/retryChannel.test.ts @@ -125,6 +125,6 @@ describe('A retry channel', () => { await channel.close(); - expect(outputChannel.close).toBeCalled(); + expect(outputChannel.close).toHaveBeenCalled(); }); }); diff --git a/test/channel/socketChannel.test.ts b/test/channel/socketChannel.test.ts index 1f6ac3dc..1efa74e1 100644 --- a/test/channel/socketChannel.test.ts +++ b/test/channel/socketChannel.test.ts @@ -43,7 +43,7 @@ describe('A socket channel', () => { socket.close({code: 1011, reason: 'Server error', wasClean: false}); }); - await expect(channel.publish('foo')).rejects.toThrowError(); + await expect(channel.publish('foo')).rejects.toThrow(); }); test('should reconnect if the connection cannot be established', async () => { @@ -59,7 +59,7 @@ describe('A socket channel', () => { attempt += 1; }); - await expect(channel.publish('foo')).rejects.toThrowError(); + await expect(channel.publish('foo')).rejects.toThrow(); await expect(channel.publish('bar')).resolves.toBeUndefined(); }); @@ -209,7 +209,7 @@ describe('A socket channel', () => { test('should close connection with error', async () => { const channel = new SocketChannel({url: url}); - await expect(channel.publish('open connection')).rejects.toThrowError(); + await expect(channel.publish('open connection')).rejects.toThrow(); await expect(channel.close()).resolves.toBeUndefined(); }); diff --git a/test/container.test.ts b/test/container.test.ts index dc0cb94f..782b3ab0 100644 --- a/test/container.test.ts +++ b/test/container.test.ts @@ -154,7 +154,7 @@ test('should flush the beacon queue on initialization', async () => { const promise = tracker.track(payload); await container.dispose(); - await expect(promise).rejects.toThrowError(); + await expect(promise).rejects.toThrow(); const server = new WS(`${configuration.trackerEndpointUrl}/${configuration.appId}`, {jsonProtocol: true}); diff --git a/test/facade/sdkFacade.test.ts b/test/facade/sdkFacade.test.ts index 7b9fd99a..f5e8dc06 100644 --- a/test/facade/sdkFacade.test.ts +++ b/test/facade/sdkFacade.test.ts @@ -73,7 +73,7 @@ describe('A SDK facade', () => { SdkFacade.init({appId: appId}); - expect(initialize).toBeCalledWith({ + expect(initialize).toHaveBeenCalledWith({ appId: appId, tokenScope: 'global', debug: false, @@ -101,7 +101,7 @@ describe('A SDK facade', () => { urlSanitizer: urlSanitizer, }); - expect(initialize).toBeCalledWith({ + expect(initialize).toHaveBeenCalledWith({ appId: appId, trackerEndpointUrl: 'https://api.croct.io/tracker', evaluationEndpointUrl: 'https://api.croct.io/evaluation', @@ -134,8 +134,8 @@ describe('A SDK facade', () => { track: false, }); - expect(context.setToken).toBeCalledWith(carolToken); - expect(context.setToken).toBeCalledTimes(1); + expect(context.setToken).toHaveBeenCalledWith(carolToken); + expect(context.setToken).toHaveBeenCalledTimes(1); }); test('should load the SDK and unset any existing token', () => { @@ -158,7 +158,7 @@ describe('A SDK facade', () => { track: false, }); - expect(context.setToken).toBeCalledWith(null); + expect(context.setToken).toHaveBeenCalledWith(null); }); test('should load the SDK and set a token for the provided user ID', () => { @@ -183,8 +183,8 @@ describe('A SDK facade', () => { track: false, }); - expect(context.setToken).toBeCalledWith(Token.issue(appId, 'c4r0l')); - expect(context.setToken).toBeCalledTimes(1); + expect(context.setToken).toHaveBeenCalledWith(Token.issue(appId, 'c4r0l')); + expect(context.setToken).toHaveBeenCalledTimes(1); }); test('should load the SDK with the tracker enabled if the flag "track" is true', () => { @@ -205,7 +205,7 @@ describe('A SDK facade', () => { track: true, }); - expect(tracker.enable).toBeCalledTimes(1); + expect(tracker.enable).toHaveBeenCalledTimes(1); }); test('should load the SDK with the tracker disabled if the flag "track" is false', () => { @@ -322,7 +322,7 @@ describe('A SDK facade', () => { await expect(sdkFacade.evaluator.evaluate('1 + 1', {timeout: 5})).resolves.toBe(result); expect(evaluator.evaluate).toHaveBeenCalledWith('1 + 1', expect.objectContaining({timeout: 5})); - expect(evaluator.evaluate).toBeCalledTimes(1); + expect(evaluator.evaluate).toHaveBeenCalledTimes(1); }); test('should provide the context', () => { @@ -369,8 +369,8 @@ describe('A SDK facade', () => { sdkFacade.identify('c4r0l'); - expect(context.setToken).toBeCalledWith(Token.issue(appId, 'c4r0l')); - expect(context.setToken).toBeCalledTimes(1); + expect(context.setToken).toHaveBeenCalledWith(Token.issue(appId, 'c4r0l')); + expect(context.setToken).toHaveBeenCalledTimes(1); }); test('should allow anonymizing a user', () => { @@ -423,7 +423,7 @@ describe('A SDK facade', () => { sdkFacade.unsetToken(); - expect(context.setToken).toBeCalledTimes(0); + expect(context.setToken).toHaveBeenCalledTimes(0); sdkFacade.setToken(Token.issue(appId, 'c4r0l')); @@ -453,8 +453,8 @@ describe('A SDK facade', () => { sdkFacade.setToken(carolToken); - expect(context.setToken).toBeCalledWith(carolToken); - expect(context.setToken).toBeCalledTimes(1); + expect(context.setToken).toHaveBeenCalledWith(carolToken); + expect(context.setToken).toHaveBeenCalledTimes(1); }); test('should provide the current token', () => { @@ -517,7 +517,7 @@ describe('A SDK facade', () => { expect(sdkFacade.getToken()).toEqual(newToken); - expect(tracker.track).toBeCalledTimes(0); + expect(tracker.track).toHaveBeenCalledTimes(0); }); test('should allow to refresh the token of the current identified user', () => { @@ -558,8 +558,8 @@ describe('A SDK facade', () => { expect(sdkFacade.getToken()).toEqual(newCarolToken); - expect(tracker.track).toBeCalledTimes(1); - expect(tracker.track).toBeCalledWith({ + expect(tracker.track).toHaveBeenCalledTimes(1); + expect(tracker.track).toHaveBeenCalledWith({ type: 'userSignedIn', userId: 'c4r0l', }); diff --git a/test/queue/monitoredQueue.test.ts b/test/queue/monitoredQueue.test.ts index b39d7920..3f26fb1f 100644 --- a/test/queue/monitoredQueue.test.ts +++ b/test/queue/monitoredQueue.test.ts @@ -130,7 +130,7 @@ describe('A monitored queue', () => { queue.addCallback(status, callback); - expect(callback).toBeCalledWith(queue); + expect(callback).toHaveBeenCalledWith(queue); }); test('should allow to remove a callback', () => { @@ -143,8 +143,8 @@ describe('A monitored queue', () => { queue.removeCallback('full', callback); queue.push('bar'); - expect(callback).toBeCalledWith(queue); - expect(callback).toBeCalledTimes(1); + expect(callback).toHaveBeenCalledWith(queue); + expect(callback).toHaveBeenCalledTimes(1); }); test('should not fail to remove an nonexistent callback', () => { @@ -154,6 +154,6 @@ describe('A monitored queue', () => { queue.removeCallback('full', callback); queue.push('foo'); - expect(callback).not.toBeCalled(); + expect(callback).not.toHaveBeenCalled(); }); }); diff --git a/test/schemas/loggerSchema.test.ts b/test/schemas/loggerSchema.test.ts index abd3be7e..d4b07dd7 100644 --- a/test/schemas/loggerSchema.test.ts +++ b/test/schemas/loggerSchema.test.ts @@ -10,7 +10,7 @@ describe('The logger schema', () => { extra: true, }; - expect(() => loggerSchema.validate(logger)).not.toThrowError(); + expect(() => loggerSchema.validate(logger)).not.toThrow(); }); test.each([ diff --git a/test/tracker.test.ts b/test/tracker.test.ts index 4d9a2c7d..588c6eca 100644 --- a/test/tracker.test.ts +++ b/test/tracker.test.ts @@ -125,13 +125,13 @@ describe('A tracker', () => { tracker.suspend(); - await expect(tracker.track(event, 1)).rejects.toThrowError(); + await expect(tracker.track(event, 1)).rejects.toThrow(); tracker.unsuspend(); await expect(tracker.track(event, 2)).resolves.toBeDefined(); - await expect(tracker.track(event, 3)).rejects.toThrowError(); + await expect(tracker.track(event, 3)).rejects.toThrow(); // Listeners can be added more than once, should remove both tracker.addListener(listener); @@ -169,7 +169,7 @@ describe('A tracker', () => { ...eventInfo, }); - expect(listener).toBeCalledTimes(5); + expect(listener).toHaveBeenCalledTimes(5); }); test('should allow to be enabled even if it is suspended', () => { @@ -389,7 +389,7 @@ describe('A tracker', () => { sinceTime: 0, }); - expect(channel.publish).toBeCalledWith( + expect(channel.publish).toHaveBeenCalledWith( expect.objectContaining({ context: expect.objectContaining({ metadata: metadata, @@ -421,7 +421,7 @@ describe('A tracker', () => { sinceTime: 0, }); - expect(channel.publish).toBeCalledWith( + expect(channel.publish).toHaveBeenCalledWith( expect.objectContaining({ token: token.toString(), }), @@ -1248,7 +1248,7 @@ describe('A tracker', () => { await expect(tracker.flushed).resolves.toBeUndefined(); - expect(publish).toBeCalledWith({ + expect(publish).toHaveBeenCalledWith({ timestamp: now, context: { tabId: tab.id, diff --git a/test/validation/jsonType.test.ts b/test/validation/jsonType.test.ts index 2b31e07d..a5e3d8a1 100644 --- a/test/validation/jsonType.test.ts +++ b/test/validation/jsonType.test.ts @@ -72,7 +72,7 @@ describe('A JSON object type', () => { objectType.validate({foobar: 'baz'}); } - expect(validateValidValue).not.toThrowError(); + expect(validateValidValue).not.toThrow(); expect(validateInvalidValue).toThrow(Error); expect(validateInvalidValue).toThrow('Expected at most 3 characters at path \'/foobar\', actual 6.'); });