diff --git a/.changeset/renovate-4f0c2e3.md b/.changeset/renovate-4f0c2e3.md index b1f816f73dad8..0aab9dc9a61bf 100644 --- a/.changeset/renovate-4f0c2e3.md +++ b/.changeset/renovate-4f0c2e3.md @@ -8,3 +8,6 @@ Note that this major update to the Jest plugin contains some breaking changes. This means that some of your tests may start seeing some new lint errors. [Read about them here](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md#2700-2022-08-28). + +These are mostly possible to fix automatically. You can try to run `yarn backstage-cli repo lint --fix` in your repo root to have most or all of them +corrected. diff --git a/packages/backend-common/src/cache/CacheManager.test.ts b/packages/backend-common/src/cache/CacheManager.test.ts index 82c04f2cddefc..3649309a2de6b 100644 --- a/packages/backend-common/src/cache/CacheManager.test.ts +++ b/packages/backend-common/src/cache/CacheManager.test.ts @@ -65,7 +65,7 @@ describe('CacheManager', () => { const config = new ConfigReader({ backend: {} }); expect(() => { CacheManager.fromConfig(config); - }).not.toThrowError(); + }).not.toThrow(); }); it('throws on unknown cache store', () => { @@ -74,7 +74,7 @@ describe('CacheManager', () => { }); expect(() => { CacheManager.fromConfig(config); - }).toThrowError(); + }).toThrow(); }); }); diff --git a/packages/backend-common/src/context/AbortContext.test.ts b/packages/backend-common/src/context/AbortContext.test.ts index f47e1d4beb947..f69e282d2808d 100644 --- a/packages/backend-common/src/context/AbortContext.test.ts +++ b/packages/backend-common/src/context/AbortContext.test.ts @@ -37,12 +37,12 @@ describe('AbortContext', () => { expect(child.abortSignal.aborted).toBe(false); expect(Math.abs(+child.deadline! - deadline)).toBeLessThan(50); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); jest.advanceTimersByTime(timeout + 1); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(1); + expect(childListener).toHaveBeenCalledTimes(1); }); it('results in minimum deadline when parent triggers sooner', async () => { @@ -66,15 +66,15 @@ describe('AbortContext', () => { expect(child.abortSignal.aborted).toBe(false); expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50); expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); jest.advanceTimersByTime(parentTimeout + 1); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(1); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(1); + expect(childListener).toHaveBeenCalledTimes(1); }); it('results in minimum deadline when child triggers sooner', async () => { @@ -98,22 +98,22 @@ describe('AbortContext', () => { expect(child.abortSignal.aborted).toBe(false); expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50); expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); jest.advanceTimersByTime(childTimeout + 1); expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(1); jest.advanceTimersByTime(parentTimeout - childTimeout + 1); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(1); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(1); + expect(childListener).toHaveBeenCalledTimes(1); }); it('child carries over parent signal state if parent was already aborted and had no deadline', async () => { @@ -133,13 +133,13 @@ describe('AbortContext', () => { child.abortSignal.addEventListener('abort', childListener); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50); jest.advanceTimersByTime(childTimeout + 1); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); // still + expect(childListener).toHaveBeenCalledTimes(0); // still }); it('child carries over parent signal state if parent was already aborted and had a deadline', async () => { @@ -175,15 +175,15 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(false); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); parentController.abort(); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(1); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(1); + expect(childListener).toHaveBeenCalledTimes(1); }); it('does not signal parent when child is aborted', async () => { @@ -201,15 +201,15 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(false); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); childController.abort(); expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(1); }); it('child carries over parent signal state if parent was already aborted', async () => { @@ -227,13 +227,13 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); childController.abort(); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); }); it('child carries over given signal state if it was already aborted', async () => { @@ -247,7 +247,7 @@ describe('AbortContext', () => { child.abortSignal.addEventListener('abort', childListener); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); }); }); @@ -267,15 +267,15 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(false); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); parentController.abort(); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(1); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(1); + expect(childListener).toHaveBeenCalledTimes(1); }); it('does not signal parent when child is aborted', async () => { @@ -293,15 +293,15 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(false); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(0); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); childController.abort(); expect(parent.abortSignal.aborted).toBe(false); expect(child.abortSignal.aborted).toBe(true); - expect(parentListener).toBeCalledTimes(0); - expect(childListener).toBeCalledTimes(1); + expect(parentListener).toHaveBeenCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(1); }); it('child carries over parent signal state if parent was already aborted', async () => { @@ -319,13 +319,13 @@ describe('AbortContext', () => { expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); childController.abort(); expect(parent.abortSignal.aborted).toBe(true); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); }); it('child carries over given signal state if it was already aborted', async () => { @@ -339,7 +339,7 @@ describe('AbortContext', () => { child.abortSignal.addEventListener('abort', childListener); expect(child.abortSignal.aborted).toBe(true); - expect(childListener).toBeCalledTimes(0); + expect(childListener).toHaveBeenCalledTimes(0); }); }); }); diff --git a/packages/backend-common/src/database/connection.test.ts b/packages/backend-common/src/database/connection.test.ts index 044f80757684d..caf2fccc30fdb 100644 --- a/packages/backend-common/src/database/connection.test.ts +++ b/packages/backend-common/src/database/connection.test.ts @@ -110,7 +110,7 @@ describe('database connection', () => { connection: '', }), ), - ).toThrowError(); + ).toThrow(); }); it('throws an error without a connection', () => { @@ -120,7 +120,7 @@ describe('database connection', () => { client: 'pg', }), ), - ).toThrowError(); + ).toThrow(); }); }); @@ -147,7 +147,7 @@ describe('database connection', () => { }); it('throws an error for unknown connection', () => { - expect(() => createNameOverride('unknown', 'testname')).toThrowError(); + expect(() => createNameOverride('unknown', 'testname')).toThrow(); }); }); diff --git a/packages/backend-common/src/database/connectors/postgres.test.ts b/packages/backend-common/src/database/connectors/postgres.test.ts index 553d019573955..39c9af5ef3068 100644 --- a/packages/backend-common/src/database/connectors/postgres.test.ts +++ b/packages/backend-common/src/database/connectors/postgres.test.ts @@ -194,7 +194,7 @@ describe('postgres', () => { 'postgresql://postgres:pass@localhost:5432/dbname?sslrootcert=/path/to/file', ), ), - ).toThrowError(/no such file or directory/); + ).toThrow(/no such file or directory/); }); }); diff --git a/packages/backend-common/src/reading/GithubUrlReader.test.ts b/packages/backend-common/src/reading/GithubUrlReader.test.ts index 8e59b8d9026ec..fddb7286489a7 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.test.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.test.ts @@ -551,7 +551,7 @@ describe('GithubUrlReader', () => { credentialsProvider: mockCredentialsProvider, }, ); - }).toThrowError('must configure an explicit apiBaseUrl'); + }).toThrow('must configure an explicit apiBaseUrl'); }); }); diff --git a/packages/backend-common/src/reading/GoogleGcsUrlReader.test.ts b/packages/backend-common/src/reading/GoogleGcsUrlReader.test.ts index 0ae6b1f883526..66edbcc49acd9 100644 --- a/packages/backend-common/src/reading/GoogleGcsUrlReader.test.ts +++ b/packages/backend-common/src/reading/GoogleGcsUrlReader.test.ts @@ -127,7 +127,7 @@ describe('GcsUrlReader', () => { it('throws if search url looks truly glob-y', async () => { const glob = 'https://storage.cloud.google.com/bucket/**/path*'; - await expect(() => reader.search(glob)).rejects.toThrowError( + await expect(() => reader.search(glob)).rejects.toThrow( 'GcsUrlReader only supports prefix-based searches', ); }); diff --git a/packages/backend-common/src/reading/ReadUrlResponseFactory.test.ts b/packages/backend-common/src/reading/ReadUrlResponseFactory.test.ts index ff975de9bb4ec..880ab6f1d7060 100644 --- a/packages/backend-common/src/reading/ReadUrlResponseFactory.test.ts +++ b/packages/backend-common/src/reading/ReadUrlResponseFactory.test.ts @@ -55,7 +55,7 @@ describe('ReadUrlResponseFactory', () => { it('buffer cannot be called after stream is called', async () => { const response = await ReadUrlResponseFactory.fromReadable(readable); response.stream!(); - expect(() => response.buffer()).toThrowError(ConflictError); + expect(() => response.buffer()).toThrow(ConflictError); }); it('stream returns expected data', async () => { @@ -68,7 +68,7 @@ describe('ReadUrlResponseFactory', () => { it('stream cannot be called after buffer is called', async () => { const response = await ReadUrlResponseFactory.fromReadable(readable); response.buffer(); - expect(() => response.stream!()).toThrowError(ConflictError); + expect(() => response.stream!()).toThrow(ConflictError); }); }); diff --git a/packages/backend-common/src/reading/UrlReaderPredicateMux.test.ts b/packages/backend-common/src/reading/UrlReaderPredicateMux.test.ts index 527f26a9eceee..028439365c8b4 100644 --- a/packages/backend-common/src/reading/UrlReaderPredicateMux.test.ts +++ b/packages/backend-common/src/reading/UrlReaderPredicateMux.test.ts @@ -64,7 +64,7 @@ describe('UrlReaderPredicateMux', () => { it('throws an error if no predicate matches', async () => { const mux = new UrlReaderPredicateMux(getVoidLogger()); - await expect(mux.readUrl('http://foo/1')).rejects.toThrowError( + await expect(mux.readUrl('http://foo/1')).rejects.toThrow( /^Reading from 'http:\/\/foo\/1' is not allowed. You may/, ); @@ -80,7 +80,7 @@ describe('UrlReaderPredicateMux', () => { await expect(mux.readUrl('http://foo/1')).resolves.toBeUndefined(); - await expect(mux.readUrl('http://bar/1')).rejects.toThrowError( + await expect(mux.readUrl('http://bar/1')).rejects.toThrow( /^Reading from 'http:\/\/bar\/1' is not allowed. You may/, ); }); diff --git a/packages/backend-common/src/tokens/ServerTokenManager.test.ts b/packages/backend-common/src/tokens/ServerTokenManager.test.ts index cc7854b2ee185..cb17cbe6dd98e 100644 --- a/packages/backend-common/src/tokens/ServerTokenManager.test.ts +++ b/packages/backend-common/src/tokens/ServerTokenManager.test.ts @@ -66,9 +66,9 @@ describe('ServerTokenManager', () => { const tokenManager = ServerTokenManager.fromConfig(configWithSecret, { logger, }); - await expect( - tokenManager.authenticate('random-string'), - ).rejects.toThrowError(/invalid server token/i); + await expect(tokenManager.authenticate('random-string')).rejects.toThrow( + /invalid server token/i, + ); }); it('should validate server tokens created by a different instance using the same secret', async () => { @@ -129,7 +129,7 @@ describe('ServerTokenManager', () => { const { token } = await tokenManager1.getToken(); - await expect(tokenManager2.authenticate(token)).rejects.toThrowError( + await expect(tokenManager2.authenticate(token)).rejects.toThrow( /invalid server token/i, ); }); @@ -145,7 +145,7 @@ describe('ServerTokenManager', () => { const { token } = await noopTokenManager.getToken(); - await expect(tokenManager.authenticate(token)).rejects.toThrowError( + await expect(tokenManager.authenticate(token)).rejects.toThrow( /invalid server token/i, ); }); @@ -164,7 +164,7 @@ describe('ServerTokenManager', () => { const { token } = await tokenManager2.getToken(); - await expect(tokenManager1.authenticate(token)).rejects.toThrowError( + await expect(tokenManager1.authenticate(token)).rejects.toThrow( /invalid server token/i, ); }); diff --git a/packages/backend-tasks/src/tasks/LocalTaskWorker.test.ts b/packages/backend-tasks/src/tasks/LocalTaskWorker.test.ts index bdbd976def410..b81f7ab1c24a0 100644 --- a/packages/backend-tasks/src/tasks/LocalTaskWorker.test.ts +++ b/packages/backend-tasks/src/tasks/LocalTaskWorker.test.ts @@ -37,16 +37,16 @@ describe('LocalTaskWorker', () => { ); // TODO(freben): Rewrite to fake timers - tried, but it wouldn't work - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 100)); - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 200)); - expect(fn).toBeCalledTimes(1); + expect(fn).toHaveBeenCalledTimes(1); await new Promise(r => setTimeout(r, 200)); - expect(fn).toBeCalledTimes(2); + expect(fn).toHaveBeenCalledTimes(2); controller.abort(); await new Promise(r => setTimeout(r, 200)); - expect(fn).toBeCalledTimes(2); + expect(fn).toHaveBeenCalledTimes(2); }); it('runs the happy path (with a cron expression) and handles cancellation', async () => { @@ -69,16 +69,16 @@ describe('LocalTaskWorker', () => { ); // TODO(freben): Rewrite to fake timers - tried, but it wouldn't work - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 100)); - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 200)); - expect(fn).toBeCalledTimes(1); + expect(fn).toHaveBeenCalledTimes(1); await new Promise(r => setTimeout(r, 1000)); - expect(fn).toBeCalledTimes(2); + expect(fn).toHaveBeenCalledTimes(2); controller.abort(); await new Promise(r => setTimeout(r, 1000)); - expect(fn).toBeCalledTimes(2); + expect(fn).toHaveBeenCalledTimes(2); }); it('can trigger to abort wait', async () => { @@ -93,13 +93,13 @@ describe('LocalTaskWorker', () => { }); // TODO(freben): Rewrite to fake timers - tried, but it wouldn't work - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 100)); - expect(fn).toBeCalledTimes(0); + expect(fn).toHaveBeenCalledTimes(0); await new Promise(r => setTimeout(r, 200)); - expect(fn).toBeCalledTimes(1); + expect(fn).toHaveBeenCalledTimes(1); worker.trigger(); await new Promise(r => setTimeout(r, 10)); - expect(fn).toBeCalledTimes(2); + expect(fn).toHaveBeenCalledTimes(2); }); }); diff --git a/packages/backend-tasks/src/tasks/TaskScheduler.test.ts b/packages/backend-tasks/src/tasks/TaskScheduler.test.ts index e59f24c277ddb..aa2db5a3644e0 100644 --- a/packages/backend-tasks/src/tasks/TaskScheduler.test.ts +++ b/packages/backend-tasks/src/tasks/TaskScheduler.test.ts @@ -53,7 +53,7 @@ describe('TaskScheduler', () => { }); await waitForExpect(() => { - expect(fn).toBeCalled(); + expect(fn).toHaveBeenCalled(); }); }, 60_000, @@ -74,7 +74,7 @@ describe('TaskScheduler', () => { }); await waitForExpect(() => { - expect(fn).toBeCalled(); + expect(fn).toHaveBeenCalled(); }); }, 60_000, diff --git a/packages/backend-tasks/src/tasks/TaskWorker.test.ts b/packages/backend-tasks/src/tasks/TaskWorker.test.ts index 8a1be3e8a9729..e631dcce5489b 100644 --- a/packages/backend-tasks/src/tasks/TaskWorker.test.ts +++ b/packages/backend-tasks/src/tasks/TaskWorker.test.ts @@ -138,7 +138,7 @@ describe('TaskWorker', () => { worker.start(settings); await waitForExpect(() => { - expect(logger.error).toBeCalled(); + expect(logger.error).toHaveBeenCalled(); }); }, 60_000, @@ -162,7 +162,7 @@ describe('TaskWorker', () => { worker.start(settings); await waitForExpect(() => { - expect(fn).toBeCalledTimes(3); + expect(fn).toHaveBeenCalledTimes(3); }); }, 60_000, @@ -309,9 +309,9 @@ describe('TaskWorker', () => { ); await worker1.start(settings, { signal: abortFirst.signal }); - expect(fn1).toBeCalledTimes(0); + expect(fn1).toHaveBeenCalledTimes(0); await new Promise(resolve => setTimeout(resolve, 250)); - expect(fn1).toBeCalledTimes(0); + expect(fn1).toHaveBeenCalledTimes(0); await new Promise(resolve => setTimeout(resolve, 100)); expect(fn1.mock.calls.length).toBeGreaterThan(0); diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts index 488a2583883d7..49309b201bc2c 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts @@ -92,6 +92,6 @@ describe('TestBackend', () => { features: [testModule({})], }); - expect(testFn).toBeCalledWith('winning'); + expect(testFn).toHaveBeenCalledWith('winning'); }); }); diff --git a/packages/catalog-model/src/EntityPolicies.test.ts b/packages/catalog-model/src/EntityPolicies.test.ts index c630094621cda..25b43ef9c6ff9 100644 --- a/packages/catalog-model/src/EntityPolicies.test.ts +++ b/packages/catalog-model/src/EntityPolicies.test.ts @@ -67,8 +67,8 @@ describe('EntityPolicies', () => { p2.enforce.mockResolvedValue(entity2); const policy = EntityPolicies.allOf([p1, p2]); await expect(policy.enforce(entity1)).resolves.toBe(entity2); - expect(p1.enforce).toBeCalledWith(entity1); - expect(p2.enforce).toBeCalledWith(entity2); + expect(p1.enforce).toHaveBeenCalledWith(entity1); + expect(p2.enforce).toHaveBeenCalledWith(entity2); }); }); diff --git a/packages/core-app-api/src/apis/implementations/FetchApi/PluginProtocolResolverFetchMiddleware.test.ts b/packages/core-app-api/src/apis/implementations/FetchApi/PluginProtocolResolverFetchMiddleware.test.ts index 157abf9d7cea3..3b4b7136bbdc0 100644 --- a/packages/core-app-api/src/apis/implementations/FetchApi/PluginProtocolResolverFetchMiddleware.test.ts +++ b/packages/core-app-api/src/apis/implementations/FetchApi/PluginProtocolResolverFetchMiddleware.test.ts @@ -31,7 +31,7 @@ describe('PluginProtocolResolverFetchMiddleware', () => { await outer(url); expect(inner.mock.calls[0][0]).toBe(url); - expect(resolve).not.toBeCalled(); + expect(resolve).not.toHaveBeenCalled(); }, ); diff --git a/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthPendingRequests.test.ts b/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthPendingRequests.test.ts index 20b0cbba675a7..53e2b56ab61af 100644 --- a/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthPendingRequests.test.ts +++ b/packages/core-app-api/src/apis/implementations/OAuthRequestApi/OAuthPendingRequests.test.ts @@ -27,7 +27,7 @@ describe('OAuthPendingRequests', () => { target.pending().subscribe({ next, error }); target.request(input); - await waitFor(() => expect(next).toBeCalledTimes(2)); + await waitFor(() => expect(next).toHaveBeenCalledTimes(2)); expect(next.mock.calls[0][0].scopes).toBeUndefined(); expect(next.mock.calls[1][0].scopes.toString()).toBe(input.toString()); expect(error.mock.calls.length).toBe(0); @@ -46,8 +46,8 @@ describe('OAuthPendingRequests', () => { await expect(request1).resolves.toBe('session1'); await expect(request2).resolves.toBe('session1'); - expect(next).toBeCalledTimes(3); // once on subscription, twice on resolve - expect(error).toBeCalledTimes(0); + expect(next).toHaveBeenCalledTimes(3); // once on subscription, twice on resolve + expect(error).toHaveBeenCalledTimes(0); }); it('can resolve through the observable', async () => { @@ -59,8 +59,8 @@ describe('OAuthPendingRequests', () => { target.pending().subscribe({ next, error }); await expect(request1).resolves.toBe('done'); - expect(next).toBeCalledTimes(2); // once with data on subscription, once empty after resolution - expect(error).toBeCalledTimes(0); + expect(next).toHaveBeenCalledTimes(2); // once with data on subscription, once empty after resolution + expect(error).toHaveBeenCalledTimes(0); }); it('rejects requests and notifies observers only once', async () => { @@ -77,8 +77,8 @@ describe('OAuthPendingRequests', () => { await expect(request1).rejects.toBe(rejection); await expect(request2).rejects.toBe(rejection); - expect(next).toBeCalledTimes(3); // once on subscription, once or reject, once on resolve - expect(error).toBeCalledTimes(0); + expect(next).toHaveBeenCalledTimes(3); // once on subscription, once or reject, once on resolve + expect(error).toHaveBeenCalledTimes(0); }); it('can reject through the observable', async () => { @@ -91,6 +91,6 @@ describe('OAuthPendingRequests', () => { target.pending().subscribe({ next, error }); await expect(request1).rejects.toBe(rejection); - expect(next).toBeCalledTimes(2); + expect(next).toHaveBeenCalledTimes(2); }); }); diff --git a/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.test.ts b/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.test.ts index b2398f64de793..0bb40c23fcc63 100644 --- a/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.test.ts +++ b/packages/core-app-api/src/apis/implementations/auth/oauth2/OAuth2.test.ts @@ -48,7 +48,7 @@ describe('OAuth2', () => { expect(await oauth2.getAccessToken('my-scope my-scope2')).toBe( 'access-token', ); - expect(getSession).toBeCalledTimes(1); + expect(getSession).toHaveBeenCalledTimes(1); expect(getSession.mock.calls[0][0].scopes).toEqual( new Set(['my-scope', 'my-scope2']), ); @@ -65,7 +65,7 @@ describe('OAuth2', () => { }); expect(await oauth2.getAccessToken('my-scope')).toBe('access-token'); - expect(getSession).toBeCalledTimes(1); + expect(getSession).toHaveBeenCalledTimes(1); expect(getSession.mock.calls[0][0].scopes).toEqual( new Set(['my-prefix/my-scope']), ); @@ -82,7 +82,7 @@ describe('OAuth2', () => { }); expect(await oauth2.getIdToken()).toBe('id-token'); - expect(getSession).toBeCalledTimes(1); + expect(getSession).toHaveBeenCalledTimes(1); }); it('should get optional id token', async () => { @@ -96,7 +96,7 @@ describe('OAuth2', () => { }); expect(await oauth2.getIdToken({ optional: true })).toBe('id-token'); - expect(getSession).toBeCalledTimes(1); + expect(getSession).toHaveBeenCalledTimes(1); }); it('should share popup closed errors', async () => { @@ -125,7 +125,7 @@ describe('OAuth2', () => { const promise2 = oauth2.getAccessToken('more'); await expect(promise1).rejects.toBe(error); await expect(promise2).rejects.toBe(error); - expect(getSession).toBeCalledTimes(3); + expect(getSession).toHaveBeenCalledTimes(3); }); it('should wait for all session refreshes', async () => { @@ -154,7 +154,7 @@ describe('OAuth2', () => { // Grab the expired session first await expect(oauth2.getIdToken()).resolves.toBe('token1'); - expect(getSession).toBeCalledTimes(1); + expect(getSession).toHaveBeenCalledTimes(1); initialSession.providerInfo.expiresAt = thePast; @@ -164,6 +164,6 @@ describe('OAuth2', () => { await expect(promise1).resolves.toBe('token2'); await expect(promise2).resolves.toBe('token2'); await expect(promise3).resolves.toBe('token2'); - expect(getSession).toBeCalledTimes(4); // De-duping of session requests happens in client + expect(getSession).toHaveBeenCalledTimes(4); // De-duping of session requests happens in client }); }); diff --git a/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.test.ts b/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.test.ts index 1a0a53347fbb4..2b132e09cdfc8 100644 --- a/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.test.ts +++ b/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.test.ts @@ -129,7 +129,7 @@ describe('DefaultAuthConnector', () => { await mockOauth.triggerAll(); - expect(popupSpy).toBeCalledTimes(1); + expect(popupSpy).toHaveBeenCalledTimes(1); expect(popupSpy.mock.calls[0][0]).toMatchObject({ url: 'http://my-host/api/auth/my-provider/start?scope=a%20b&origin=http%3A%2F%2Flocalhost&env=production', }); @@ -159,7 +159,7 @@ describe('DefaultAuthConnector', () => { await expect(sessionPromise).resolves.toBe('my-session'); - expect(popupSpy).toBeCalledTimes(1); + expect(popupSpy).toHaveBeenCalledTimes(1); }); it('should use join func to join scopes', async () => { @@ -177,7 +177,7 @@ describe('DefaultAuthConnector', () => { await mockOauth.triggerAll(); - expect(popupSpy).toBeCalledTimes(1); + expect(popupSpy).toHaveBeenCalledTimes(1); expect(popupSpy.mock.calls[0][0]).toMatchObject({ url: 'http://my-host/api/auth/my-provider/start?scope=-ab-&origin=http%3A%2F%2Flocalhost&env=production', }); diff --git a/packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts b/packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts index 41347d010682e..a94aca85f801c 100644 --- a/packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts +++ b/packages/core-app-api/src/lib/AuthSessionManager/RefreshingAuthSessionManager.test.ts @@ -38,16 +38,16 @@ describe('RefreshingAuthSessionManager', () => { expect(stateSubscriber.mock.calls).toEqual([[SessionState.SignedOut]]); await manager.getSession({}); - expect(createSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); expect(stateSubscriber.mock.calls).toEqual([ [SessionState.SignedOut], [SessionState.SignedIn], ]); await manager.getSession({}); - expect(createSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); - expect(refreshSession).toBeCalledTimes(1); + expect(refreshSession).toHaveBeenCalledTimes(1); expect(stateSubscriber.mock.calls).toEqual([ [SessionState.SignedOut], [SessionState.SignedIn], @@ -76,13 +76,13 @@ describe('RefreshingAuthSessionManager', () => { expired: false, }); await manager.getSession({ scopes: new Set(['a']) }); - expect(createSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); await manager.getSession({ scopes: new Set(['a']) }); - expect(createSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); await manager.getSession({ scopes: new Set(['b']) }); - expect(createSession).toBeCalledTimes(2); + expect(createSession).toHaveBeenCalledTimes(2); }); it('should check for session expiry', async () => { @@ -102,12 +102,12 @@ describe('RefreshingAuthSessionManager', () => { }); await manager.getSession({ scopes: new Set(['a']) }); - expect(createSession).toBeCalledTimes(1); - expect(refreshSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); + expect(refreshSession).toHaveBeenCalledTimes(1); await manager.getSession({ scopes: new Set(['a']) }); - expect(createSession).toBeCalledTimes(1); - expect(refreshSession).toBeCalledTimes(2); + expect(createSession).toHaveBeenCalledTimes(1); + expect(refreshSession).toHaveBeenCalledTimes(2); }); it('should handle user closed popup', async () => { @@ -133,8 +133,8 @@ describe('RefreshingAuthSessionManager', () => { } as any); expect(await manager.getSession({ optional: true })).toBe(undefined); - expect(createSession).toBeCalledTimes(0); - expect(refreshSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(0); + expect(refreshSession).toHaveBeenCalledTimes(1); }); it('should forward option to instantly show auth popup and not attempt refresh', async () => { @@ -146,12 +146,12 @@ describe('RefreshingAuthSessionManager', () => { } as any); expect(await manager.getSession({ instantPopup: true })).toBe(undefined); - expect(createSession).toBeCalledTimes(1); + expect(createSession).toHaveBeenCalledTimes(1); expect(createSession).toHaveBeenCalledWith({ scopes: new Set(), instantPopup: true, }); - expect(refreshSession).toBeCalledTimes(0); + expect(refreshSession).toHaveBeenCalledTimes(0); }); it('should remove session straight away', async () => { diff --git a/packages/core-app-api/src/lib/loginPopup.test.ts b/packages/core-app-api/src/lib/loginPopup.test.ts index db4d9eb8eb76d..50193cbdd66ed 100644 --- a/packages/core-app-api/src/lib/loginPopup.test.ts +++ b/packages/core-app-api/src/lib/loginPopup.test.ts @@ -35,13 +35,13 @@ describe('showLoginPopup', () => { origin: 'my-origin', }); - expect(openSpy).toBeCalledTimes(1); + expect(openSpy).toHaveBeenCalledTimes(1); expect(openSpy.mock.calls[0][0]).toBe( 'my-origin/api/backend/auth/start?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fa%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fb', ); expect(openSpy.mock.calls[0][1]).toBe('test-popup'); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(0); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(0); const listener = addEventListenerSpy.mock.calls[0][1] as EventListener; @@ -88,9 +88,9 @@ describe('showLoginPopup', () => { await expect(payloadPromise).resolves.toBe(myResponse); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(1); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(1); }); it('should fail if popup returns error', async () => { @@ -107,9 +107,9 @@ describe('showLoginPopup', () => { origin: 'my-origin', }); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(0); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(0); const listener = addEventListenerSpy.mock.calls[0][1] as EventListener; @@ -130,9 +130,9 @@ describe('showLoginPopup', () => { message: 'NOPE', }); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(1); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(1); }); it('should fail if popup is closed', async () => { @@ -151,9 +151,9 @@ describe('showLoginPopup', () => { origin: 'origin', }); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(0); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(0); const listener = addEventListenerSpy.mock.calls[0][1] as EventListener; listener({ @@ -172,9 +172,9 @@ describe('showLoginPopup', () => { 'Login failed, popup was closed', ); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(1); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(1); }); it('should indicate if origin does not match', async () => { @@ -210,8 +210,8 @@ describe('showLoginPopup', () => { 'Login failed, Incorrect app origin, expected http://differenthost', ); - expect(openSpy).toBeCalledTimes(1); - expect(addEventListenerSpy).toBeCalledTimes(1); - expect(removeEventListenerSpy).toBeCalledTimes(1); + expect(openSpy).toHaveBeenCalledTimes(1); + expect(addEventListenerSpy).toHaveBeenCalledTimes(1); + expect(removeEventListenerSpy).toHaveBeenCalledTimes(1); }); }); diff --git a/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInIdentity.test.ts b/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInIdentity.test.ts index 00e0c02373701..3c9b9c3f58b85 100644 --- a/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInIdentity.test.ts +++ b/packages/core-components/src/layout/ProxiedSignInPage/ProxiedSignInIdentity.test.ts @@ -121,9 +121,9 @@ describe('ProxiedSignInIdentity', () => { getBaseUrl.mockResolvedValue('http://example.com/api/auth'); await identity.start(); // should not throw - expect(getBaseUrl).toBeCalledTimes(1); - expect(getBaseUrl).lastCalledWith('auth'); - expect(serverCalled).toBeCalledTimes(1); + expect(getBaseUrl).toHaveBeenCalledTimes(1); + expect(getBaseUrl).toHaveBeenLastCalledWith('auth'); + expect(serverCalled).toHaveBeenCalledTimes(1); // All information should now be available await expect(identity.getBackstageIdentity()).resolves.toEqual({ @@ -148,7 +148,7 @@ describe('ProxiedSignInIdentity', () => { }); await identity.getSessionAsync(); // no need to fetch again just yet - expect(serverCalled).toBeCalledTimes(1); + expect(serverCalled).toHaveBeenCalledTimes(1); // Use a fairly large margin (1000) since the iat and exp are clamped to // full seconds, but the "local current time" isn't @@ -156,11 +156,11 @@ describe('ProxiedSignInIdentity', () => { 3600 * 1000 - DEFAULTS.tokenExpiryMarginMillis - 1000, ); await identity.getSessionAsync(); // still no need to fetch again - expect(serverCalled).toBeCalledTimes(1); + expect(serverCalled).toHaveBeenCalledTimes(1); jest.advanceTimersByTime(1001); await identity.getSessionAsync(); // now the expiry has passed - expect(serverCalled).toBeCalledTimes(2); + expect(serverCalled).toHaveBeenCalledTimes(2); }); }); }); diff --git a/packages/create-app/src/lib/tasks.test.ts b/packages/create-app/src/lib/tasks.test.ts index 0c92173dbf81d..7a8f85bf71b0c 100644 --- a/packages/create-app/src/lib/tasks.test.ts +++ b/packages/create-app/src/lib/tasks.test.ts @@ -130,10 +130,10 @@ describe('buildAppTask', () => { const appDir = 'projects/dir'; await expect(buildAppTask(appDir)).resolves.not.toThrow(); - expect(mockChdir).toBeCalledTimes(2); + expect(mockChdir).toHaveBeenCalledTimes(2); expect(mockChdir).toHaveBeenNthCalledWith(1, appDir); expect(mockChdir).toHaveBeenNthCalledWith(2, appDir); - expect(mockExec).toBeCalledTimes(2); + expect(mockExec).toHaveBeenCalledTimes(2); expect(mockExec).toHaveBeenNthCalledWith( 1, 'yarn install', diff --git a/packages/techdocs-cli/src/lib/PublisherConfig.test.ts b/packages/techdocs-cli/src/lib/PublisherConfig.test.ts index 24cad332ac733..7be274c3f2753 100644 --- a/packages/techdocs-cli/src/lib/PublisherConfig.test.ts +++ b/packages/techdocs-cli/src/lib/PublisherConfig.test.ts @@ -23,7 +23,7 @@ describe('getValidPublisherConfig', () => { publisherType: 'unknown publisher', } as unknown as OptionValues; - expect(() => PublisherConfig.getValidConfig(invalidConfig)).toThrowError( + expect(() => PublisherConfig.getValidConfig(invalidConfig)).toThrow( `Unknown publisher type ${invalidConfig.publisherType}`, ); }); @@ -34,7 +34,7 @@ describe('getValidPublisherConfig', () => { publisherType: 'azureBlobStorage', } as unknown as OptionValues; - expect(() => PublisherConfig.getValidConfig(config)).toThrowError( + expect(() => PublisherConfig.getValidConfig(config)).toThrow( 'azureBlobStorage requires --azureAccountName to be specified', ); }); @@ -104,7 +104,7 @@ describe('getValidPublisherConfig', () => { osSecret: 'someSecret', } as unknown as OptionValues; - expect(() => PublisherConfig.getValidConfig(config)).toThrowError( + expect(() => PublisherConfig.getValidConfig(config)).toThrow( `openStackSwift requires the following params to be specified: ${[ 'osAuthUrl', 'osSwiftUrl', diff --git a/packages/test-utils/src/testUtils/apis/FetchApi/MockFetchApi.test.ts b/packages/test-utils/src/testUtils/apis/FetchApi/MockFetchApi.test.ts index 78f12a10f118a..37b9d874f9e04 100644 --- a/packages/test-utils/src/testUtils/apis/FetchApi/MockFetchApi.test.ts +++ b/packages/test-utils/src/testUtils/apis/FetchApi/MockFetchApi.test.ts @@ -39,7 +39,7 @@ describe('MockFetchApi', () => { const inner = jest.fn(); const m = new MockFetchApi({ baseImplementation: inner }); await m.fetch('http://example.com/data.json'); - expect(inner).lastCalledWith('http://example.com/data.json'); + expect(inner).toHaveBeenLastCalledWith('http://example.com/data.json'); }); }); diff --git a/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.test.ts b/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.test.ts index 8a5182534d57e..c9c2a02c69037 100644 --- a/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.test.ts +++ b/plugins/analytics-module-ga/src/apis/implementations/AnalyticsApi/GoogleAnalytics.test.ts @@ -38,7 +38,7 @@ describe('GoogleAnalytics', () => { describe('fromConfig', () => { it('throws when missing trackingId', () => { const config = new ConfigReader({ app: { analytics: { ga: {} } } }); - expect(() => GoogleAnalytics.fromConfig(config)).toThrowError( + expect(() => GoogleAnalytics.fromConfig(config)).toThrow( /Missing required config value/, ); }); diff --git a/plugins/auth-backend/src/identity/FirestoreKeyStore.test.ts b/plugins/auth-backend/src/identity/FirestoreKeyStore.test.ts index 6a3ce87f82889..d28cbfa11a58c 100644 --- a/plugins/auth-backend/src/identity/FirestoreKeyStore.test.ts +++ b/plugins/auth-backend/src/identity/FirestoreKeyStore.test.ts @@ -109,8 +109,13 @@ describe('FirestoreKeyStore', () => { const keyStore = await FirestoreKeyStore.create(); await keyStore.addKey(key); - expect(setTimeout).toBeCalledWith(expect.any(Function), DEFAULT_TIMEOUT_MS); - expect(firestoreMock.collection).toBeCalledWith(DEFAULT_DOCUMENT_PATH); + expect(setTimeout).toHaveBeenCalledWith( + expect.any(Function), + DEFAULT_TIMEOUT_MS, + ); + expect(firestoreMock.collection).toHaveBeenCalledWith( + DEFAULT_DOCUMENT_PATH, + ); }); it('can handle a timeout', async () => { @@ -135,9 +140,9 @@ describe('FirestoreKeyStore', () => { const keyStore = await FirestoreKeyStore.create(firestoreSettings); await keyStore.addKey(key); - expect(setTimeout).toBeCalledTimes(1); - expect(firestoreMock.collection).toBeCalledWith(path); - expect(firestoreMock.doc).toBeCalledWith(key.kid); + expect(setTimeout).toHaveBeenCalledTimes(1); + expect(firestoreMock.collection).toHaveBeenCalledWith(path); + expect(firestoreMock.doc).toHaveBeenCalledWith(key.kid); expect(firestoreMock.set).toHaveBeenCalledWith({ kid: key.kid, key: JSON.stringify(key), @@ -148,32 +153,32 @@ describe('FirestoreKeyStore', () => { const keyStore = await FirestoreKeyStore.create(firestoreSettings); await keyStore.removeKeys(['123']); - expect(setTimeout).toBeCalledTimes(1); - expect(firestoreMock.collection).toBeCalledWith(path); - expect(firestoreMock.doc).toBeCalledWith('123'); - expect(firestoreMock.delete).toBeCalledTimes(1); + expect(setTimeout).toHaveBeenCalledTimes(1); + expect(firestoreMock.collection).toHaveBeenCalledWith(path); + expect(firestoreMock.doc).toHaveBeenCalledWith('123'); + expect(firestoreMock.delete).toHaveBeenCalledTimes(1); }); it('can delete a multiple keys', async () => { const keyStore = await FirestoreKeyStore.create(firestoreSettings); await keyStore.removeKeys(['123', '456']); - expect(setTimeout).toBeCalledTimes(2); - expect(firestoreMock.collection).toBeCalledWith(path); - expect(firestoreMock.doc).toBeCalledWith('123'); - expect(firestoreMock.doc).toBeCalledWith('456'); - expect(firestoreMock.delete).toBeCalledTimes(2); + expect(setTimeout).toHaveBeenCalledTimes(2); + expect(firestoreMock.collection).toHaveBeenCalledWith(path); + expect(firestoreMock.doc).toHaveBeenCalledWith('123'); + expect(firestoreMock.doc).toHaveBeenCalledWith('456'); + expect(firestoreMock.delete).toHaveBeenCalledTimes(2); }); it('can list keys', async () => { const keyStore = await FirestoreKeyStore.create(firestoreSettings); const items = await keyStore.listKeys(); - expect(setTimeout).toBeCalledTimes(1); - expect(firestoreMock.collection).toBeCalledWith(path); - expect(firestoreMock.get).toBeCalledTimes(1); - expect(data).toBeCalledTimes(1); - expect(toDate).toBeCalledTimes(1); + expect(setTimeout).toHaveBeenCalledTimes(1); + expect(firestoreMock.collection).toHaveBeenCalledWith(path); + expect(firestoreMock.get).toHaveBeenCalledTimes(1); + expect(data).toHaveBeenCalledTimes(1); + expect(toDate).toHaveBeenCalledTimes(1); expect(items).toMatchObject({ items: [{ key: 'data', createdAt: 'date' }], }); diff --git a/plugins/auth-backend/src/identity/TokenFactory.test.ts b/plugins/auth-backend/src/identity/TokenFactory.test.ts index 291359676f753..9a163b3ff5bc5 100644 --- a/plugins/auth-backend/src/identity/TokenFactory.test.ts +++ b/plugins/auth-backend/src/identity/TokenFactory.test.ts @@ -128,7 +128,7 @@ describe('TokenFactory', () => { return factory.issueToken({ claims: { sub: 'UserId' }, }); - }).rejects.toThrowError(); + }).rejects.toThrow(); }); it('should throw error on empty algorithm string', async () => { @@ -145,7 +145,7 @@ describe('TokenFactory', () => { return factory.issueToken({ claims: { sub: 'UserId' }, }); - }).rejects.toThrowError(); + }).rejects.toThrow(); }); it('should defaults to ES256 when no algorithm string is supplied', async () => { diff --git a/plugins/auth-backend/src/lib/flow/authFlowHelpers.test.ts b/plugins/auth-backend/src/lib/flow/authFlowHelpers.test.ts index 87e6b9674537a..a0c437815d6c5 100644 --- a/plugins/auth-backend/src/lib/flow/authFlowHelpers.test.ts +++ b/plugins/auth-backend/src/lib/flow/authFlowHelpers.test.ts @@ -62,9 +62,11 @@ describe('oauth helpers', () => { const encoded = safelyEncodeURIComponent(JSON.stringify(data)); postMessageResponse(mockResponse, appOrigin, data); - expect(mockResponse.setHeader).toBeCalledTimes(3); - expect(mockResponse.end).toBeCalledTimes(1); - expect(mockResponse.end).toBeCalledWith(expect.stringContaining(encoded)); + expect(mockResponse.setHeader).toHaveBeenCalledTimes(3); + expect(mockResponse.end).toHaveBeenCalledTimes(1); + expect(mockResponse.end).toHaveBeenCalledWith( + expect.stringContaining(encoded), + ); }); it('should post a message back with payload error', () => { @@ -80,9 +82,11 @@ describe('oauth helpers', () => { const encoded = safelyEncodeURIComponent(JSON.stringify(data)); postMessageResponse(mockResponse, appOrigin, data); - expect(mockResponse.setHeader).toBeCalledTimes(3); - expect(mockResponse.end).toBeCalledTimes(1); - expect(mockResponse.end).toBeCalledWith(expect.stringContaining(encoded)); + expect(mockResponse.setHeader).toHaveBeenCalledTimes(3); + expect(mockResponse.end).toHaveBeenCalledTimes(1); + expect(mockResponse.end).toHaveBeenCalledWith( + expect.stringContaining(encoded), + ); }); it('should call postMessage twice but only one of them with target *', () => { @@ -166,9 +170,9 @@ describe('oauth helpers', () => { }; postMessageResponse(mockResponse, appOrigin, data); - expect(mockResponse.setHeader).toBeCalledTimes(3); - expect(mockResponse.end).toBeCalledTimes(1); - expect(mockResponse.end).toBeCalledWith( + expect(mockResponse.setHeader).toHaveBeenCalledTimes(3); + expect(mockResponse.end).toHaveBeenCalledTimes(1); + expect(mockResponse.end).toHaveBeenCalledWith( expect.stringContaining('Adam%20l%27H%C3%B4pital'), ); }); diff --git a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts index d6d346745ac95..9dcd76e92eb2c 100644 --- a/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts +++ b/plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts @@ -92,8 +92,8 @@ describe('OAuthAdapter', () => { await oauthProvider.start(mockRequest, mockResponse); // nonce cookie checks - expect(mockResponse.cookie).toBeCalledTimes(1); - expect(mockResponse.cookie).toBeCalledWith( + expect(mockResponse.cookie).toHaveBeenCalledTimes(1); + expect(mockResponse.cookie).toHaveBeenCalledWith( `${oAuthProviderOptions.providerId}-nonce`, expect.any(String), expect.objectContaining({ maxAge: TEN_MINUTES_MS }), @@ -323,8 +323,8 @@ describe('OAuthAdapter', () => { await oauthProvider.start(mockRequest, mockResponse); - expect(mockResponse.cookie).toBeCalledTimes(1); - expect(mockResponse.cookie).toBeCalledWith( + expect(mockResponse.cookie).toHaveBeenCalledTimes(1); + expect(mockResponse.cookie).toHaveBeenCalledWith( `${oAuthProviderOptions.providerId}-nonce`, expect.any(String), expect.objectContaining({ diff --git a/plugins/auth-backend/src/lib/oauth/helpers.test.ts b/plugins/auth-backend/src/lib/oauth/helpers.test.ts index 2f79cdef9846b..b3052c93e11ce 100644 --- a/plugins/auth-backend/src/lib/oauth/helpers.test.ts +++ b/plugins/auth-backend/src/lib/oauth/helpers.test.ts @@ -64,7 +64,7 @@ describe('OAuthProvider Utils', () => { } as unknown as express.Request; expect(() => { verifyNonce(mockRequest, 'providera'); - }).toThrowError('Auth response is missing cookie nonce'); + }).toThrow('Auth response is missing cookie nonce'); }); it('should throw error if state nonce missing', () => { @@ -76,7 +76,7 @@ describe('OAuthProvider Utils', () => { } as unknown as express.Request; expect(() => { verifyNonce(mockRequest, 'providera'); - }).toThrowError('Invalid state passed via request'); + }).toThrow('Invalid state passed via request'); }); it('should throw error if nonce mismatch', () => { @@ -91,7 +91,7 @@ describe('OAuthProvider Utils', () => { } as unknown as express.Request; expect(() => { verifyNonce(mockRequest, 'providera'); - }).toThrowError('Invalid nonce'); + }).toThrow('Invalid nonce'); }); it('should not throw any error if nonce matches', () => { diff --git a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts index 660b96f018498..dd0c1579a937f 100644 --- a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts +++ b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts @@ -41,7 +41,7 @@ describe('PassportStrategyHelper', () => { mockStrategy, {}, ); - expect(spyAuthenticate).toBeCalledTimes(1); + expect(spyAuthenticate).toHaveBeenCalledTimes(1); await expect(redirectStrategyPromise).resolves.toStrictEqual( expect.objectContaining({ url: 'a', status: 302 }), ); @@ -84,7 +84,7 @@ describe('PassportStrategyHelper', () => { mockRequest, mockStrategy, ); - expect(spyAuthenticate).toBeCalledTimes(1); + expect(spyAuthenticate).toHaveBeenCalledTimes(1); await expect(frameHandlerStrategyPromise).resolves.toStrictEqual( expect.objectContaining({ result: { accessToken: 'ACCESS_TOKEN' }, @@ -100,7 +100,7 @@ describe('PassportStrategyHelper', () => { mockRequest, mockStrategy, ); - expect(spyAuthenticate).toBeCalledTimes(1); + expect(spyAuthenticate).toHaveBeenCalledTimes(1); await expect(frameHandlerStrategyPromise).rejects.toThrow( 'Authentication failed, MyCustomAuth error - Custom message', ); @@ -113,7 +113,7 @@ describe('PassportStrategyHelper', () => { mockRequest, mockStrategy, ); - expect(spyAuthenticate).toBeCalledTimes(1); + expect(spyAuthenticate).toHaveBeenCalledTimes(1); await expect(frameHandlerStrategyPromise).rejects.toThrow( 'Unexpected redirect', ); @@ -126,7 +126,7 @@ describe('PassportStrategyHelper', () => { mockRequest, mockStrategy, ); - expect(spyAuthenticate).toBeCalledTimes(1); + expect(spyAuthenticate).toHaveBeenCalledTimes(1); await expect(frameHandlerStrategyPromise).rejects.toThrow(); }); }); diff --git a/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts b/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts index 7570eb91563be..6653bc38cb588 100644 --- a/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts +++ b/plugins/auth-backend/src/providers/cloudflare-access/provider.test.ts @@ -233,7 +233,7 @@ describe('CloudflareAccessAuthProvider', () => { mockFetch.mockReturnValue(Promise.reject()); await expect( provider.refresh(mockRequestWithJwtCookie, mockResponse), - ).rejects.toThrowError(); + ).rejects.toThrow(); }); }); diff --git a/plugins/auth-backend/src/providers/gcp-iap/helpers.test.ts b/plugins/auth-backend/src/providers/gcp-iap/helpers.test.ts index 94fa9c0bd8350..c0e351c90b423 100644 --- a/plugins/auth-backend/src/providers/gcp-iap/helpers.test.ts +++ b/plugins/auth-backend/src/providers/gcp-iap/helpers.test.ts @@ -54,7 +54,7 @@ describe('helpers', () => { 'a', mockClient as unknown as OAuth2Client, ); - await expect(validator(validJwt)).rejects.toThrowError(TypeError); + await expect(validator(validJwt)).rejects.toThrow(TypeError); }); it('rejects empty payload', async () => { diff --git a/plugins/auth-backend/src/providers/oauth2-proxy/provider.test.ts b/plugins/auth-backend/src/providers/oauth2-proxy/provider.test.ts index f10a81c76b17b..0279604f2d819 100644 --- a/plugins/auth-backend/src/providers/oauth2-proxy/provider.test.ts +++ b/plugins/auth-backend/src/providers/oauth2-proxy/provider.test.ts @@ -122,7 +122,7 @@ describe('Oauth2ProxyAuthProvider', () => { await provider.refresh(mockRequest, mockResponse); - expect(mockRequest.header).toBeCalledWith(OAUTH2_PROXY_JWT_HEADER); + expect(mockRequest.header).toHaveBeenCalledWith(OAUTH2_PROXY_JWT_HEADER); expect(mockJwtDecode).toHaveBeenCalledWith('token'); expect(mockResponse.json).toHaveBeenCalled(); }); @@ -197,7 +197,7 @@ describe('Oauth2ProxyAuthProvider', () => { } as any); await handler.refresh!(mockRequest, mockResponse); - expect(mockRequest.header).toBeCalledWith(OAUTH2_PROXY_JWT_HEADER); + expect(mockRequest.header).toHaveBeenCalledWith(OAUTH2_PROXY_JWT_HEADER); expect(mockJwtDecode).toHaveBeenCalledWith('token'); expect(mockResponse.json).toHaveBeenCalled(); }); diff --git a/plugins/auth-backend/src/providers/oidc/provider.test.ts b/plugins/auth-backend/src/providers/oidc/provider.test.ts index ee8aa50b01d86..2285b60ed0722 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.test.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.test.ts @@ -83,7 +83,7 @@ describe('OidcAuthProvider', () => { }; }; // Assert that the expected request to the metadaurl was made. - expect(handler).toBeCalledTimes(1); + expect(handler).toHaveBeenCalledTimes(1); const { _client, _issuer } = strategy; expect(_client.client_id).toBe(clientMetadata.clientId); expect(_issuer.token_endpoint).toBe(issuerMetadata.token_endpoint); @@ -183,6 +183,6 @@ describe('OidcAuthProvider', () => { // Cast provider as any here to be able to inspect private members await (provider as any).handlers.get('testEnv').handlers.implementation; // Assert that the expected request to the metadaurl was made. - expect(handler).toBeCalledTimes(1); + expect(handler).toHaveBeenCalledTimes(1); }); }); diff --git a/plugins/catalog-backend-module-aws/src/processors/AwsEKSClusterProcessor.test.ts b/plugins/catalog-backend-module-aws/src/processors/AwsEKSClusterProcessor.test.ts index 3e33ba740c5bf..87b7f2c487d9c 100644 --- a/plugins/catalog-backend-module-aws/src/processors/AwsEKSClusterProcessor.test.ts +++ b/plugins/catalog-backend-module-aws/src/processors/AwsEKSClusterProcessor.test.ts @@ -45,7 +45,7 @@ describe('AwsEKSClusterProcessor', () => { AWSMock.mock('EKS', 'describeCluster', cluster); await processor.readLocation(location, false, emit); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'entity', location, entity: { diff --git a/plugins/catalog-backend-module-aws/src/processors/AwsOrganizationCloudAccountProcessor.test.ts b/plugins/catalog-backend-module-aws/src/processors/AwsOrganizationCloudAccountProcessor.test.ts index a7da6d9ad3f68..b9b8ba7741744 100644 --- a/plugins/catalog-backend-module-aws/src/processors/AwsOrganizationCloudAccountProcessor.test.ts +++ b/plugins/catalog-backend-module-aws/src/processors/AwsOrganizationCloudAccountProcessor.test.ts @@ -45,7 +45,7 @@ describe('AwsOrganizationCloudAccountProcessor', () => { }; }); await processor.readLocation(location, false, emit); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'entity', location, entity: { @@ -94,8 +94,8 @@ describe('AwsOrganizationCloudAccountProcessor', () => { }; }); await processor.readLocation(locationTest, false, emit); - expect(emit).toBeCalledTimes(1); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(1); + expect(emit).toHaveBeenCalledWith({ type: 'entity', location: locationTest, entity: { diff --git a/plugins/catalog-backend-module-aws/src/providers/AwsS3EntityProvider.test.ts b/plugins/catalog-backend-module-aws/src/providers/AwsS3EntityProvider.test.ts index b186b3d1b80ad..9d3bba0e8aec4 100644 --- a/plugins/catalog-backend-module-aws/src/providers/AwsS3EntityProvider.test.ts +++ b/plugins/catalog-backend-module-aws/src/providers/AwsS3EntityProvider.test.ts @@ -137,7 +137,7 @@ describe('AwsS3EntityProvider', () => { }; }); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); diff --git a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts index 08379807d3d00..1c2c3d0082690 100644 --- a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts +++ b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts @@ -114,7 +114,7 @@ describe('AzureDevOpsEntityProvider', () => { }; }); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/BitbucketCloudEntityProvider.test.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/BitbucketCloudEntityProvider.test.ts index efb1328643b07..08b127f69eebb 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/BitbucketCloudEntityProvider.test.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/BitbucketCloudEntityProvider.test.ts @@ -272,8 +272,8 @@ describe('BitbucketCloudEntityProvider', () => { }, ]; - expect(entityProviderConnection.applyMutation).toBeCalledTimes(1); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); diff --git a/plugins/catalog-backend-module-bitbucket-server/src/providers/BitbucketServerEntityProvider.test.ts b/plugins/catalog-backend-module-bitbucket-server/src/providers/BitbucketServerEntityProvider.test.ts index 1ebf7c95a779f..fe2c81b9b6ce6 100644 --- a/plugins/catalog-backend-module-bitbucket-server/src/providers/BitbucketServerEntityProvider.test.ts +++ b/plugins/catalog-backend-module-bitbucket-server/src/providers/BitbucketServerEntityProvider.test.ts @@ -266,8 +266,8 @@ describe('BitbucketServerEntityProvider', () => { }, ]; - expect(entityProviderConnection.applyMutation).toBeCalledTimes(1); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); @@ -359,8 +359,8 @@ describe('BitbucketServerEntityProvider', () => { }, ]; - expect(entityProviderConnection.applyMutation).toBeCalledTimes(1); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); diff --git a/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.test.ts b/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.test.ts index c2f98bf549756..f7a56ebc8f95d 100644 --- a/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.test.ts +++ b/plugins/catalog-backend-module-bitbucket/src/BitbucketDiscoveryProcessor.test.ts @@ -573,7 +573,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -615,7 +615,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -657,7 +657,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -698,7 +698,7 @@ describe('BitbucketDiscoveryProcessor', () => { const emitter = jest.fn(); await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(1); + expect(emitter).toHaveBeenCalledTimes(1); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -734,7 +734,7 @@ describe('BitbucketDiscoveryProcessor', () => { const emitter = jest.fn(); await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(1); + expect(emitter).toHaveBeenCalledTimes(1); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -762,7 +762,7 @@ describe('BitbucketDiscoveryProcessor', () => { const emitter = jest.fn(); await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(1); + expect(emitter).toHaveBeenCalledTimes(1); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -772,7 +772,7 @@ describe('BitbucketDiscoveryProcessor', () => { presence: 'optional', }, }); - expect(mockCall).toBeCalledTimes(1); + expect(mockCall).toHaveBeenCalledTimes(1); // it should be possible to do this via an `expect.objectContaining` check but seems to fail with some encoding issue. expect(mockCall.mock.calls[0][0].url).toMatchInlineSnapshot( `"https://api.bitbucket.org/2.0/repositories/myworkspace?page=1&pagelen=100&q=project.key+%7E+%22prj-one%22"`, @@ -875,7 +875,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -921,7 +921,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -967,7 +967,7 @@ describe('BitbucketDiscoveryProcessor', () => { await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(2); + expect(emitter).toHaveBeenCalledTimes(2); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -1012,7 +1012,7 @@ describe('BitbucketDiscoveryProcessor', () => { const emitter = jest.fn(); await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(1); + expect(emitter).toHaveBeenCalledTimes(1); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { @@ -1052,7 +1052,7 @@ describe('BitbucketDiscoveryProcessor', () => { const emitter = jest.fn(); await processor.readLocation(location, false, emitter); - expect(emitter).toBeCalledTimes(1); + expect(emitter).toHaveBeenCalledTimes(1); expect(emitter).toHaveBeenCalledWith({ type: 'location', location: { diff --git a/plugins/catalog-backend-module-gerrit/src/providers/GerritEntityProvider.test.ts b/plugins/catalog-backend-module-gerrit/src/providers/GerritEntityProvider.test.ts index 26aacb9126bd8..d5be045e6c992 100644 --- a/plugins/catalog-backend-module-gerrit/src/providers/GerritEntityProvider.test.ts +++ b/plugins/catalog-backend-module-gerrit/src/providers/GerritEntityProvider.test.ts @@ -115,7 +115,9 @@ describe('GerritEntityProvider', () => { expect(taskDef.id).toEqual('gerrit-provider:active-training:refresh'); await (taskDef.fn as () => Promise)(); - expect(entityProviderConnection.applyMutation).toBeCalledWith(expected); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith( + expected, + ); }); it('handles api errors.', async () => { diff --git a/plugins/catalog-backend-module-github/src/providers/GitHubEntityProvider.test.ts b/plugins/catalog-backend-module-github/src/providers/GitHubEntityProvider.test.ts index 2d92dcbba9f2c..1c51969c1ddd3 100644 --- a/plugins/catalog-backend-module-github/src/providers/GitHubEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GitHubEntityProvider.test.ts @@ -93,9 +93,7 @@ describe('GitHubEntityProvider', () => { logger, schedule, }), - ).toThrowError( - /There is no GitHub config that matches host ghe.internal.com/, - ); + ).toThrow(/There is no GitHub config that matches host ghe.internal.com/); }); it('multiple provider configs', () => { @@ -204,8 +202,8 @@ describe('GitHubEntityProvider', () => { }, ]; - expect(entityProviderConnection.applyMutation).toBeCalledTimes(1); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); diff --git a/plugins/catalog-backend-module-github/src/providers/GitHubOrgEntityProvider.test.ts b/plugins/catalog-backend-module-github/src/providers/GitHubOrgEntityProvider.test.ts index 3086386af8e33..77d585eae14e6 100644 --- a/plugins/catalog-backend-module-github/src/providers/GitHubOrgEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GitHubOrgEntityProvider.test.ts @@ -111,7 +111,7 @@ describe('GitHubOrgEntityProvider', () => { await entityProvider.read(); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ entities: [ { entity: { diff --git a/plugins/catalog-backend-module-gitlab/src/lib/client.test.ts b/plugins/catalog-backend-module-gitlab/src/lib/client.test.ts index 132dd0bc34fd5..513a5b937f015 100644 --- a/plugins/catalog-backend-module-gitlab/src/lib/client.test.ts +++ b/plugins/catalog-backend-module-gitlab/src/lib/client.test.ts @@ -214,7 +214,7 @@ describe('GitLabClient', () => { logger: getVoidLogger(), }); // non-200 status code should throw - await expect(() => client.pagedRequest(endpoint)).rejects.toThrowError(); + await expect(() => client.pagedRequest(endpoint)).rejects.toThrow(); }); }); diff --git a/plugins/catalog-backend-module-gitlab/src/providers/GitlabDiscoveryEntityProvider.test.ts b/plugins/catalog-backend-module-gitlab/src/providers/GitlabDiscoveryEntityProvider.test.ts index d4a13cf81e13b..7fb4bf8d09fb2 100644 --- a/plugins/catalog-backend-module-gitlab/src/providers/GitlabDiscoveryEntityProvider.test.ts +++ b/plugins/catalog-backend-module-gitlab/src/providers/GitlabDiscoveryEntityProvider.test.ts @@ -221,8 +221,8 @@ describe('GitlabDiscoveryEntityProvider', () => { }, ]; - expect(entityProviderConnection.applyMutation).toBeCalledTimes(1); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1); + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: expectedEntities, }); @@ -308,7 +308,7 @@ describe('GitlabDiscoveryEntityProvider', () => { await provider.refresh(logger); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ type: 'full', entities: [ { diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts index 94502b9e7d0b9..05693149d82bf 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts @@ -51,8 +51,8 @@ describe('MicrosoftGraphClient', () => { expect(response.status).toBe(200); expect(await response.json()).toEqual({ value: 'example' }); - expect(tokenCredential.getToken).toBeCalledTimes(1); - expect(tokenCredential.getToken).toBeCalledWith( + expect(tokenCredential.getToken).toHaveBeenCalledTimes(1); + expect(tokenCredential.getToken).toHaveBeenCalledWith( 'https://graph.microsoft.com/.default', ); }); @@ -158,7 +158,7 @@ describe('MicrosoftGraphClient', () => { ), ); - await expect(() => client.getUserProfile('user-id')).rejects.toThrowError(); + await expect(() => client.getUserProfile('user-id')).rejects.toThrow(); }); it('should load user profile photo with max size of 120', async () => { diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts index caef1701f6705..3f43807809620 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts @@ -111,15 +111,18 @@ describe('read microsoft graph', () => { }), ]); - expect(client.getUsers).toBeCalledTimes(1); - expect(client.getUsers).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( { filter: 'accountEnabled eq true', }, undefined, ); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); it('should read users with advanced query mode', async () => { @@ -162,15 +165,18 @@ describe('read microsoft graph', () => { }), ]); - expect(client.getUsers).toBeCalledTimes(1); - expect(client.getUsers).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( { filter: 'accountEnabled eq true', }, 'advanced', ); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); it('should read users with userExpand and custom transformer', async () => { @@ -208,16 +214,19 @@ describe('read microsoft graph', () => { }, ]); - expect(client.getUsers).toBeCalledTimes(1); - expect(client.getUsers).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( { expand: 'manager', filter: 'accountEnabled eq true', }, undefined, ); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); }); @@ -280,22 +289,25 @@ describe('read microsoft graph', () => { }), ]); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq true', }, undefined, ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); - expect(client.getUserProfile).toBeCalledTimes(1); - expect(client.getUserProfile).toBeCalledWith('userid', { + expect(client.getUserProfile).toHaveBeenCalledTimes(1); + expect(client.getUserProfile).toHaveBeenCalledWith('userid', { expand: undefined, }); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); it('should read users from Groups with advanced query mode', async () => { @@ -357,22 +369,25 @@ describe('read microsoft graph', () => { }), ]); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq true', }, 'advanced', ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); - expect(client.getUserProfile).toBeCalledTimes(1); - expect(client.getUserProfile).toBeCalledWith('userid', { + expect(client.getUserProfile).toHaveBeenCalledTimes(1); + expect(client.getUserProfile).toHaveBeenCalledWith('userid', { expand: undefined, }); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); it('should read users with userExpand, groupExpand and custom transformer', async () => { @@ -430,23 +445,26 @@ describe('read microsoft graph', () => { }, ]); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { expand: 'member', filter: 'securityEnabled eq true', }, undefined, ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); - expect(client.getUserProfile).toBeCalledTimes(1); - expect(client.getUserProfile).toBeCalledWith('userid', { + expect(client.getUserProfile).toHaveBeenCalledTimes(1); + expect(client.getUserProfile).toHaveBeenCalledWith('userid', { expand: 'manager', }); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith( + 'userid', + 120, + ); }); }); @@ -481,8 +499,8 @@ describe('read microsoft graph', () => { }), ); - expect(client.getOrganization).toBeCalledTimes(1); - expect(client.getOrganization).toBeCalledWith('tenantid'); + expect(client.getOrganization).toHaveBeenCalledTimes(1); + expect(client.getOrganization).toHaveBeenCalledWith('tenantid'); }); it('should read organization with custom transformer', async () => { @@ -499,8 +517,8 @@ describe('read microsoft graph', () => { expect(rootGroup).toEqual(undefined); - expect(client.getOrganization).toBeCalledTimes(1); - expect(client.getOrganization).toBeCalledWith('tenantid'); + expect(client.getOrganization).toHaveBeenCalledTimes(1); + expect(client.getOrganization).toHaveBeenCalledWith('tenantid'); }); }); @@ -585,15 +603,15 @@ describe('read microsoft graph', () => { expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid'])); expect(groupMember.get('organization_name')).toEqual(new Set()); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq false', }, undefined, ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); // TODO: Loading groups photos doesn't work right now as Microsoft Graph // doesn't allows this yet // expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1); @@ -681,15 +699,15 @@ describe('read microsoft graph', () => { expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid'])); expect(groupMember.get('organization_name')).toEqual(new Set()); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq false', }, 'advanced', ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); // TODO: Loading groups photos doesn't work right now as Microsoft Graph // doesn't allows this yet // expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1); @@ -777,16 +795,16 @@ describe('read microsoft graph', () => { expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid'])); expect(groupMember.get('organization_name')).toEqual(new Set()); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { expand: 'member', filter: 'securityEnabled eq false', }, undefined, ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); // TODO: Loading groups photos doesn't work right now as Microsoft Graph // doesn't allows this yet // expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1); @@ -872,14 +890,14 @@ describe('read microsoft graph', () => { }), ]); expect(rootGroup).toEqual(expectedRootGroup); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq true', }, undefined, ); - expect(client.getGroupMembers).toBeCalledTimes(1); - expect(client.getGroupMembers).toBeCalledWith('groupid'); + expect(client.getGroupMembers).toHaveBeenCalledTimes(1); + expect(client.getGroupMembers).toHaveBeenCalledWith('groupid'); }); }); @@ -1034,15 +1052,15 @@ describe('read microsoft graph', () => { groupFilter: 'securityEnabled eq false', }); - expect(client.getUsers).toBeCalledTimes(1); - expect(client.getUsers).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( { filter: undefined, }, undefined, ); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq false', }, @@ -1074,16 +1092,16 @@ describe('read microsoft graph', () => { groupFilter: 'securityEnabled eq false', }); - expect(client.getUsers).toBeCalledTimes(1); - expect(client.getUsers).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( { expand: 'manager', filter: 'accountEnabled eq true', }, undefined, ); - expect(client.getGroups).toBeCalledTimes(1); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledTimes(1); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq false', }, @@ -1115,22 +1133,22 @@ describe('read microsoft graph', () => { groupFilter: 'securityEnabled eq false', }); - expect(client.getUsers).toBeCalledTimes(0); - expect(client.getGroups).toBeCalledTimes(2); - expect(client.getGroups).toBeCalledWith( + expect(client.getUsers).toHaveBeenCalledTimes(0); + expect(client.getGroups).toHaveBeenCalledTimes(2); + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'name eq backstage-group', }, undefined, ); - expect(client.getGroups).toBeCalledWith( + expect(client.getGroups).toHaveBeenCalledWith( { filter: 'securityEnabled eq false', }, undefined, ); - expect(client.getUserProfile).toBeCalledTimes(1); - expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1); + expect(client.getUserProfile).toHaveBeenCalledTimes(1); + expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1); }); }); }); diff --git a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.test.ts b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.test.ts index 26b4f807656ea..e34eee04991f4 100644 --- a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.test.ts @@ -108,7 +108,7 @@ describe('MicrosoftGraphOrgEntityProvider', () => { await provider.read(); - expect(entityProviderConnection.applyMutation).toBeCalledWith({ + expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({ entities: [ { entity: { diff --git a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgReaderProcessor.test.ts b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgReaderProcessor.test.ts index bcf76e94828df..a33108c8fd666 100644 --- a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgReaderProcessor.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgReaderProcessor.test.ts @@ -92,8 +92,8 @@ describe('MicrosoftGraphOrgReaderProcessor', () => { const processed = await processor.readLocation(location, false, emit); expect(processed).toBe(true); - expect(emit).toBeCalledTimes(2); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(2); + expect(emit).toHaveBeenCalledWith({ entity: { apiVersion: 'backstage.io/v1alpha1', kind: 'Group', @@ -111,7 +111,7 @@ describe('MicrosoftGraphOrgReaderProcessor', () => { }, type: 'entity', }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ entity: { apiVersion: 'backstage.io/v1alpha1', kind: 'User', @@ -139,6 +139,6 @@ describe('MicrosoftGraphOrgReaderProcessor', () => { const processed = await processor.readLocation(location, false, emit); expect(processed).toBe(false); - expect(emit).toBeCalledTimes(0); + expect(emit).toHaveBeenCalledTimes(0); }); }); diff --git a/plugins/catalog-backend/src/database/DefaultProcessingDatabase.test.ts b/plugins/catalog-backend/src/database/DefaultProcessingDatabase.test.ts index 9eaeb0e322edf..46b327733dfea 100644 --- a/plugins/catalog-backend/src/database/DefaultProcessingDatabase.test.ts +++ b/plugins/catalog-backend/src/database/DefaultProcessingDatabase.test.ts @@ -1225,7 +1225,7 @@ describe('Default Processing Database', () => { ], }); }); - expect(fakeLogger.debug).toBeCalledWith( + expect(fakeLogger.debug).toHaveBeenCalledWith( expect.stringMatching( /Fast insert path failed, falling back to slow path/, ), diff --git a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts index 7ae4b6b5a0199..dbb9922fe0d83 100644 --- a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts @@ -52,8 +52,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(14); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(14); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -61,7 +61,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -69,7 +69,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'o' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'API', namespace: 'default', name: 'b' }, @@ -77,7 +77,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -85,7 +85,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'API', namespace: 'default', name: 'b' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'API', namespace: 'default', name: 'c' }, @@ -93,7 +93,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -101,7 +101,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'API', namespace: 'default', name: 'c' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -109,7 +109,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Resource', namespace: 'default', name: 'r' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'r' }, @@ -117,7 +117,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -125,7 +125,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'd' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'd' }, @@ -133,7 +133,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 's' }, @@ -141,7 +141,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -149,7 +149,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 's' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'System', namespace: 'default', name: 's' }, @@ -157,7 +157,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'n' }, @@ -185,7 +185,7 @@ describe('BuiltinKindsEntityProcessor', () => { }; await expect( processor.postProcessEntity(entity, location, emit), - ).rejects.toThrowError( + ).rejects.toThrow( 'Entity reference "r" had missing or empty kind (e.g. did not start with "component:" or similar)', ); }); @@ -206,8 +206,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(4); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(4); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -215,7 +215,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'API', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'API', namespace: 'default', name: 'n' }, @@ -223,7 +223,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'o' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'System', namespace: 'default', name: 's' }, @@ -231,7 +231,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'API', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'API', namespace: 'default', name: 'n' }, @@ -257,8 +257,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(10); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(10); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -266,7 +266,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Resource', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'n' }, @@ -275,7 +275,7 @@ describe('BuiltinKindsEntityProcessor', () => { }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'n' }, @@ -283,7 +283,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'c' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'c' }, @@ -292,7 +292,7 @@ describe('BuiltinKindsEntityProcessor', () => { }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'n' }, @@ -300,7 +300,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Resource', namespace: 'default', name: 'r' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'r' }, @@ -309,7 +309,7 @@ describe('BuiltinKindsEntityProcessor', () => { }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'System', namespace: 'default', name: 's' }, @@ -317,7 +317,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Resource', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'n' }, @@ -326,7 +326,7 @@ describe('BuiltinKindsEntityProcessor', () => { }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Resource', namespace: 'default', name: 'n' }, @@ -334,7 +334,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Component', namespace: 'default', name: 'd' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Component', namespace: 'default', name: 'd' }, @@ -358,7 +358,7 @@ describe('BuiltinKindsEntityProcessor', () => { }; await expect( processor.postProcessEntity(entity, location, emit), - ).rejects.toThrowError( + ).rejects.toThrow( 'Entity reference "c" had missing or empty kind (e.g. did not start with "component:" or similar)', ); }); @@ -376,8 +376,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(4); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(4); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -385,7 +385,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'System', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'System', namespace: 'default', name: 'n' }, @@ -393,7 +393,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'o' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Domain', namespace: 'default', name: 'd' }, @@ -401,7 +401,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'System', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'System', namespace: 'default', name: 'n' }, @@ -423,8 +423,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(2); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(2); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -432,7 +432,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Domain', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Domain', namespace: 'default', name: 'n' }, @@ -454,8 +454,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(2); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(2); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'User', namespace: 'default', name: 'n' }, @@ -463,7 +463,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'g' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'g' }, @@ -488,8 +488,8 @@ describe('BuiltinKindsEntityProcessor', () => { await processor.postProcessEntity(entity, location, emit); - expect(emit).toBeCalledTimes(6); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(6); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'n' }, @@ -497,7 +497,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'p' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'p' }, @@ -505,7 +505,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'c' }, @@ -513,7 +513,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'n' }, @@ -521,7 +521,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'c' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'User', namespace: 'default', name: 'm' }, @@ -529,7 +529,7 @@ describe('BuiltinKindsEntityProcessor', () => { target: { kind: 'Group', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'n' }, diff --git a/plugins/catalog-backend/src/modules/core/FileReaderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/FileReaderProcessor.test.ts index 18d4ba4032cfa..e43667d471b4c 100644 --- a/plugins/catalog-backend/src/modules/core/FileReaderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/FileReaderProcessor.test.ts @@ -80,7 +80,7 @@ describe('FileReaderProcessor', () => { defaultEntityDataParser, ); - expect(emit).toBeCalledTimes(4); + expect(emit).toHaveBeenCalledTimes(4); expect(emit.mock.calls[0][0].entity).toEqual({ kind: 'Component', metadata: { name: 'component-test' }, diff --git a/plugins/catalog-backend/src/modules/core/LocationEntityProcessor.test.ts b/plugins/catalog-backend/src/modules/core/LocationEntityProcessor.test.ts index 8f3de7e29bb35..68c073eb0a7bf 100644 --- a/plugins/catalog-backend/src/modules/core/LocationEntityProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/LocationEntityProcessor.test.ts @@ -57,7 +57,7 @@ describe('LocationEntityProcessor', () => { 'http://b.com/z', ); - expect(integrations.resolveUrl).toBeCalledTimes(3); + expect(integrations.resolveUrl).toHaveBeenCalledTimes(3); }); it('handles azure urls specifically', () => { diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts index 735536ae356bb..8fd811476038e 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts @@ -86,8 +86,8 @@ describe('PlaceholderProcessor', () => { spec: { a: [{ b: 'TEXT' }] }, }); - expect(read).not.toBeCalled(); - expect(upperResolver).toBeCalledWith( + expect(read).not.toHaveBeenCalled(); + expect(upperResolver).toHaveBeenCalledWith( expect.objectContaining({ key: 'upper', value: 'text', @@ -115,7 +115,7 @@ describe('PlaceholderProcessor', () => { processor.preProcessEntity(entity, { type: 'a', target: 'b' }, () => {}), ).resolves.toEqual(entity); - expect(read).not.toBeCalled(); + expect(read).not.toHaveBeenCalled(); }); it('ignores unknown placeholders', async () => { @@ -136,7 +136,7 @@ describe('PlaceholderProcessor', () => { processor.preProcessEntity(entity, { type: 'a', target: 'b' }, () => {}), ).resolves.toEqual(entity); - expect(read).not.toBeCalled(); + expect(read).not.toHaveBeenCalled(); }); it('works with the text resolver', async () => { @@ -169,7 +169,7 @@ describe('PlaceholderProcessor', () => { spec: { data: 'TEXT' }, }); - expect(read).toBeCalledWith( + expect(read).toHaveBeenCalledWith( 'https://github.com/backstage/backstage/a/file.txt', ); }); @@ -206,7 +206,7 @@ describe('PlaceholderProcessor', () => { spec: { data: { a: ['b', 7] } }, }); - expect(read).toBeCalledWith( + expect(read).toHaveBeenCalledWith( 'https://github.com/backstage/backstage/a/b/file.json', ); }); @@ -241,7 +241,7 @@ describe('PlaceholderProcessor', () => { spec: { data: { foo: [{ bar: 7 }] } }, }); - expect(read).toBeCalledWith( + expect(read).toHaveBeenCalledWith( 'https://github.com/backstage/backstage/a/file.yaml', ); }); @@ -280,7 +280,7 @@ describe('PlaceholderProcessor', () => { spec: { data: 'TEXT' }, }); - expect(read).toBeCalledWith( + expect(read).toHaveBeenCalledWith( 'https://github.com/backstage/backstage/catalog-info.yaml', ); }); @@ -318,7 +318,7 @@ describe('PlaceholderProcessor', () => { spec: { data: 'TEXT' }, }); - expect(read).toBeCalledWith( + expect(read).toHaveBeenCalledWith( 'https://github.com/backstage/backstage/catalog-info.yaml', ); }); @@ -356,7 +356,7 @@ describe('PlaceholderProcessor', () => { /^Placeholder \$text could not form a URL out of \.\/a\/b\/catalog-info\.yaml and \.\.\/c\/catalog-info\.yaml, TypeError \[ERR_INVALID_URL\]/, ); - expect(read).not.toBeCalled(); + expect(read).not.toHaveBeenCalled(); }); it('should emit the resolverValue as a refreshKey', async () => { read.mockResolvedValue( diff --git a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts index c372eb12a6e73..cf14ea22e01e3 100644 --- a/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/UrlReaderProcessor.test.ts @@ -91,7 +91,7 @@ describe('UrlReaderProcessor', () => { type: 'refresh', key: 'url:http://localhost/component.yaml', }); - expect(mockCache.set).toBeCalledWith('v1', { + expect(mockCache.set).toHaveBeenCalledWith('v1', { etag: 'my-etag', value: [ { @@ -101,7 +101,7 @@ describe('UrlReaderProcessor', () => { }, ], }); - expect(mockCache.set).toBeCalledTimes(1); + expect(mockCache.set).toHaveBeenCalledTimes(1); }); it('should use cached data when available', async () => { @@ -147,9 +147,9 @@ describe('UrlReaderProcessor', () => { expect(refresh.type).toBe('refresh'); expect(refresh.key).toBe('url:http://localhost/component.yaml'); - expect(mockCache.get).toBeCalledWith('v1'); - expect(mockCache.get).toBeCalledTimes(1); - expect(mockCache.set).toBeCalledTimes(0); + expect(mockCache.get).toHaveBeenCalledWith('v1'); + expect(mockCache.get).toHaveBeenCalledTimes(1); + expect(mockCache.set).toHaveBeenCalledTimes(0); }); it('should fail load from url with error', async () => { @@ -211,6 +211,6 @@ describe('UrlReaderProcessor', () => { mockCache, ); - expect(reader.search).toBeCalledTimes(1); + expect(reader.search).toHaveBeenCalledTimes(1); }); }); diff --git a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.test.ts b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.test.ts index 3b6f126391de2..a358f1d07e72f 100644 --- a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.test.ts +++ b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.test.ts @@ -100,8 +100,8 @@ describe('DefaultCatalogProcessingEngine', () => { await engine.start(); await waitForExpect(() => { - expect(orchestrator.process).toBeCalledTimes(1); - expect(orchestrator.process).toBeCalledWith({ + expect(orchestrator.process).toHaveBeenCalledTimes(1); + expect(orchestrator.process).toHaveBeenCalledWith({ entity: { apiVersion: '1', kind: 'Location', @@ -167,8 +167,8 @@ describe('DefaultCatalogProcessingEngine', () => { await engine.start(); await waitForExpect(() => { - expect(orchestrator.process).toBeCalledTimes(1); - expect(orchestrator.process).toBeCalledWith({ + expect(orchestrator.process).toHaveBeenCalledTimes(1); + expect(orchestrator.process).toHaveBeenCalledWith({ entity: { apiVersion: '1', kind: 'Location', @@ -232,10 +232,10 @@ describe('DefaultCatalogProcessingEngine', () => { await engine.start(); await waitForExpect(() => { - expect(orchestrator.process).toBeCalledTimes(1); - expect(hash.digest).toBeCalledTimes(1); - expect(db.updateProcessedEntity).toBeCalledTimes(1); - expect(db.listParents).toBeCalledTimes(1); + expect(orchestrator.process).toHaveBeenCalledTimes(1); + expect(hash.digest).toHaveBeenCalledTimes(1); + expect(db.updateProcessedEntity).toHaveBeenCalledTimes(1); + expect(db.listParents).toHaveBeenCalledTimes(1); }); expect(db.updateEntityCache).not.toHaveBeenCalled(); @@ -247,11 +247,11 @@ describe('DefaultCatalogProcessingEngine', () => { .mockResolvedValue({ items: [] }); await waitForExpect(() => { - expect(orchestrator.process).toBeCalledTimes(2); - expect(hash.digest).toBeCalledTimes(2); - expect(db.updateProcessedEntity).toBeCalledTimes(1); - expect(db.updateEntityCache).toBeCalledTimes(1); - expect(db.listParents).toBeCalledTimes(2); + expect(orchestrator.process).toHaveBeenCalledTimes(2); + expect(hash.digest).toHaveBeenCalledTimes(2); + expect(db.updateProcessedEntity).toHaveBeenCalledTimes(1); + expect(db.updateEntityCache).toHaveBeenCalledTimes(1); + expect(db.listParents).toHaveBeenCalledTimes(2); }); expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), { id: '', @@ -307,7 +307,7 @@ describe('DefaultCatalogProcessingEngine', () => { })); await waitForExpect(() => { - expect(db.updateEntityCache).toBeCalledTimes(1); + expect(db.updateEntityCache).toHaveBeenCalledTimes(1); }); expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), { @@ -329,7 +329,7 @@ describe('DefaultCatalogProcessingEngine', () => { db.updateEntityCache.mockReset(); await waitForExpect(() => { - expect(db.updateEntityCache).toBeCalledTimes(1); + expect(db.updateEntityCache).toHaveBeenCalledTimes(1); }); expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), { @@ -442,7 +442,7 @@ describe('DefaultCatalogProcessingEngine', () => { await engine.start(); await waitForExpect(() => { - expect(stitcher.stitch).toBeCalledTimes(2); + expect(stitcher.stitch).toHaveBeenCalledTimes(2); }); expect([...stitcher.stitch.mock.calls[0][0]]).toEqual( expect.arrayContaining(['k:ns/me', 'k:ns/other1', 'k:ns/other2']), diff --git a/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.test.ts b/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.test.ts index 51edd903e659c..b15d1df4bb5a2 100644 --- a/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.test.ts +++ b/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.test.ts @@ -110,7 +110,7 @@ describe('AuthorizedEntitiesCatalog', () => { await expect(() => catalog.removeEntityByUid('uid', { authorizationToken: 'abcd' }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); it('throws error on CONDITIONAL authorization that evaluates to 0 entities', async () => { @@ -129,7 +129,7 @@ describe('AuthorizedEntitiesCatalog', () => { await expect(() => catalog.removeEntityByUid('uid', { authorizationToken: 'abcd' }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); it('calls underlying catalog method on CONDITIONAL authorization that evaluates to nonzero entities', async () => { @@ -185,7 +185,7 @@ describe('AuthorizedEntitiesCatalog', () => { catalog.entityAncestry('backstage:default/component', { authorizationToken: 'Bearer abcd', }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); it('filters out unauthorized entities and their parents', async () => { diff --git a/plugins/catalog-backend/src/service/AuthorizedLocationService.test.ts b/plugins/catalog-backend/src/service/AuthorizedLocationService.test.ts index dc8719bb0ec84..e613f25cb290d 100644 --- a/plugins/catalog-backend/src/service/AuthorizedLocationService.test.ts +++ b/plugins/catalog-backend/src/service/AuthorizedLocationService.test.ts @@ -73,7 +73,7 @@ describe('AuthorizedLocationService', () => { service.createLocation(spec, false, { authorizationToken: 'Bearer authtoken', }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); }); @@ -117,7 +117,7 @@ describe('AuthorizedLocationService', () => { await expect(() => service.getLocation('id', { authorizationToken: 'Bearer authtoken' }), - ).rejects.toThrowError(NotFoundError); + ).rejects.toThrow(NotFoundError); }); }); @@ -141,7 +141,7 @@ describe('AuthorizedLocationService', () => { service.deleteLocation('id', { authorizationToken: 'Bearer authtoken', }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); }); }); diff --git a/plugins/catalog-backend/src/service/AuthorizedRefreshService.test.ts b/plugins/catalog-backend/src/service/AuthorizedRefreshService.test.ts index 5d0a19247095a..f37bd0ec4927e 100644 --- a/plugins/catalog-backend/src/service/AuthorizedRefreshService.test.ts +++ b/plugins/catalog-backend/src/service/AuthorizedRefreshService.test.ts @@ -48,7 +48,7 @@ describe('AuthorizedRefreshService', () => { entityRef: 'some entity ref', authorizationToken: 'some auth token', }), - ).rejects.toThrowError(NotAllowedError); + ).rejects.toThrow(NotAllowedError); }); it('calls refresh on allow', async () => { diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts index 8169fc484d1a0..6d70923556eb2 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts @@ -86,7 +86,7 @@ describe('DefaultLocationServiceTest', () => { true, ); - expect(orchestrator.process).toBeCalledWith({ + expect(orchestrator.process).toHaveBeenCalledWith({ entity: { apiVersion: 'backstage.io/v1alpha1', kind: 'Location', @@ -108,7 +108,7 @@ describe('DefaultLocationServiceTest', () => { state: expect.anything(), }); - expect(orchestrator.process).toBeCalledWith({ + expect(orchestrator.process).toHaveBeenCalledWith({ entity: { apiVersion: 'backstage.io/v1alpha1', kind: 'Component', @@ -116,8 +116,8 @@ describe('DefaultLocationServiceTest', () => { }, state: expect.anything(), }); - expect(orchestrator.process).toBeCalledTimes(2); - expect(store.createLocation).not.toBeCalled(); + expect(orchestrator.process).toHaveBeenCalledTimes(2); + expect(store.createLocation).not.toHaveBeenCalled(); }); it('should check for location existence when running in dry run', async () => { @@ -255,7 +255,7 @@ describe('DefaultLocationServiceTest', () => { type: 'url', }, }); - expect(store.createLocation).toBeCalledWith({ + expect(store.createLocation).toHaveBeenCalledWith({ target: 'https://backstage.io/catalog-info.yaml', type: 'url', }); @@ -289,7 +289,7 @@ describe('DefaultLocationServiceTest', () => { type: 'unknown', }, }); - expect(store.createLocation).toBeCalledWith({ + expect(store.createLocation).toHaveBeenCalledWith({ target: 'https://backstage.io/catalog-info.yaml', type: 'unknown', }); @@ -330,21 +330,21 @@ describe('DefaultLocationServiceTest', () => { describe('listLocations', () => { it('should call locationStore.deleteLocation', async () => { await locationService.listLocations(); - expect(store.listLocations).toBeCalled(); + expect(store.listLocations).toHaveBeenCalled(); }); }); describe('deleteLocation', () => { it('should call locationStore.deleteLocation', async () => { await locationService.deleteLocation('123'); - expect(store.deleteLocation).toBeCalledWith('123'); + expect(store.deleteLocation).toHaveBeenCalledWith('123'); }); }); describe('getLocation', () => { it('should call locationStore.getLocation', async () => { await locationService.getLocation('123'); - expect(store.getLocation).toBeCalledWith('123'); + expect(store.getLocation).toHaveBeenCalledWith('123'); }); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx index f3717f8b701c5..9b354b5f389a9 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx @@ -81,7 +81,7 @@ describe('', () => { expect(await findByText('b:d/c')).toBeInTheDocument(); expect(await findAllByTestId('node')).toHaveLength(1); - expect(catalog.getEntityByRef).toBeCalledTimes(1); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1); }); test('renders with custom title', async () => { diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx index eb31e07a65a5a..d8b7ede2c2b2e 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx @@ -123,7 +123,7 @@ describe('', () => { expect(await findByText('b:d/c')).toBeInTheDocument(); expect(await findByText('b:d/e')).toBeInTheDocument(); expect(await findAllByTestId('node')).toHaveLength(2); - expect(catalog.getEntityByRef).toBeCalledTimes(2); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2); }); test('should toggle filters', async () => { @@ -169,7 +169,7 @@ describe('', () => { const user = userEvent.setup(); await user.keyboard('{Shift>}'); await user.click(getByText('b:d/e')); - expect(navigate).toBeCalledWith('/entity/{kind}/{namespace}/{name}'); + expect(navigate).toHaveBeenCalledWith('/entity/{kind}/{namespace}/{name}'); }); test('should capture analytics event when selecting other entity', async () => { diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/DirectionFilter.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/DirectionFilter.test.tsx index 634a4bf44283f..05c071f1f9a0d 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/DirectionFilter.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/DirectionFilter.test.tsx @@ -41,7 +41,7 @@ describe('', () => { await waitFor(() => { expect(getByText('Top to bottom')).toBeInTheDocument(); - expect(onChange).toBeCalledWith(Direction.TOP_BOTTOM); + expect(onChange).toHaveBeenCalledWith(Direction.TOP_BOTTOM); }); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/MaxDepthFilter.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/MaxDepthFilter.test.tsx index bddb2ac8ab528..3f3a7f82a6a51 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/MaxDepthFilter.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/MaxDepthFilter.test.tsx @@ -44,7 +44,7 @@ describe('', () => { ); await userEvent.click(getByLabelText('clear max depth')); - expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY); + expect(onChange).toHaveBeenCalledWith(Number.POSITIVE_INFINITY); }); test('should set max depth to undefined if below one', async () => { @@ -56,7 +56,7 @@ describe('', () => { await userEvent.clear(getByLabelText('maxp')); await userEvent.type(getByLabelText('maxp'), '0'); - expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY); + expect(onChange).toHaveBeenCalledWith(Number.POSITIVE_INFINITY); }); test('should select direction', async () => { @@ -70,7 +70,7 @@ describe('', () => { await userEvent.clear(getByLabelText('maxp')); await userEvent.type(getByLabelText('maxp'), '10'); waitFor(() => { - expect(onChange).toBeCalledWith(10); + expect(onChange).toHaveBeenCalledWith(10); }); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedKindsFilter.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedKindsFilter.test.tsx index e7bf10216fe44..580c118b275f6 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedKindsFilter.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedKindsFilter.test.tsx @@ -75,7 +75,7 @@ describe('', () => { await userEvent.click(getByText('System')); await waitFor(() => { - expect(onChange).toBeCalledWith(['api', 'component', 'system']); + expect(onChange).toHaveBeenCalledWith(['api', 'component', 'system']); }); }); @@ -96,7 +96,7 @@ describe('', () => { await userEvent.click(getByText('Resource')); await waitFor(() => { - expect(onChange).toBeCalledWith(undefined); + expect(onChange).toHaveBeenCalledWith(undefined); }); }); @@ -112,7 +112,7 @@ describe('', () => { await userEvent.tab(); await waitFor(() => { - expect(onChange).toBeCalledWith(undefined); + expect(onChange).toHaveBeenCalledWith(undefined); }); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedRelationsFilter.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedRelationsFilter.test.tsx index 6bd740ac9ebf9..bcc67edc3d04f 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedRelationsFilter.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/SelectedRelationsFilter.test.tsx @@ -57,7 +57,7 @@ describe('', () => { await userEvent.click(getByText(RELATION_HAS_MEMBER)); await waitFor(() => { - expect(onChange).toBeCalledWith([ + expect(onChange).toHaveBeenCalledWith([ RELATION_OWNED_BY, RELATION_CHILD_OF, RELATION_HAS_MEMBER, @@ -86,7 +86,7 @@ describe('', () => { await userEvent.click(getByText(RELATION_HAS_MEMBER)); await waitFor(() => { - expect(onChange).toBeCalledWith(undefined); + expect(onChange).toHaveBeenCalledWith(undefined); }); }); @@ -104,7 +104,7 @@ describe('', () => { await userEvent.tab(); await waitFor(() => { - expect(onChange).toBeCalledWith(undefined); + expect(onChange).toHaveBeenCalledWith(undefined); }); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/SwitchFilter.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/SwitchFilter.test.tsx index de53f4682e873..08c7304989e3f 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/SwitchFilter.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/SwitchFilter.test.tsx @@ -39,6 +39,6 @@ describe('', () => { await userEvent.click(getByLabelText('My label')); - expect(onChange).toBeCalledWith(false); + expect(onChange).toHaveBeenCalledWith(false); }); }); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.test.ts b/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.test.ts index f536190e43adb..d78a5b768c8d3 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.test.ts +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.test.ts @@ -106,7 +106,7 @@ describe('useCatalogGraphPage', () => { act(() => result.current.setMaxDepth(5)); - expect(windowHistoryReplaceState).toBeCalledWith( + expect(windowHistoryReplaceState).toHaveBeenCalledWith( null, '', '/?maxDepth=5&unidirectional=true&mergeRelations=true&direction=LR&showFilters=true', @@ -114,7 +114,7 @@ describe('useCatalogGraphPage', () => { act(() => result.current.setUnidirectional(false)); - expect(windowHistoryReplaceState).toBeCalledWith( + expect(windowHistoryReplaceState).toHaveBeenCalledWith( null, '', '/?maxDepth=5&unidirectional=false&mergeRelations=true&direction=LR&showFilters=true', @@ -138,7 +138,7 @@ describe('useCatalogGraphPage', () => { rerender(); - expect(windowHistoryPushState).toBeCalledWith( + expect(windowHistoryPushState).toHaveBeenCalledWith( null, '', '/?rootEntityRefs%5B%5D=component%3Adefault%2Fmy&maxDepth=%E2%88%9E&unidirectional=true&mergeRelations=true&direction=LR&showFilters=true', diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/CustomNode.test.tsx b/plugins/catalog-graph/src/components/EntityRelationsGraph/CustomNode.test.tsx index 6e034db2b6d4e..ff9fc9377e076 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/CustomNode.test.tsx +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/CustomNode.test.tsx @@ -75,7 +75,7 @@ describe('', () => { expect(getByText('kind:namespace/name')).toBeInTheDocument(); await userEvent.click(getByText('kind:namespace/name')); - expect(onClick).toBeCalledTimes(1); + expect(onClick).toHaveBeenCalledTimes(1); }); test('renders title if entity has one', async () => { diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx index 187c23f967fd6..db6711a0a515e 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.test.tsx @@ -153,7 +153,7 @@ describe('', () => { expect(await findByText('b:d/c')).toBeInTheDocument(); expect(await findAllByTestId('node')).toHaveLength(1); - expect(catalog.getEntityByRef).toBeCalledTimes(1); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1); }); test('renders a progress indicator while loading', async () => { @@ -168,7 +168,7 @@ describe('', () => { ); expect(await findByRole('progressbar')).toBeInTheDocument(); - expect(catalog.getEntityByRef).toBeCalledTimes(1); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1); }); test('does not explode if an entity is missing', async () => { @@ -208,7 +208,7 @@ describe('', () => { expect(await findByText('b:d/c')).toBeInTheDocument(); expect(await findAllByTestId('node')).toHaveLength(1); - expect(catalog.getEntityByRef).toBeCalledTimes(2); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2); }); test('renders at max depth of one', async () => { @@ -231,7 +231,7 @@ describe('', () => { expect(await findAllByText('hasPart')).toHaveLength(1); expect(await findAllByTestId('label')).toHaveLength(2); - expect(catalog.getEntityByRef).toBeCalledTimes(3); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(3); }); test('renders simplied graph at full depth', async () => { @@ -256,7 +256,7 @@ describe('', () => { expect(await findAllByText('hasPart')).toHaveLength(2); expect(await findAllByTestId('label')).toHaveLength(3); - expect(catalog.getEntityByRef).toBeCalledTimes(4); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4); }); test('renders full graph at full depth', async () => { @@ -283,7 +283,7 @@ describe('', () => { expect(await findAllByText('partOf')).toHaveLength(2); expect(await findAllByTestId('label')).toHaveLength(8); - expect(catalog.getEntityByRef).toBeCalledTimes(4); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4); }); test('renders full graph at full depth with merged relations', async () => { @@ -308,7 +308,7 @@ describe('', () => { expect(await findAllByText('hasPart')).toHaveLength(2); expect(await findAllByTestId('label')).toHaveLength(4); - expect(catalog.getEntityByRef).toBeCalledTimes(4); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4); }); test('renders a graph with multiple root nodes', async () => { @@ -334,7 +334,7 @@ describe('', () => { expect(await findAllByText('partOf')).toHaveLength(2); expect(await findAllByTestId('label')).toHaveLength(3); - expect(catalog.getEntityByRef).toBeCalledTimes(4); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4); }); test('renders a graph with filtered kinds and relations', async () => { @@ -356,7 +356,7 @@ describe('', () => { expect(await findAllByText('ownerOf')).toHaveLength(1); expect(await findAllByTestId('label')).toHaveLength(1); - expect(catalog.getEntityByRef).toBeCalledTimes(2); + expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2); }); test('handle clicks on a node', async () => { @@ -371,7 +371,7 @@ describe('', () => { ); await userEvent.click(await findByText('k:d/a1')); - expect(onNodeClick).toBeCalledTimes(1); + expect(onNodeClick).toHaveBeenCalledTimes(1); }); test('render custom node', async () => { diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts index 9956137287d8b..74d7423eea6e9 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityStore.test.ts @@ -233,6 +233,6 @@ describe('useEntityStore', () => { }); }); - expect(catalogApi.getEntityByRef).toBeCalledTimes(2); + expect(catalogApi.getEntityByRef).toHaveBeenCalledTimes(2); }); }); diff --git a/plugins/catalog-import/src/api/CatalogImportClient.test.ts b/plugins/catalog-import/src/api/CatalogImportClient.test.ts index 98aea30638180..e26d6c5d6ab47 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.test.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.test.ts @@ -164,7 +164,7 @@ describe('CatalogImportClient', () => { type: 'locations', }); - expect(catalogApi.addLocation).toBeCalledTimes(1); + expect(catalogApi.addLocation).toHaveBeenCalledTimes(1); expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({ type: 'url', target: 'http://example.com/folder/catalog-info.yaml', @@ -213,7 +213,7 @@ describe('CatalogImportClient', () => { type: 'locations', }); - expect(catalogApi.addLocation).toBeCalledTimes(1); + expect(catalogApi.addLocation).toHaveBeenCalledTimes(1); expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({ type: 'url', target: @@ -261,7 +261,7 @@ describe('CatalogImportClient', () => { type: 'locations', }); - expect(catalogApi.addLocation).toBeCalledTimes(1); + expect(catalogApi.addLocation).toHaveBeenCalledTimes(1); expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({ type: 'url', target: 'http://example.com/folder/catalog-info.yaml?branch=test', diff --git a/plugins/catalog-import/src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.test.tsx b/plugins/catalog-import/src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.test.tsx index 37f3c1a389236..5a8110eb6cfd7 100644 --- a/plugins/catalog-import/src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.test.tsx +++ b/plugins/catalog-import/src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.test.tsx @@ -106,9 +106,9 @@ describe('', () => { } }); - expect(catalogImportApi.analyzeUrl).toBeCalledTimes(0); - expect(onAnalysisFn).toBeCalledTimes(0); - expect(errorApi.post).toBeCalledTimes(0); + expect(catalogImportApi.analyzeUrl).toHaveBeenCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should not analyze invalid value', async () => { @@ -129,9 +129,9 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(catalogImportApi.analyzeUrl).toBeCalledTimes(0); - expect(onAnalysisFn).toBeCalledTimes(0); - expect(errorApi.post).toBeCalledTimes(0); + expect(catalogImportApi.analyzeUrl).toHaveBeenCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); expect( getByText('Must start with http:// or https://.'), ).toBeInTheDocument(); @@ -164,14 +164,14 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(1); + expect(onAnalysisFn).toHaveBeenCalledTimes(1); expect(onAnalysisFn.mock.calls[0]).toMatchObject([ 'single-location', 'https://my-repository', analyzeResult, { prepareResult: analyzeResult }, ]); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should analyze multiple locations', async () => { @@ -201,13 +201,13 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(1); + expect(onAnalysisFn).toHaveBeenCalledTimes(1); expect(onAnalysisFn.mock.calls[0]).toMatchObject([ 'multiple-locations', 'https://my-repository-1', analyzeResult, ]); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should not analyze with no locations', async () => { @@ -237,11 +237,11 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); expect( getByText('There are no entities at this location'), ).toBeInTheDocument(); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should analyze repository', async () => { @@ -281,13 +281,13 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(1); + expect(onAnalysisFn).toHaveBeenCalledTimes(1); expect(onAnalysisFn.mock.calls[0]).toMatchObject([ 'no-location', 'https://my-repository-2', analyzeResult, ]); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should not analyze repository without entities', async () => { @@ -319,11 +319,11 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); expect( getByText("Couldn't generate entities for your repository"), ).toBeInTheDocument(); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should not analyze repository if disabled', async () => { @@ -363,11 +363,11 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); expect( getByText("Couldn't generate entities for your repository"), ).toBeInTheDocument(); - expect(errorApi.post).toBeCalledTimes(0); + expect(errorApi.post).toHaveBeenCalledTimes(0); }); it('should report unknown type to the errorapi', async () => { @@ -392,13 +392,13 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Analyze/i })); }); - expect(onAnalysisFn).toBeCalledTimes(0); + expect(onAnalysisFn).toHaveBeenCalledTimes(0); expect( getByText( 'Received unknown analysis result of type unknown. Please contact the support team.', ), ).toBeInTheDocument(); - expect(errorApi.post).toBeCalledTimes(1); + expect(errorApi.post).toHaveBeenCalledTimes(1); expect(errorApi.post.mock.calls[0][0]).toMatchObject( new Error( 'Received unknown analysis result of type unknown. Please contact the support team.', diff --git a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.test.tsx b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.test.tsx index 90a2987958a8d..b4393667285c0 100644 --- a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.test.tsx +++ b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.test.tsx @@ -42,7 +42,7 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /submit/i })); }); - expect(onSubmitFn).toBeCalledTimes(1); + expect(onSubmitFn).toHaveBeenCalledTimes(1); expect(onSubmitFn.mock.calls[0][0]).toMatchObject({ main: 'default' }); }); @@ -72,7 +72,7 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /submit/i })); }); - expect(onSubmitFn).toBeCalledTimes(1); + expect(onSubmitFn).toHaveBeenCalledTimes(1); expect(onSubmitFn.mock.calls[0][0]).toMatchObject({ main: 'My Text' }); }); @@ -107,7 +107,7 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /submit/i })); }); - expect(onSubmitFn).not.toBeCalled(); + expect(onSubmitFn).not.toHaveBeenCalled(); expect(queryByText('Error in required main field')).toBeInTheDocument(); }); }); diff --git a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx index dac7f394a4920..f3dc1f2144234 100644 --- a/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx +++ b/plugins/catalog-import/src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.test.tsx @@ -173,7 +173,7 @@ describe('', () => { await userEvent.click(screen.getByRole('button', { name: /Create PR/i })); }); - expect(catalogImportApi.submitPullRequest).toBeCalledTimes(1); + expect(catalogImportApi.submitPullRequest).toHaveBeenCalledTimes(1); expect(catalogImportApi.submitPullRequest.mock.calls[0]).toMatchObject([ { body: 'My **body**', @@ -189,7 +189,7 @@ spec: title: 'My title', }, ]); - expect(onPrepareFn).toBeCalledTimes(1); + expect(onPrepareFn).toHaveBeenCalledTimes(1); expect(onPrepareFn.mock.calls[0]).toMatchObject([ { type: 'repository', @@ -250,8 +250,8 @@ spec: }); expect(screen.getByText('some error')).toBeInTheDocument(); - expect(catalogImportApi.submitPullRequest).toBeCalledTimes(1); - expect(onPrepareFn).toBeCalledTimes(0); + expect(catalogImportApi.submitPullRequest).toHaveBeenCalledTimes(1); + expect(onPrepareFn).toHaveBeenCalledTimes(0); }); it('should load groups', async () => { @@ -283,8 +283,8 @@ spec: ); }); - expect(catalogApi.getEntities).toBeCalledTimes(1); - expect(renderFormFieldsFn).toBeCalled(); + expect(catalogApi.getEntities).toHaveBeenCalledTimes(1); + expect(renderFormFieldsFn).toHaveBeenCalled(); expect(renderFormFieldsFn.mock.calls[0][0]).toMatchObject({ groups: [], groupsLoading: true, diff --git a/plugins/catalog-import/src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.test.tsx b/plugins/catalog-import/src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.test.tsx index 973a4fa3d74ea..1817ece1b8f08 100644 --- a/plugins/catalog-import/src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.test.tsx +++ b/plugins/catalog-import/src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.test.tsx @@ -200,7 +200,7 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Back/i })); }); - expect(onGoBack).toBeCalledTimes(1); + expect(onGoBack).toHaveBeenCalledTimes(1); }); it('should submit', async () => { @@ -224,7 +224,7 @@ describe('', () => { await userEvent.click(getByRole('button', { name: /Review/i })); }); - expect(onPrepare).toBeCalledTimes(1); + expect(onPrepare).toHaveBeenCalledTimes(1); expect(onPrepare.mock.calls[0][0]).toMatchObject({ type: 'locations', locations: [ diff --git a/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx b/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx index 9d76ba4e158d5..4173ca85b2ef6 100644 --- a/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx +++ b/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx @@ -101,7 +101,7 @@ describe('UnregisterEntityDialog', () => { await userEvent.click(screen.getByText('Cancel')); await waitFor(() => { - expect(onClose).toBeCalled(); + expect(onClose).toHaveBeenCalled(); }); }); @@ -196,8 +196,8 @@ describe('UnregisterEntityDialog', () => { await userEvent.click(screen.getByText('Delete Entity')); await waitFor(() => { - expect(deleteEntity).toBeCalled(); - expect(onConfirm).toBeCalled(); + expect(deleteEntity).toHaveBeenCalled(); + expect(onConfirm).toHaveBeenCalled(); }); }); @@ -236,8 +236,8 @@ describe('UnregisterEntityDialog', () => { await userEvent.click(screen.getByText('Delete Entity')); await waitFor(() => { - expect(deleteEntity).toBeCalled(); - expect(onConfirm).toBeCalled(); + expect(deleteEntity).toHaveBeenCalled(); + expect(onConfirm).toHaveBeenCalled(); }); }); @@ -284,8 +284,8 @@ describe('UnregisterEntityDialog', () => { await userEvent.click(screen.getByText('Unregister Location')); await waitFor(() => { - expect(unregisterLocation).toBeCalled(); - expect(onConfirm).toBeCalled(); + expect(unregisterLocation).toHaveBeenCalled(); + expect(onConfirm).toHaveBeenCalled(); }); }); @@ -340,8 +340,8 @@ describe('UnregisterEntityDialog', () => { await userEvent.click(screen.getByText('Delete Entity')); await waitFor(() => { - expect(deleteEntity).toBeCalled(); - expect(onConfirm).toBeCalled(); + expect(deleteEntity).toHaveBeenCalled(); + expect(onConfirm).toHaveBeenCalled(); }); }); }); diff --git a/plugins/catalog-react/src/hooks/useStarredEntity.test.tsx b/plugins/catalog-react/src/hooks/useStarredEntity.test.tsx index 77bd16c63637d..ad168e5f9d6da 100644 --- a/plugins/catalog-react/src/hooks/useStarredEntity.test.tsx +++ b/plugins/catalog-react/src/hooks/useStarredEntity.test.tsx @@ -58,8 +58,8 @@ describe('useStarredEntity', () => { result.current.toggleStarredEntity(); - expect(mockStarredEntitiesApi.toggleStarred).toBeCalledTimes(1); - expect(mockStarredEntitiesApi.toggleStarred).toBeCalledWith( + expect(mockStarredEntitiesApi.toggleStarred).toHaveBeenCalledTimes(1); + expect(mockStarredEntitiesApi.toggleStarred).toHaveBeenCalledWith( 'component:default/mock', ); }); diff --git a/plugins/catalog/src/apis/StarredEntitiesApi/DefaultStarredEntitiesApi.test.ts b/plugins/catalog/src/apis/StarredEntitiesApi/DefaultStarredEntitiesApi.test.ts index 2a3c4d83ed04d..b696e44e0a9c4 100644 --- a/plugins/catalog/src/apis/StarredEntitiesApi/DefaultStarredEntitiesApi.test.ts +++ b/plugins/catalog/src/apis/StarredEntitiesApi/DefaultStarredEntitiesApi.test.ts @@ -46,7 +46,7 @@ describe('DefaultStarredEntitiesApi', () => { const api = new DefaultStarredEntitiesApi({ storageApi: MockStorageApi.create(), }); - expect(performMigrationToTheNewBucket).toBeCalledTimes(1); + expect(performMigrationToTheNewBucket).toHaveBeenCalledTimes(1); expect(api).toBeDefined(); }); }); diff --git a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx index 0e981bb1fc84c..04cfa1b9472ba 100644 --- a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx @@ -57,7 +57,7 @@ describe('ComponentContextMenu', () => { expect(unregister).toBeInTheDocument(); fireEvent.click(unregister); - expect(mockCallback).toBeCalled(); + expect(mockCallback).toHaveBeenCalled(); }); it('check Unregister entity button is disabled', async () => { @@ -102,7 +102,7 @@ describe('ComponentContextMenu', () => { expect(unregister).toBeInTheDocument(); fireEvent.click(unregister); - expect(mockCallback).toBeCalled(); + expect(mockCallback).toHaveBeenCalled(); }); it('supports extra items', async () => { @@ -128,6 +128,6 @@ describe('ComponentContextMenu', () => { expect(item).toBeInTheDocument(); fireEvent.click(item); - expect(extra.onClick).toBeCalled(); + expect(extra.onClick).toHaveBeenCalled(); }); }); diff --git a/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.test.tsx b/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.test.tsx index 70b75c7baeaab..95cb601ea03ab 100644 --- a/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.test.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/UnregisterEntity.test.tsx @@ -54,7 +54,7 @@ describe('ComponentContextMenu', () => { expect(unregister).toBeInTheDocument(); fireEvent.click(unregister); - expect(mockCallback).toBeCalled(); + expect(mockCallback).toHaveBeenCalled(); }); it('check Unregister entity button is disabled', async () => { diff --git a/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.test.tsx b/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.test.tsx index ca7cbeec679bf..897f4889ff701 100644 --- a/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.test.tsx +++ b/plugins/catalog/src/components/EntityOrphanWarning/DeleteEntityDialog.test.tsx @@ -80,7 +80,7 @@ describe('DeleteEntityDialog', () => { await userEvent.click(screen.getByText('Cancel')); await waitFor(() => { - expect(onClose).toBeCalled(); + expect(onClose).toHaveBeenCalled(); }); }); @@ -101,8 +101,8 @@ describe('DeleteEntityDialog', () => { await userEvent.click(screen.getByText('Delete')); await waitFor(() => { - expect(catalogClient.removeEntityByUid).toBeCalledWith('123'); - expect(onConfirm).toBeCalled(); + expect(catalogClient.removeEntityByUid).toHaveBeenCalledWith('123'); + expect(onConfirm).toHaveBeenCalled(); }); }); @@ -124,8 +124,8 @@ describe('DeleteEntityDialog', () => { await userEvent.click(screen.getByText('Delete')); await waitFor(() => { - expect(catalogClient.removeEntityByUid).toBeCalledWith('123'); - expect(alertApi.post).toBeCalledWith({ message: 'no no no' }); + expect(catalogClient.removeEntityByUid).toHaveBeenCalledWith('123'); + expect(alertApi.post).toHaveBeenCalledWith({ message: 'no no no' }); }); }); }); diff --git a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx index e6cf65771a76b..7ef6c799df3df 100644 --- a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx +++ b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx @@ -170,7 +170,7 @@ describe('', () => { }, ); - expect(catalogApi.getEntities).toBeCalledWith( + expect(catalogApi.getEntities).toHaveBeenCalledWith( expect.objectContaining({ filter: { kind: 'API' }, }), diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts index bada5e1c29936..4f65e446fd63d 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts @@ -86,7 +86,7 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: jenkinsInfo.jobFullName, tree: expect.anything(), }); @@ -127,7 +127,7 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: `${jenkinsInfo.jobFullName}/testBranchName`, tree: expect.anything(), }); @@ -148,15 +148,15 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: `${jenkinsInfo.jobFullName}/foo`, tree: expect.anything(), }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: `${jenkinsInfo.jobFullName}/bar`, tree: expect.anything(), }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: `${jenkinsInfo.jobFullName}/catpants`, tree: expect.anything(), }); @@ -643,11 +643,11 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.get).toBeCalledWith({ + expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({ name: jobFullName, depth: 1, }); - expect(mockedJenkinsClient.build.get).toBeCalledWith( + expect(mockedJenkinsClient.build.get).toHaveBeenCalledWith( jobFullName, buildNumber, ); @@ -660,7 +660,7 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); + expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName); }); it('buildProject should fail if it does not have required permissions', async () => { @@ -688,7 +688,7 @@ describe('JenkinsApi', () => { headers: jenkinsInfo.headers, promisify: true, }); - expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); + expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName); }); it('buildProject with crumbIssuer option', async () => { @@ -701,6 +701,6 @@ describe('JenkinsApi', () => { promisify: true, crumbIssuer: true, }); - expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); + expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName); }); }); diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts index 5e6198e1cd157..b608a9f313874 100644 --- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts @@ -183,9 +183,9 @@ describe('DefaultJenkinsInfoProvider', () => { it('Handles entity not found', async () => { const provider = configureProvider({ jenkins: {} }, undefined); - await expect(provider.getInstance({ entityRef })).rejects.toThrowError(); + await expect(provider.getInstance({ entityRef })).rejects.toThrow(); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); }); @@ -209,7 +209,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toStrictEqual({ @@ -247,7 +247,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ @@ -286,7 +286,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ @@ -325,7 +325,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ @@ -353,7 +353,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ @@ -381,7 +381,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ @@ -414,7 +414,7 @@ describe('DefaultJenkinsInfoProvider', () => { ); const info: JenkinsInfo = await provider.getInstance({ entityRef }); - expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, { + expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, { backstageToken: undefined, }); expect(info).toMatchObject({ diff --git a/plugins/kafka/src/api/KafkaDashboardClient.test.ts b/plugins/kafka/src/api/KafkaDashboardClient.test.ts index 332b17cba6616..4e07bbf0e71d4 100644 --- a/plugins/kafka/src/api/KafkaDashboardClient.test.ts +++ b/plugins/kafka/src/api/KafkaDashboardClient.test.ts @@ -133,6 +133,6 @@ describe('KafkaDashboardClient', () => { } as unknown as Entity; kafkaDashboardClient.getDashboardUrl('cluster2', '', mockEntity); - expect(mockConfigApi.getConfigArray).toBeCalled(); + expect(mockConfigApi.getConfigArray).toHaveBeenCalled(); }); }); diff --git a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx index ead3e03934116..e2393d05985ab 100644 --- a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx +++ b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx @@ -166,7 +166,7 @@ describe('useConsumerGroupOffsets', () => { }, }; const { result } = subject(); - expect(() => result.current).toThrowError(); + expect(() => result.current).toThrow(); expect(result.error).toStrictEqual( new Error( `Failed to parse kafka consumer group annotation: got "dev/another,consumer"`, diff --git a/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.test.ts b/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.test.ts index 783ec16904f7d..11dc4572eaab1 100644 --- a/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.test.ts +++ b/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.test.ts @@ -35,7 +35,7 @@ describe('GkeClusterLocator', () => { listClusters: mockedListClusters, } as any); - expect(mockedListClusters).toBeCalledTimes(0); + expect(mockedListClusters).toHaveBeenCalledTimes(0); }); it('should not accept missing projectId', async () => { const config: Config = new ConfigReader({ @@ -48,7 +48,7 @@ describe('GkeClusterLocator', () => { } as any), ).toThrow("Missing required config value at 'projectId'"); - expect(mockedListClusters).toBeCalledTimes(0); + expect(mockedListClusters).toHaveBeenCalledTimes(0); }); }); describe('listClusters', () => { @@ -72,7 +72,7 @@ describe('GkeClusterLocator', () => { const result = await sut.getClusters(); expect(result).toStrictEqual([]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -111,7 +111,7 @@ describe('GkeClusterLocator', () => { skipMetricsLookup: true, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -148,7 +148,7 @@ describe('GkeClusterLocator', () => { skipMetricsLookup: false, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/-', }); @@ -197,7 +197,7 @@ describe('GkeClusterLocator', () => { skipMetricsLookup: false, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -252,7 +252,7 @@ describe('GkeClusterLocator', () => { skipMetricsLookup: false, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -306,7 +306,7 @@ describe('GkeClusterLocator', () => { skipMetricsLookup: false, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -330,7 +330,7 @@ describe('GkeClusterLocator', () => { 'There was an error retrieving clusters from GKE for projectId=some-project region=some-region; caused by Error: some error', ); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); @@ -376,7 +376,7 @@ describe('GkeClusterLocator', () => { }, }, ]); - expect(mockedListClusters).toBeCalledTimes(1); + expect(mockedListClusters).toHaveBeenCalledTimes(1); expect(mockedListClusters).toHaveBeenCalledWith({ parent: 'projects/some-project/locations/some-region', }); diff --git a/plugins/kubernetes-backend/src/cluster-locator/index.test.ts b/plugins/kubernetes-backend/src/cluster-locator/index.test.ts index f494fbbf2bebc..a43e475d8ed69 100644 --- a/plugins/kubernetes-backend/src/cluster-locator/index.test.ts +++ b/plugins/kubernetes-backend/src/cluster-locator/index.test.ts @@ -103,7 +103,7 @@ describe('getCombinedClusterSupplier', () => { 'ctx', ); - expect(() => getCombinedClusterSupplier(config, catalogApi)).toThrowError( + expect(() => getCombinedClusterSupplier(config, catalogApi)).toThrow( new Error('Unsupported kubernetes.clusterLocatorMethods: "magic"'), ); }); diff --git a/plugins/kubernetes/src/hooks/useKubernetesObjects.test.ts b/plugins/kubernetes/src/hooks/useKubernetesObjects.test.ts index 0daeb93d734ce..e5efafd477cb8 100644 --- a/plugins/kubernetes/src/hooks/useKubernetesObjects.test.ts +++ b/plugins/kubernetes/src/hooks/useKubernetesObjects.test.ts @@ -72,9 +72,11 @@ describe('useKubernetesObjects', () => { const mockDecorateRequestBodyForAuth = jest.fn(); const expectMocksCalledCorrectly = (numOfCalls: number = 1) => { - expect(mockGetClusters).toBeCalledTimes(numOfCalls); + expect(mockGetClusters).toHaveBeenCalledTimes(numOfCalls); expect(mockGetClusters).toHaveBeenLastCalledWith(); - expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(numOfCalls * 2); + expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes( + numOfCalls * 2, + ); expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledWith('google', { entity, }); @@ -82,7 +84,7 @@ describe('useKubernetesObjects', () => { 'authprovider2', entityWithAuthToken, ); - expect(mockGetObjectsByEntity).toBeCalledTimes(numOfCalls); + expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(numOfCalls); expect(mockGetObjectsByEntity).toHaveBeenLastCalledWith( entityWithAuthToken, ); @@ -166,10 +168,10 @@ describe('useKubernetesObjects', () => { expect(result.current.error).toBe('some-error'); expect(result.current.kubernetesObjects).toBeUndefined(); - expect(mockGetClusters).toBeCalledTimes(1); + expect(mockGetClusters).toHaveBeenCalledTimes(1); expect(mockGetClusters).toHaveBeenLastCalledWith(); - expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(0); - expect(mockGetObjectsByEntity).toBeCalledTimes(0); + expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes(0); + expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(0); }); it('should return error when decorateRequestBodyForAuth throws', async () => { (useApi as any).mockReturnValue({ @@ -189,12 +191,12 @@ describe('useKubernetesObjects', () => { expect(result.current.error).toBe('some-error'); expect(result.current.kubernetesObjects).toBeUndefined(); - expect(mockGetClusters).toBeCalledTimes(1); + expect(mockGetClusters).toHaveBeenCalledTimes(1); expect(mockGetClusters).toHaveBeenLastCalledWith(); - expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(1); + expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes(1); expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledWith('google', { entity, }); - expect(mockGetObjectsByEntity).toBeCalledTimes(0); + expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(0); }); }); diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatClusterLink.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatClusterLink.test.ts index b767d496a2a83..254b9fc51bc35 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatClusterLink.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatClusterLink.test.ts @@ -42,9 +42,7 @@ describe('clusterLinks', () => { }, kind: 'Deployment', }), - ).toThrowError( - "Could not find Kubernetes dashboard app named 'unknownapp'", - ); + ).toThrow("Could not find Kubernetes dashboard app named 'unknownapp'"); }); describe('default app', () => { diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/aks.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/aks.test.ts index 6f90ab1f1d28c..18db618686b92 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/aks.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/aks.test.ts @@ -27,7 +27,7 @@ describe('clusterLinks - AKS formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('AKS dashboard requires a dashboardParameters option'); + ).toThrow('AKS dashboard requires a dashboardParameters option'); }); it('should provide a subscriptionId in the dashboardParameters options', () => { expect(() => @@ -44,7 +44,7 @@ describe('clusterLinks - AKS formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'AKS dashboard requires a "subscriptionId" of type string in the dashboardParameters option', ); }); @@ -63,7 +63,7 @@ describe('clusterLinks - AKS formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'AKS dashboard requires a "resourceGroup" of type string in the dashboardParameters option', ); }); @@ -82,7 +82,7 @@ describe('clusterLinks - AKS formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'AKS dashboard requires a "clusterName" of type string in the dashboardParameters option', ); }); diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/eks.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/eks.test.ts index 5998bfde5e553..d0ae73753fa0d 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/eks.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/eks.test.ts @@ -28,6 +28,6 @@ describe('clusterLinks - EKS formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('EKS formatter is not yet implemented. Please, contribute!'); + ).toThrow('EKS formatter is not yet implemented. Please, contribute!'); }); }); diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/gke.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/gke.test.ts index 20541f216d10e..7fd08142679e5 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/gke.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/gke.test.ts @@ -27,7 +27,7 @@ describe('clusterLinks - GKE formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('GKE dashboard requires a dashboardParameters option'); + ).toThrow('GKE dashboard requires a dashboardParameters option'); }); it('should provide a projectId in the dashboardParameters options', () => { expect(() => @@ -44,7 +44,7 @@ describe('clusterLinks - GKE formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'GKE dashboard requires a "projectId" of type string in the dashboardParameters option', ); }); @@ -63,7 +63,7 @@ describe('clusterLinks - GKE formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'GKE dashboard requires a "region" of type string in the dashboardParameters option', ); }); @@ -82,7 +82,7 @@ describe('clusterLinks - GKE formatter', () => { }, kind: 'Deployment', }), - ).toThrowError( + ).toThrow( 'GKE dashboard requires a "clusterName" of type string in the dashboardParameters option', ); }); diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/openshift.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/openshift.test.ts index 2380d3e2d515a..945553e340d7c 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/openshift.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/openshift.test.ts @@ -27,7 +27,7 @@ describe('clusterLinks - OpenShift formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('OpenShift dashboard requires a dashboardUrl option'); + ).toThrow('OpenShift dashboard requires a dashboardUrl option'); }); it('should return an url on the workloads when there is a namespace only', () => { const url = openshiftFormatter({ diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/rancher.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/rancher.test.ts index 45983deab041d..bb26da3ab017d 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/rancher.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/rancher.test.ts @@ -27,7 +27,7 @@ describe('clusterLinks - rancher formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('Rancher dashboard requires a dashboardUrl option'); + ).toThrow('Rancher dashboard requires a dashboardUrl option'); }); it('should return a url on the workloads when there is a namespace only', () => { const url = rancherFormatter({ diff --git a/plugins/kubernetes/src/utils/clusterLinks/formatters/standard.test.ts b/plugins/kubernetes/src/utils/clusterLinks/formatters/standard.test.ts index c0ee3f534dd6f..280de6bfde2e5 100644 --- a/plugins/kubernetes/src/utils/clusterLinks/formatters/standard.test.ts +++ b/plugins/kubernetes/src/utils/clusterLinks/formatters/standard.test.ts @@ -34,7 +34,7 @@ describe('clusterLinks - standard formatter', () => { }, kind: 'Deployment', }), - ).toThrowError('standard dashboard requires a dashboardUrl option'); + ).toThrow('standard dashboard requires a dashboardUrl option'); }); it('should return an url on the workloads when there is a namespace only', () => { const url = standardFormatter({ diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 16a8898f0a503..28fa3f498820c 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -221,7 +221,7 @@ describe('OwnershipCard', () => { expect( queryByText(getByText('OPENAPI').parentElement!, '1'), ).toBeInTheDocument(); - expect(() => getByText('LIBRARY')).toThrowError(); + expect(() => getByText('LIBRARY')).toThrow(); }); it('links to the catalog with the group filter', async () => { diff --git a/plugins/pagerduty/src/api/client.test.ts b/plugins/pagerduty/src/api/client.test.ts index a32a533e6847d..84fabbbffa36b 100644 --- a/plugins/pagerduty/src/api/client.test.ts +++ b/plugins/pagerduty/src/api/client.test.ts @@ -114,7 +114,7 @@ describe('PagerDutyClient', () => { }); it('throws UnauthorizedError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( UnauthorizedError, ); }); @@ -130,7 +130,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); }); @@ -149,7 +149,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( 'Request failed with 500, Not valid request internal error occurred', ); }); @@ -165,7 +165,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); }); @@ -212,7 +212,7 @@ describe('PagerDutyClient', () => { }); it('throws UnauthorizedError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( UnauthorizedError, ); }); @@ -228,7 +228,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); }); @@ -247,7 +247,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( 'Request failed with 500, Not valid request internal error occurred', ); }); @@ -295,7 +295,7 @@ describe('PagerDutyClient', () => { }); it('throws UnauthorizedError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( UnauthorizedError, ); }); @@ -311,7 +311,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); }); @@ -330,7 +330,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( 'Request failed with 500, Not valid request internal error occurred', ); }); @@ -346,7 +346,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); }); @@ -366,7 +366,7 @@ describe('PagerDutyClient', () => { }); it('throws NotFoundError', async () => { - await expect(client.getServiceByEntity(entity)).rejects.toThrowError( + await expect(client.getServiceByEntity(entity)).rejects.toThrow( NotFoundError, ); expect(mockFetch).not.toHaveBeenCalled(); diff --git a/plugins/permission-backend/src/service/PermissionIntegrationClient.test.ts b/plugins/permission-backend/src/service/PermissionIntegrationClient.test.ts index 451a6895a99c8..4c50e1646f81a 100644 --- a/plugins/permission-backend/src/service/PermissionIntegrationClient.test.ts +++ b/plugins/permission-backend/src/service/PermissionIntegrationClient.test.ts @@ -189,7 +189,7 @@ describe('PermissionIntegrationClient', () => { conditions: mockConditions, }, ]), - ).rejects.toThrowError(/401/i); + ).rejects.toThrow(/401/i); }); it('should reject invalid responses', async () => { @@ -210,7 +210,7 @@ describe('PermissionIntegrationClient', () => { conditions: mockConditions, }, ]), - ).rejects.toThrowError(/invalid input/i); + ).rejects.toThrow(/invalid input/i); }); it('should batch requests to plugin backends', async () => { diff --git a/plugins/permission-common/src/PermissionClient.test.ts b/plugins/permission-common/src/PermissionClient.test.ts index 503ce2768da94..9b2bdcb9ff897 100644 --- a/plugins/permission-common/src/PermissionClient.test.ts +++ b/plugins/permission-common/src/PermissionClient.test.ts @@ -126,7 +126,7 @@ describe('PermissionClient', () => { ); await expect( client.authorize([mockAuthorizeConditional], { token }), - ).rejects.toThrowError(/request failed with 401/i); + ).rejects.toThrow(/request failed with 401/i); }); it('should reject responses with missing ids', async () => { @@ -141,7 +141,7 @@ describe('PermissionClient', () => { ); await expect( client.authorize([mockAuthorizeConditional], { token }), - ).rejects.toThrowError(/items in response do not match request/i); + ).rejects.toThrow(/items in response do not match request/i); }); it('should reject invalid responses', async () => { @@ -159,7 +159,7 @@ describe('PermissionClient', () => { ); await expect( client.authorize([mockAuthorizeConditional], { token }), - ).rejects.toThrowError(/invalid input/i); + ).rejects.toThrow(/invalid input/i); }); it('should allow all when permission.enabled is false', async () => { @@ -183,7 +183,7 @@ describe('PermissionClient', () => { expect(response[0]).toEqual( expect.objectContaining({ result: AuthorizeResult.ALLOW }), ); - expect(mockAuthorizeHandler).not.toBeCalled(); + expect(mockAuthorizeHandler).not.toHaveBeenCalled(); }); it('should allow all when permission.enabled is not configured', async () => { @@ -207,7 +207,7 @@ describe('PermissionClient', () => { expect(response[0]).toEqual( expect.objectContaining({ result: AuthorizeResult.ALLOW }), ); - expect(mockAuthorizeHandler).not.toBeCalled(); + expect(mockAuthorizeHandler).not.toHaveBeenCalled(); }); }); @@ -307,7 +307,7 @@ describe('PermissionClient', () => { client.authorizeConditional([mockResourceAuthorizeConditional], { token, }), - ).rejects.toThrowError(/request failed with 401/i); + ).rejects.toThrow(/request failed with 401/i); }); it('should reject responses with missing ids', async () => { @@ -324,7 +324,7 @@ describe('PermissionClient', () => { client.authorizeConditional([mockResourceAuthorizeConditional], { token, }), - ).rejects.toThrowError(/items in response do not match request/i); + ).rejects.toThrow(/items in response do not match request/i); }); it('should reject invalid responses', async () => { @@ -344,7 +344,7 @@ describe('PermissionClient', () => { client.authorizeConditional([mockResourceAuthorizeConditional], { token, }), - ).rejects.toThrowError(/invalid input/i); + ).rejects.toThrow(/invalid input/i); }); it('should allow all when permission.enabled is false', async () => { @@ -373,7 +373,7 @@ describe('PermissionClient', () => { expect(response[0]).toEqual( expect.objectContaining({ result: AuthorizeResult.ALLOW }), ); - expect(mockPolicyDecisionHandler).not.toBeCalled(); + expect(mockPolicyDecisionHandler).not.toHaveBeenCalled(); }); it('should allow all when permission.enabled is not configured', async () => { @@ -402,7 +402,7 @@ describe('PermissionClient', () => { expect(response[0]).toEqual( expect.objectContaining({ result: AuthorizeResult.ALLOW }), ); - expect(mockPolicyDecisionHandler).not.toBeCalled(); + expect(mockPolicyDecisionHandler).not.toHaveBeenCalled(); }); }); }); diff --git a/plugins/permission-node/src/ServerPermissionClient.test.ts b/plugins/permission-node/src/ServerPermissionClient.test.ts index bcdd5053b0a3d..75177af328074 100644 --- a/plugins/permission-node/src/ServerPermissionClient.test.ts +++ b/plugins/permission-node/src/ServerPermissionClient.test.ts @@ -69,7 +69,7 @@ describe('ServerPermissionClient', () => { discovery, tokenManager: ServerTokenManager.noop(), }), - ).toThrowError( + ).toThrow( 'Backend-to-backend authentication must be configured before enabling permissions. Read more here https://backstage.io/docs/tutorials/backend-to-backend-auth', ); }); diff --git a/plugins/permission-node/src/integration/util.test.ts b/plugins/permission-node/src/integration/util.test.ts index 17e27b6028f9f..6c1c270953266 100644 --- a/plugins/permission-node/src/integration/util.test.ts +++ b/plugins/permission-node/src/integration/util.test.ts @@ -51,7 +51,7 @@ describe('permission integration utils', () => { }); it('throws if there is no rule for the supplied name', () => { - expect(() => getRule('test-rule-3')).toThrowError( + expect(() => getRule('test-rule-3')).toThrow( /unexpected permission rule/i, ); }); diff --git a/plugins/permission-react/src/components/RequirePermission.test.tsx b/plugins/permission-react/src/components/RequirePermission.test.tsx index 262a602eada44..31ccc5042d6ce 100644 --- a/plugins/permission-react/src/components/RequirePermission.test.tsx +++ b/plugins/permission-react/src/components/RequirePermission.test.tsx @@ -69,7 +69,7 @@ describe('RequirePermission', () => { children={
content
} />, ), - ).rejects.toThrowError('Reached NotFound Page'); + ).rejects.toThrow('Reached NotFound Page'); }); it('Renders custom error page if not authorized', async () => { diff --git a/plugins/permission-react/src/hooks/usePermission.test.tsx b/plugins/permission-react/src/hooks/usePermission.test.tsx index 2862b10f96b7f..cbf3b22ae763e 100644 --- a/plugins/permission-react/src/hooks/usePermission.test.tsx +++ b/plugins/permission-react/src/hooks/usePermission.test.tsx @@ -83,6 +83,6 @@ describe('usePermission', () => { const { findByText } = renderComponent(mockPermissionApi); expect(mockPermissionApi.authorize).toHaveBeenCalledWith({ permission }); - await expect(findByText('content')).rejects.toThrowError(); + await expect(findByText('content')).rejects.toThrow(); }); }); diff --git a/plugins/proxy-backend/src/service/router.test.ts b/plugins/proxy-backend/src/service/router.test.ts index 3bfcc889f42c9..afe78aebebae9 100644 --- a/plugins/proxy-backend/src/service/router.test.ts +++ b/plugins/proxy-backend/src/service/router.test.ts @@ -392,9 +392,9 @@ describe('buildMiddleware', () => { it('rejects malformed target URLs', async () => { expect(() => buildMiddleware('/proxy', logger, '/test', 'backstage.io'), - ).toThrowError(/Proxy target is not a valid URL/); + ).toThrow(/Proxy target is not a valid URL/); expect(() => buildMiddleware('/proxy', logger, '/test', { target: 'backstage.io' }), - ).toThrowError(/Proxy target is not a valid URL/); + ).toThrow(/Proxy target is not a valid URL/); }); }); diff --git a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts index 3b235b96501df..23d343f354201 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts +++ b/plugins/scaffolder-backend-module-cookiecutter/src/actions/fetch/cookiecutter.test.ts @@ -139,7 +139,7 @@ describe('fetch:cookiecutter', () => { it('should throw an error when copyWithoutRender is not an array', async () => { (mockContext.input as any).copyWithoutRender = 'not an array'; - await expect(action.handler(mockContext)).rejects.toThrowError( + await expect(action.handler(mockContext)).rejects.toThrow( /Fetch action input copyWithoutRender must be an Array/, ); }); @@ -147,7 +147,7 @@ describe('fetch:cookiecutter', () => { it('should throw an error when extensions is not an array', async () => { (mockContext.input as any).extensions = 'not an array'; - await expect(action.handler(mockContext)).rejects.toThrowError( + await expect(action.handler(mockContext)).rejects.toThrow( /Fetch action input extensions must be an Array/, ); }); diff --git a/plugins/scaffolder-backend/src/processor/ScaffolderEntitiesProcessor.test.ts b/plugins/scaffolder-backend/src/processor/ScaffolderEntitiesProcessor.test.ts index c5278edce3eb8..db817af569424 100644 --- a/plugins/scaffolder-backend/src/processor/ScaffolderEntitiesProcessor.test.ts +++ b/plugins/scaffolder-backend/src/processor/ScaffolderEntitiesProcessor.test.ts @@ -58,8 +58,8 @@ describe('ScaffolderEntitiesProcessor', () => { await processor.postProcessEntity(mockEntity, mockLocation, emit); - expect(emit).toBeCalledTimes(2); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledTimes(2); + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Group', namespace: 'default', name: 'o' }, @@ -67,7 +67,7 @@ describe('ScaffolderEntitiesProcessor', () => { target: { kind: 'Template', namespace: 'default', name: 'n' }, }, }); - expect(emit).toBeCalledWith({ + expect(emit).toHaveBeenCalledWith({ type: 'relation', relation: { source: { kind: 'Template', namespace: 'default', name: 'n' }, diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/catalog/register.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/catalog/register.test.ts index d257bced38d81..c718f3906eff5 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/catalog/register.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/catalog/register.test.ts @@ -107,11 +107,11 @@ describe('catalog:register', () => { {}, ); - expect(mockContext.output).toBeCalledWith( + expect(mockContext.output).toHaveBeenCalledWith( 'entityRef', 'component:default/test', ); - expect(mockContext.output).toBeCalledWith( + expect(mockContext.output).toHaveBeenCalledWith( 'catalogInfoUrl', 'http://foo/var', ); @@ -160,7 +160,7 @@ describe('catalog:register', () => { catalogInfoUrl: 'http://foo/var', }, }); - expect(mockContext.output).toBeCalledWith( + expect(mockContext.output).toHaveBeenCalledWith( 'entityRef', 'component:default/test', ); @@ -202,7 +202,10 @@ describe('catalog:register', () => { catalogInfoUrl: 'http://foo/var', }, }); - expect(mockContext.output).toBeCalledWith('entityRef', 'api:default/test'); + expect(mockContext.output).toHaveBeenCalledWith( + 'entityRef', + 'api:default/test', + ); }); it('should return entityRef with the first entity if no non-generated entities can be found', async () => { @@ -234,7 +237,7 @@ describe('catalog:register', () => { catalogInfoUrl: 'http://foo/var', }, }); - expect(mockContext.output).toBeCalledWith( + expect(mockContext.output).toHaveBeenCalledWith( 'entityRef', 'location:default/generated-1238', ); @@ -254,7 +257,7 @@ describe('catalog:register', () => { catalogInfoUrl: 'http://foo/var', }, }); - expect(mockContext.output).not.toBeCalledWith( + expect(mockContext.output).not.toHaveBeenCalledWith( 'entityRef', expect.any(String), ); @@ -292,7 +295,7 @@ describe('catalog:register', () => { {}, ); - expect(mockContext.output).toBeCalledWith( + expect(mockContext.output).toHaveBeenCalledWith( 'catalogInfoUrl', 'http://foo/var', ); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/debug/log.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/debug/log.test.ts index ecd0f33e2117d..544784acb5055 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/debug/log.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/debug/log.test.ts @@ -54,7 +54,7 @@ describe('debug:log', () => { it('should do nothing', async () => { await action.handler(mockContext); - expect(logStream.write).toBeCalledTimes(0); + expect(logStream.write).toHaveBeenCalledTimes(0); }); it('should log the workspace content, if active', async () => { @@ -67,11 +67,11 @@ describe('debug:log', () => { await action.handler(context); - expect(logStream.write).toBeCalledTimes(1); - expect(logStream.write).toBeCalledWith( + expect(logStream.write).toHaveBeenCalledTimes(1); + expect(logStream.write).toHaveBeenCalledWith( expect.stringContaining('README.md'), ); - expect(logStream.write).toBeCalledWith( + expect(logStream.write).toHaveBeenCalledWith( expect.stringContaining(join('a-directory', 'index.md')), ); }); @@ -86,8 +86,8 @@ describe('debug:log', () => { await action.handler(context); - expect(logStream.write).toBeCalledTimes(1); - expect(logStream.write).toBeCalledWith( + expect(logStream.write).toHaveBeenCalledTimes(1); + expect(logStream.write).toHaveBeenCalledWith( expect.stringContaining('Hello Backstage!'), ); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/helpers.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/helpers.test.ts index d274ad3ba81cc..3c58c833ff2e7 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/helpers.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/helpers.test.ts @@ -81,7 +81,7 @@ describe('fetchContent helper', () => { fetchUrl: 'foo', outputPath: 'somepath', }); - expect(fs.copy).toBeCalledWith(resolvePath('/some/foo'), 'somepath'); + expect(fs.copy).toHaveBeenCalledWith(resolvePath('/some/foo'), 'somepath'); }); it('should reject if no integration matches location', async () => { @@ -116,7 +116,7 @@ describe('fetchContent helper', () => { outputPath: 'foo', fetchUrl: 'https://github.com/backstage/foo', }); - expect(fs.ensureDir).toBeCalled(); - expect(dirFunction).toBeCalledWith({ targetDir: 'foo' }); + expect(fs.ensureDir).toHaveBeenCalled(); + expect(dirFunction).toHaveBeenCalledWith({ targetDir: 'foo' }); }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts index 0ef095bf7919b..740f27a623638 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/plain.test.ts @@ -73,7 +73,7 @@ describe('fetch:plain', () => { targetPath: 'lol', }, }); - expect(fetchContents).toBeCalledWith( + expect(fetchContents).toHaveBeenCalledWith( expect.objectContaining({ outputPath: resolvePath(mockContext.workspacePath, 'lol'), fetchUrl: diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts index af353bef70105..165289de23f06 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts @@ -117,7 +117,7 @@ describe('fetch:template', () => { it('throws if output directory is outside the workspace', async () => { await expect(() => action.handler(mockContext({ targetPath: '../' })), - ).rejects.toThrowError( + ).rejects.toThrow( /relative path is not allowed to refer to a directory outside its parent/i, ); }); @@ -127,7 +127,7 @@ describe('fetch:template', () => { action.handler( mockContext({ copyWithoutRender: 'abc' as unknown as string[] }), ), - ).rejects.toThrowError( + ).rejects.toThrow( /copyWithoutRender\/copyWithoutTemplating must be an array/i, ); }); @@ -140,7 +140,7 @@ describe('fetch:template', () => { copyWithoutTemplating: 'def' as unknown as string[], }), ), - ).rejects.toThrowError( + ).rejects.toThrow( /copyWithoutRender and copyWithoutTemplating can not be used at the same time/i, ); }); @@ -153,7 +153,7 @@ describe('fetch:template', () => { templateFileExtension: true, }), ), - ).rejects.toThrowError( + ).rejects.toThrow( /input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/, ); }); @@ -166,7 +166,7 @@ describe('fetch:template', () => { templateFileExtension: true, }), ), - ).rejects.toThrowError( + ).rejects.toThrow( /input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/, ); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts index 1bc768e4bded9..43b4eeb58dbd8 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/githubPullRequest.test.ts @@ -302,8 +302,8 @@ describe('createPublishGithubPullRequestAction', () => { it('creates a pull request and requests a review from the given reviewers', async () => { await instance.handler(ctx); - expect(fakeClient.createPullRequest).toBeCalled(); - expect(fakeClient.rest.pulls.requestReviewers).toBeCalledWith({ + expect(fakeClient.createPullRequest).toHaveBeenCalled(); + expect(fakeClient.rest.pulls.requestReviewers).toHaveBeenCalledWith({ owner: 'myorg', repo: 'myrepo', pull_number: 123, @@ -354,8 +354,8 @@ describe('createPublishGithubPullRequestAction', () => { it('does not call the API endpoint for requesting reviewers', async () => { await instance.handler(ctx); - expect(fakeClient.createPullRequest).toBeCalled(); - expect(fakeClient.rest.pulls.requestReviewers).not.toBeCalled(); + expect(fakeClient.createPullRequest).toHaveBeenCalled(); + expect(fakeClient.rest.pulls.requestReviewers).not.toHaveBeenCalled(); }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts index 6b1701380b4a5..3627d83aa733c 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts @@ -128,7 +128,7 @@ describe('DefaultWorkflowRunner', () => { steps: [{ id: 'test', name: 'name', action: 'does-not-exist' }], }); - await expect(runner.execute(task)).rejects.toThrowError( + await expect(runner.execute(task)).rejects.toThrow( "Template action with ID 'does-not-exist' is not registered.", ); }); @@ -142,7 +142,7 @@ describe('DefaultWorkflowRunner', () => { steps: [{ id: 'test', name: 'name', action: 'jest-validated-action' }], }); - await expect(runner.execute(task)).rejects.toThrowError( + await expect(runner.execute(task)).rejects.toThrow( /Invalid input passed to action jest-validated-action, instance requires property \"foo\"/, ); }); diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index 9e2c7b926572c..20cd64668ed0a 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -410,7 +410,7 @@ describe('createRouter', () => { }); const response = await request(app).get(`/v2/tasks`); - expect(taskBroker.list).toBeCalledWith({ + expect(taskBroker.list).toHaveBeenCalledWith({ createdBy: undefined, }); expect(response.status).toEqual(200); @@ -445,7 +445,7 @@ describe('createRouter', () => { const response = await request(app).get( `/v2/tasks?createdBy=user:default/foo`, ); - expect(taskBroker.list).toBeCalledWith({ + expect(taskBroker.list).toHaveBeenCalledWith({ createdBy: 'user:default/foo', }); @@ -545,18 +545,18 @@ describe('createRouter', () => { expect(statusCode).toBe(200); expect(headers['content-type']).toBe('text/event-stream'); - expect(responseDataFn).toBeCalledTimes(2); - expect(responseDataFn).toBeCalledWith(`event: log + expect(responseDataFn).toHaveBeenCalledTimes(2); + expect(responseDataFn).toHaveBeenCalledWith(`event: log data: {"id":0,"taskId":"a-random-id","type":"log","createdAt":"","body":{"message":"My log message"}} `); - expect(responseDataFn).toBeCalledWith(`event: completion + expect(responseDataFn).toHaveBeenCalledWith(`event: completion data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{"message":"Finished!"}} `); - expect(taskBroker.event$).toBeCalledTimes(1); - expect(taskBroker.event$).toBeCalledWith({ taskId: 'a-random-id' }); + expect(taskBroker.event$).toHaveBeenCalledTimes(1); + expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id' }); expect(subscriber!.closed).toBe(true); }); @@ -607,8 +607,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ expect(statusCode).toBe(200); expect(headers['content-type']).toBe('text/event-stream'); - expect(taskBroker.event$).toBeCalledTimes(1); - expect(taskBroker.event$).toBeCalledWith({ + expect(taskBroker.event$).toHaveBeenCalledTimes(1); + expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id', after: 10, }); @@ -666,8 +666,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ }, ]); - expect(taskBroker.event$).toBeCalledTimes(1); - expect(taskBroker.event$).toBeCalledWith({ taskId: 'a-random-id' }); + expect(taskBroker.event$).toHaveBeenCalledTimes(1); + expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id' }); expect(subscriber!.closed).toBe(true); }); @@ -689,8 +689,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ expect(response.status).toEqual(200); expect(response.body).toEqual([]); - expect(taskBroker.event$).toBeCalledTimes(1); - expect(taskBroker.event$).toBeCalledWith({ + expect(taskBroker.event$).toHaveBeenCalledTimes(1); + expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id', after: 10, }); diff --git a/plugins/scaffolder/src/api.test.ts b/plugins/scaffolder/src/api.test.ts index 583258c0696b5..e21bda8fd7c47 100644 --- a/plugins/scaffolder/src/api.test.ts +++ b/plugins/scaffolder/src/api.test.ts @@ -110,21 +110,21 @@ describe('api', () => { .subscribe({ next, complete }); }); - expect(MockedEventSource).toBeCalledWith( + expect(MockedEventSource).toHaveBeenCalledWith( 'http://backstage/api/v2/tasks/a-random-task-id/eventstream', { withCredentials: true }, ); - expect(MockedEventSource.prototype.close).toBeCalled(); + expect(MockedEventSource.prototype.close).toHaveBeenCalled(); - expect(next).toBeCalledTimes(2); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledTimes(2); + expect(next).toHaveBeenCalledWith({ id: 1, taskId: 'a-random-id', type: 'log', createdAt: '', body: { message: 'My log message' }, }); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledWith({ id: 2, taskId: 'a-random-id', type: 'completion', @@ -194,15 +194,15 @@ describe('api', () => { .subscribe({ next, complete }), ); - expect(next).toBeCalledTimes(2); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledTimes(2); + expect(next).toHaveBeenCalledWith({ id: 1, taskId: 'a-random-id', type: 'log', createdAt: '', body: { message: 'My log message' }, }); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledWith({ id: 2, taskId: 'a-random-id', type: 'completion', @@ -258,8 +258,8 @@ describe('api', () => { }); }); - expect(next).toBeCalledTimes(1); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledTimes(1); + expect(next).toHaveBeenCalledWith({ id: 1, taskId: 'a-random-id', type: 'log', @@ -304,10 +304,10 @@ describe('api', () => { .subscribe({ next, complete }), ); - expect(called).toBeCalledTimes(2); + expect(called).toHaveBeenCalledTimes(2); - expect(next).toBeCalledTimes(1); - expect(next).toBeCalledWith({ + expect(next).toHaveBeenCalledTimes(1); + expect(next).toHaveBeenCalledWith({ id: 2, taskId: 'a-random-id', type: 'completion', @@ -387,7 +387,7 @@ describe('api', () => { }); const result = await apiClient.listTasks({ filterByOwnership: 'owned' }); - expect(identityApi.getBackstageIdentity).toBeCalled(); + expect(identityApi.getBackstageIdentity).toHaveBeenCalled(); expect(result.tasks).toHaveLength(1); }); }); diff --git a/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx b/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx index 6dc26abd68a18..837b87437f771 100644 --- a/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx +++ b/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx @@ -141,7 +141,7 @@ describe('', () => { }, ); - expect(scaffolderApiMock.listTasks).toBeCalledWith({ + expect(scaffolderApiMock.listTasks).toHaveBeenCalledWith({ filterByOwnership: 'owned', }); expect(getByText('List template tasks')).toBeInTheDocument(); @@ -240,7 +240,7 @@ describe('', () => { fireEvent.click(allButton); }); - expect(scaffolderApiMock.listTasks).toBeCalledWith({ + expect(scaffolderApiMock.listTasks).toHaveBeenCalledWith({ filterByOwnership: 'all', }); expect(await findByText('One Template')).toBeInTheDocument(); diff --git a/plugins/scaffolder/src/components/ListTasksPage/OwnerListPicker.test.tsx b/plugins/scaffolder/src/components/ListTasksPage/OwnerListPicker.test.tsx index bf0ae6d9461bf..63f943d6dda7c 100644 --- a/plugins/scaffolder/src/components/ListTasksPage/OwnerListPicker.test.tsx +++ b/plugins/scaffolder/src/components/ListTasksPage/OwnerListPicker.test.tsx @@ -42,6 +42,6 @@ describe('', () => { const { getByText } = await renderInTestApp(); fireEvent.click(await getByText('All')); - expect(props.onSelectOwner).toBeCalledWith('all'); + expect(props.onSelectOwner).toHaveBeenCalledWith('all'); }); }); diff --git a/plugins/scaffolder/src/components/TemplatePage/createValidator.test.ts b/plugins/scaffolder/src/components/TemplatePage/createValidator.test.ts index a5b04df71e4fe..f549c9e7f26ab 100644 --- a/plugins/scaffolder/src/components/TemplatePage/createValidator.test.ts +++ b/plugins/scaffolder/src/components/TemplatePage/createValidator.test.ts @@ -68,6 +68,6 @@ describe('createValidator', () => { /* THEN */ expect(result).not.toBeNull(); - expect(result.p1.addError).toBeCalledTimes(1); + expect(result.p1.addError).toHaveBeenCalledTimes(1); }); }); diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts index 64725e446d7e5..3a237664a81d5 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts @@ -937,7 +937,7 @@ describe('ElasticSearchSearchEngine', () => { logger: getVoidLogger(), config, }), - ).not.toThrowError(); + ).not.toThrow(); }); }); }); diff --git a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.test.ts b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.test.ts index 1fc7e74fc4f8a..03b9774751b20 100644 --- a/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.test.ts +++ b/plugins/search-backend-module-pg/src/PgSearchEngine/PgSearchEngineIndexer.test.ts @@ -77,7 +77,7 @@ describe('PgSearchEngineIndexer', () => { expect(database.getTransaction).toHaveBeenCalledTimes(1); expect(database.prepareInsert).toHaveBeenCalledTimes(1); - expect(database.insertDocuments).toBeCalledTimes(4); + expect(database.insertDocuments).toHaveBeenCalledTimes(4); expect(database.completeInsert).toHaveBeenCalledWith(tx, 'my-type'); }); diff --git a/plugins/search-backend-node/src/Scheduler.test.ts b/plugins/search-backend-node/src/Scheduler.test.ts index 7eaa6e8c9dac5..30e5c7e416bdd 100644 --- a/plugins/search-backend-node/src/Scheduler.test.ts +++ b/plugins/search-backend-node/src/Scheduler.test.ts @@ -55,7 +55,7 @@ describe('Scheduler', () => { task: mockTask2, scheduledRunner: mockScheduledTaskRunner2, }), - ).toThrowError(); + ).toThrow(); expect(mockScheduledTaskRunner1.run).toHaveBeenCalledWith( expect.objectContaining({ @@ -95,7 +95,7 @@ describe('Scheduler', () => { task: mockTask2, scheduledRunner: mockScheduledTaskRunner2, }), - ).toThrowError(); + ).toThrow(); // Starts scheduling process testScheduler.start(); @@ -144,7 +144,7 @@ describe('Scheduler', () => { task: mockTask2, scheduledRunner: mockScheduledTaskRunner2, }), - ).not.toThrowError(); + ).not.toThrow(); // Starts scheduling process testScheduler.start(); diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts index 198995b3cfc38..7120fc7ce578e 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.test.ts @@ -72,7 +72,7 @@ describe('DefaultCatalogCollatorFactory', () => { it('throws if url reader throws an error during search', async () => { reader.search.mockRejectedValue(new Error('Expected error')); - await expect(() => factory.getCollator()).rejects.toThrowError( + await expect(() => factory.getCollator()).rejects.toThrow( 'Expected error', ); }); @@ -80,7 +80,7 @@ describe('DefaultCatalogCollatorFactory', () => { it('throws if no matching files are found', async () => { reader.search.mockResolvedValue({ files: [], etag: '' }); - await expect(() => factory.getCollator()).rejects.toThrowError( + await expect(() => factory.getCollator()).rejects.toThrow( 'Could not find an .ndjson file matching', ); }); @@ -95,7 +95,7 @@ describe('DefaultCatalogCollatorFactory', () => { stream: jest.fn().mockReturnValue(readable), }); - await expect(() => factory.getCollator()).rejects.toThrowError( + await expect(() => factory.getCollator()).rejects.toThrow( 'Could not find an .ndjson file matching', ); }); diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts b/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts index 521cb9ee81f95..f0518cd71d085 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts @@ -133,16 +133,16 @@ describe('LunrSearchEngine', () => { actualTranslatedQuery.lunrQueryBuilder.bind(query)(query); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 100, usePipeline: true, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 10, usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 1, usePipeline: false, editDistance: 2, @@ -174,16 +174,16 @@ describe('LunrSearchEngine', () => { actualTranslatedQuery.lunrQueryBuilder.bind(query)(query); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 100, usePipeline: true, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 10, usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 1, usePipeline: false, editDistance: 2, @@ -215,21 +215,21 @@ describe('LunrSearchEngine', () => { actualTranslatedQuery.lunrQueryBuilder.bind(query)(query); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 100, usePipeline: true, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 10, usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 1, usePipeline: false, editDistance: 2, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testKind'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testKind'), { fields: ['kind'], presence: lunr.Query.presence.REQUIRED, }); @@ -260,7 +260,7 @@ describe('LunrSearchEngine', () => { actualTranslatedQuery.lunrQueryBuilder.bind(query)(query); - expect(query.term).toBeCalledWith(lunr.tokenizer('testKind'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testKind'), { fields: ['kind'], presence: lunr.Query.presence.REQUIRED, }); @@ -291,25 +291,25 @@ describe('LunrSearchEngine', () => { actualTranslatedQuery.lunrQueryBuilder.bind(query)(query); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 100, usePipeline: true, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 10, usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testTerm'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testTerm'), { boost: 1, usePipeline: false, editDistance: 2, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testKind'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testKind'), { fields: ['kind'], presence: lunr.Query.presence.REQUIRED, }); - expect(query.term).toBeCalledWith(lunr.tokenizer('testNameSpace'), { + expect(query.term).toHaveBeenCalledWith(lunr.tokenizer('testNameSpace'), { fields: ['namespace'], presence: lunr.Query.presence.REQUIRED, }); diff --git a/plugins/search-react/src/components/SearchResultPager/SearchResultPager.test.tsx b/plugins/search-react/src/components/SearchResultPager/SearchResultPager.test.tsx index 24d9a76e51a69..2508604ca9fb6 100644 --- a/plugins/search-react/src/components/SearchResultPager/SearchResultPager.test.tsx +++ b/plugins/search-react/src/components/SearchResultPager/SearchResultPager.test.tsx @@ -46,13 +46,13 @@ describe('SearchResultPager', () => { expect(getByLabelText('previous page')).toBeInTheDocument(); }); await userEvent.click(getByLabelText('previous page')); - expect(fetchPreviousPage).toBeCalled(); + expect(fetchPreviousPage).toHaveBeenCalled(); await waitFor(() => { expect(getByLabelText('next page')).toBeInTheDocument(); }); await userEvent.click(getByLabelText('next page')); - expect(fetchNextPage).toBeCalled(); + expect(fetchNextPage).toHaveBeenCalled(); }); }); diff --git a/plugins/shortcuts/src/AddShortcut.test.tsx b/plugins/shortcuts/src/AddShortcut.test.tsx index b35b4c588d3d9..c6d89318b2e13 100644 --- a/plugins/shortcuts/src/AddShortcut.test.tsx +++ b/plugins/shortcuts/src/AddShortcut.test.tsx @@ -60,7 +60,7 @@ describe('AddShortcut', () => { fireEvent.click(screen.getByText('Save')); await waitFor(() => { - expect(spy).toBeCalledWith({ + expect(spy).toHaveBeenCalledWith({ title: 'some title', url: '/some-url', }); @@ -77,7 +77,7 @@ describe('AddShortcut', () => { fireEvent.click(screen.getByText('Use current page')); fireEvent.click(screen.getByText('Save')); await waitFor(() => { - expect(spy).toBeCalledWith({ + expect(spy).toHaveBeenCalledWith({ title: 'some document title', url: '/some-initial-url', }); diff --git a/plugins/shortcuts/src/EditShortcut.test.tsx b/plugins/shortcuts/src/EditShortcut.test.tsx index a08299055b376..4d5128b0a827c 100644 --- a/plugins/shortcuts/src/EditShortcut.test.tsx +++ b/plugins/shortcuts/src/EditShortcut.test.tsx @@ -66,7 +66,7 @@ describe('EditShortcut', () => { fireEvent.click(screen.getByText('Save')); await waitFor(() => { - expect(spy).toBeCalledWith({ + expect(spy).toHaveBeenCalledWith({ id: 'id', title: 'some new title', url: '/some-new-url', @@ -81,7 +81,7 @@ describe('EditShortcut', () => { await renderInTestApp(); fireEvent.click(screen.getByText('Remove')); - expect(spy).toBeCalledWith('id'); + expect(spy).toHaveBeenCalledWith('id'); }); it('displays errors', async () => { diff --git a/plugins/sonarqube-backend/src/service/router.test.ts b/plugins/sonarqube-backend/src/service/router.test.ts index 426066d897b1a..7045cdf0d2e85 100644 --- a/plugins/sonarqube-backend/src/service/router.test.ts +++ b/plugins/sonarqube-backend/src/service/router.test.ts @@ -69,8 +69,8 @@ describe('createRouter', () => { instanceKey: DUMMY_INSTANCE_KEY, }) .send(); - expect(getFindingsMock).toBeCalledTimes(1); - expect(getFindingsMock).toBeCalledWith({ + expect(getFindingsMock).toHaveBeenCalledTimes(1); + expect(getFindingsMock).toHaveBeenCalledWith({ componentKey: DUMMY_COMPONENT_KEY, instanceName: DUMMY_INSTANCE_KEY, }); @@ -103,8 +103,8 @@ describe('createRouter', () => { }) .send(); - expect(getFindingsMock).toBeCalledTimes(1); - expect(getFindingsMock).toBeCalledWith({ + expect(getFindingsMock).toHaveBeenCalledTimes(1); + expect(getFindingsMock).toHaveBeenCalledWith({ componentKey: DUMMY_COMPONENT_KEY, instanceName: undefined, }); @@ -123,8 +123,8 @@ describe('createRouter', () => { instanceKey: DUMMY_INSTANCE_KEY, }) .send(); - expect(getBaseUrlMock).toBeCalledTimes(1); - expect(getBaseUrlMock).toBeCalledWith({ + expect(getBaseUrlMock).toHaveBeenCalledTimes(1); + expect(getBaseUrlMock).toHaveBeenCalledWith({ instanceName: DUMMY_INSTANCE_KEY, }); expect(response.status).toEqual(200); @@ -134,8 +134,8 @@ describe('createRouter', () => { it('query default instance when instanceKey not provided', async () => { getBaseUrlMock.mockReturnValue({ baseUrl: DUMMY_INSTANCE_URL }); const response = await request(app).get('/instanceUrl').send(); - expect(getBaseUrlMock).toBeCalledTimes(1); - expect(getBaseUrlMock).toBeCalledWith({ + expect(getBaseUrlMock).toHaveBeenCalledTimes(1); + expect(getBaseUrlMock).toHaveBeenCalledWith({ instanceName: undefined, }); expect(response.status).toEqual(200); diff --git a/plugins/sonarqube-backend/src/service/sonarqubeInfoProvider.test.ts b/plugins/sonarqube-backend/src/service/sonarqubeInfoProvider.test.ts index 64313e8fd281e..5675d635e1dc6 100644 --- a/plugins/sonarqube-backend/src/service/sonarqubeInfoProvider.test.ts +++ b/plugins/sonarqube-backend/src/service/sonarqubeInfoProvider.test.ts @@ -129,7 +129,7 @@ describe('SonarqubeConfig', () => { }, }), ), - ).toThrowError(Error); + ).toThrow(Error); }); it('Throw an error if default config is partially provided', async () => { @@ -141,7 +141,7 @@ describe('SonarqubeConfig', () => { }, }), ), - ).toThrowError(Error); + ).toThrow(Error); }); }); @@ -208,7 +208,7 @@ describe('SonarqubeConfig', () => { expect(() => config.getInstanceConfig({ sonarqubeName: 'default' }), - ).toThrowError(Error); + ).toThrow(Error); }); it('Throw an error if named instance could not be found', async () => { @@ -218,7 +218,7 @@ describe('SonarqubeConfig', () => { expect(() => config.getInstanceConfig({ sonarqubeName: 'other' }), - ).toThrowError(Error); + ).toThrow(Error); }); }); }); diff --git a/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.test.ts b/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.test.ts index c808713c3be5b..0d651be178745 100644 --- a/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.test.ts +++ b/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.test.ts @@ -219,14 +219,14 @@ describe('JsonRulesEngineFactChecker', () => { describe('when running checks', () => { it('should throw on incorrectly configured checks conditions', async () => { const cur = async () => await factChecker.runChecks('a/a/a', ['broken']); - await expect(cur()).rejects.toThrowError( + await expect(cur()).rejects.toThrow( 'Failed to run rules engine, Unknown operator: largerThan', ); }); it('should handle cases where wrong facts are referenced', async () => { const cur = async () => await factChecker.runChecks('a/a/a', ['broken2']); - await expect(cur()).rejects.toThrowError( + await expect(cur()).rejects.toThrow( 'Failed to run rules engine, Undefined fact: somefact', ); }); diff --git a/plugins/tech-insights-backend/src/service/fact/FactRetrieverEngine.test.ts b/plugins/tech-insights-backend/src/service/fact/FactRetrieverEngine.test.ts index 3a9506ed46a7f..37c7cdf3ca8b8 100644 --- a/plugins/tech-insights-backend/src/service/fact/FactRetrieverEngine.test.ts +++ b/plugins/tech-insights-backend/src/service/fact/FactRetrieverEngine.test.ts @@ -173,7 +173,7 @@ describe('FactRetrieverEngine', () => { () => {}, schemaAssertionCallback, ); - expect(schemaAssertionCallback).toBeCalled(); + expect(schemaAssertionCallback).toHaveBeenCalled(); }, 60_000, ); diff --git a/plugins/tech-radar/src/components/RadarPage.test.tsx b/plugins/tech-radar/src/components/RadarPage.test.tsx index c0ebde17c8bb3..f0c2a0459068e 100644 --- a/plugins/tech-radar/src/components/RadarPage.test.tsx +++ b/plugins/tech-radar/src/components/RadarPage.test.tsx @@ -98,7 +98,7 @@ describe('RadarPage', () => { expect( getByText('Pick the recommended technologies for your projects'), ).toBeInTheDocument(); - expect(mockClient.load).toBeCalledWith(undefined); + expect(mockClient.load).toHaveBeenCalledWith(undefined); }); it('should call load with id', async () => { @@ -119,7 +119,7 @@ describe('RadarPage', () => { ); await expect(findByTestId('tech-radar-svg')).resolves.toBeInTheDocument(); - expect(mockClient.load).toBeCalledWith('myId'); + expect(mockClient.load).toHaveBeenCalledWith('myId'); }); it('should call the errorApi if load fails', async () => { diff --git a/plugins/techdocs-backend/src/cache/TechDocsCache.test.ts b/plugins/techdocs-backend/src/cache/TechDocsCache.test.ts index 17613e1b58940..039f1db09f2fd 100644 --- a/plugins/techdocs-backend/src/cache/TechDocsCache.test.ts +++ b/plugins/techdocs-backend/src/cache/TechDocsCache.test.ts @@ -151,7 +151,7 @@ describe('TechDocsCache', () => { await expect( CacheUnderTest.invalidateMultiple(expectedPaths), - ).rejects.toThrowError(CacheInvalidationError); + ).rejects.toThrow(CacheInvalidationError); expect(MockClient.delete).toHaveBeenCalledTimes(2); }); diff --git a/plugins/techdocs-backend/src/service/CachedEntityLoader.test.ts b/plugins/techdocs-backend/src/service/CachedEntityLoader.test.ts index 19684486dc514..57e4dccbd4ba5 100644 --- a/plugins/techdocs-backend/src/service/CachedEntityLoader.test.ts +++ b/plugins/techdocs-backend/src/service/CachedEntityLoader.test.ts @@ -58,7 +58,7 @@ describe('CachedEntityLoader', () => { const result = await loader.load(entityName, token); expect(result).toEqual(entity); - expect(cache.set).toBeCalledWith( + expect(cache.set).toHaveBeenCalledWith( 'catalog:component:default/test:test-token', entity, { ttl: 5000 }, @@ -71,7 +71,7 @@ describe('CachedEntityLoader', () => { const result = await loader.load(entityName, token); expect(result).toEqual(entity); - expect(catalog.getEntityByRef).not.toBeCalled(); + expect(catalog.getEntityByRef).not.toHaveBeenCalled(); }); it('does not cache missing entites', async () => { @@ -81,7 +81,7 @@ describe('CachedEntityLoader', () => { const result = await loader.load(entityName, token); expect(result).toBeUndefined(); - expect(cache.set).not.toBeCalled(); + expect(cache.set).not.toHaveBeenCalled(); }); it('uses entity ref as cache key for anonymous users', async () => { @@ -91,9 +91,13 @@ describe('CachedEntityLoader', () => { const result = await loader.load(entityName, undefined); expect(result).toEqual(entity); - expect(cache.set).toBeCalledWith('catalog:component:default/test', entity, { - ttl: 5000, - }); + expect(cache.set).toHaveBeenCalledWith( + 'catalog:component:default/test', + entity, + { + ttl: 5000, + }, + ); }); it('calls the catalog if the cache read takes too long', async () => { diff --git a/plugins/techdocs-backend/src/service/DocsSynchronizer.test.ts b/plugins/techdocs-backend/src/service/DocsSynchronizer.test.ts index 0ab124c26d6a9..1445079d12b29 100644 --- a/plugins/techdocs-backend/src/service/DocsSynchronizer.test.ts +++ b/plugins/techdocs-backend/src/service/DocsSynchronizer.test.ts @@ -144,19 +144,21 @@ describe('DocsSynchronizer', () => { generators, }); - expect(mockResponseHandler.log).toBeCalledTimes(3); - expect(mockResponseHandler.log).toBeCalledWith('Some log'); - expect(mockResponseHandler.log).toBeCalledWith('Another log'); - expect(mockResponseHandler.log).toBeCalledWith( + expect(mockResponseHandler.log).toHaveBeenCalledTimes(3); + expect(mockResponseHandler.log).toHaveBeenCalledWith('Some log'); + expect(mockResponseHandler.log).toHaveBeenCalledWith('Another log'); + expect(mockResponseHandler.log).toHaveBeenCalledWith( expect.stringMatching(/info.*Some more log/), ); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: true }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: true, + }); - expect(mockResponseHandler.error).toBeCalledTimes(0); + expect(mockResponseHandler.error).toHaveBeenCalledTimes(0); - expect(shouldCheckForUpdate).toBeCalledTimes(1); - expect(DocsBuilder.prototype.build).toBeCalledTimes(1); + expect(shouldCheckForUpdate).toHaveBeenCalledTimes(1); + expect(DocsBuilder.prototype.build).toHaveBeenCalledTimes(1); }); it('should limit concurrent updates', async () => { @@ -210,13 +212,15 @@ describe('DocsSynchronizer', () => { generators, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: false }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: false, + }); - expect(mockResponseHandler.log).toBeCalledTimes(0); - expect(mockResponseHandler.error).toBeCalledTimes(0); + expect(mockResponseHandler.log).toHaveBeenCalledTimes(0); + expect(mockResponseHandler.error).toHaveBeenCalledTimes(0); - expect(shouldCheckForUpdate).toBeCalledTimes(1); - expect(DocsBuilder.prototype.build).toBeCalledTimes(0); + expect(shouldCheckForUpdate).toHaveBeenCalledTimes(1); + expect(DocsBuilder.prototype.build).toHaveBeenCalledTimes(0); }); it('should forward build errors', async () => { @@ -242,15 +246,15 @@ describe('DocsSynchronizer', () => { generators, }); - expect(mockResponseHandler.log).toBeCalledTimes(1); - expect(mockResponseHandler.log).toBeCalledWith( + expect(mockResponseHandler.log).toHaveBeenCalledTimes(1); + expect(mockResponseHandler.log).toHaveBeenCalledWith( expect.stringMatching( /error.*: Failed to build the docs page: Some random error/, ), ); - expect(mockResponseHandler.finish).toBeCalledTimes(0); - expect(mockResponseHandler.error).toBeCalledTimes(1); - expect(mockResponseHandler.error).toBeCalledWith(error); + expect(mockResponseHandler.finish).toHaveBeenCalledTimes(0); + expect(mockResponseHandler.error).toHaveBeenCalledTimes(1); + expect(mockResponseHandler.error).toHaveBeenCalledWith(error); }); }); @@ -275,8 +279,10 @@ describe('DocsSynchronizer', () => { entity, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: false }); - expect(shouldCheckForUpdate).toBeCalledTimes(1); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: false, + }); + expect(shouldCheckForUpdate).toHaveBeenCalledTimes(1); }); it('should do nothing if source/cached metadata matches', async () => { @@ -292,7 +298,9 @@ describe('DocsSynchronizer', () => { entity, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: false }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: false, + }); }); it('should invalidate expected files when source/cached metadata differ', async () => { @@ -309,7 +317,9 @@ describe('DocsSynchronizer', () => { entity, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: true }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: true, + }); expect(cache.invalidateMultiple).toHaveBeenCalledWith([ 'default/component/test/index.html', ]); @@ -342,7 +352,9 @@ describe('DocsSynchronizer', () => { entity, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: true }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: true, + }); expect(cache.invalidateMultiple).toHaveBeenCalledWith([ 'default/Component/test/index.html', ]); @@ -361,7 +373,9 @@ describe('DocsSynchronizer', () => { entity, }); - expect(mockResponseHandler.finish).toBeCalledWith({ updated: false }); + expect(mockResponseHandler.finish).toHaveBeenCalledWith({ + updated: false, + }); }); it("adds the build log transport to the logger's list of transports", async () => { diff --git a/plugins/techdocs-backend/src/service/router.test.ts b/plugins/techdocs-backend/src/service/router.test.ts index 9edd2e3edcd61..0c049c00f2457 100644 --- a/plugins/techdocs-backend/src/service/router.test.ts +++ b/plugins/techdocs-backend/src/service/router.test.ts @@ -231,7 +231,7 @@ data: "Invalid configuration. docsBuildStrategy.shouldBuild returned 'true', but `, ); - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledTimes(0); + expect(MockDocsSynchronizer.prototype.doSync).toHaveBeenCalledTimes(0); }); it('should execute synchronization', async () => { @@ -249,8 +249,8 @@ data: "Invalid configuration. docsBuildStrategy.shouldBuild returned 'true', but .set('accept', 'text/event-stream') .send(); - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledTimes(1); - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledWith({ + expect(MockDocsSynchronizer.prototype.doSync).toHaveBeenCalledTimes(1); + expect(MockDocsSynchronizer.prototype.doSync).toHaveBeenCalledWith({ responseHandler: { log: expect.any(Function), error: expect.any(Function), @@ -313,7 +313,7 @@ data: {"updated":true} .send(); expect(response.status).toBe(200); - expect(docsRouter).toBeCalled(); + expect(docsRouter).toHaveBeenCalled(); }); it('should return assets from cache', async () => { @@ -328,7 +328,7 @@ data: {"updated":true} .send(); expect(response.status).toBe(200); - expect(MockTechDocsCache.get).toBeCalled(); + expect(MockTechDocsCache.get).toHaveBeenCalled(); }); it('should check entity access when permissions are enabled', async () => { @@ -347,7 +347,7 @@ data: {"updated":true} .send(); expect(response.status).toBe(200); - expect(MockCachedEntityLoader.prototype.load).toBeCalled(); + expect(MockCachedEntityLoader.prototype.load).toHaveBeenCalled(); }); it('should not return assets without corresponding entity access', async () => { @@ -387,8 +387,8 @@ describe('createEventStream', () => { it('should return correct event stream', async () => { // called in beforeEach - expect(res.writeHead).toBeCalledTimes(1); - expect(res.writeHead).toBeCalledWith(200, { + expect(res.writeHead).toHaveBeenCalledTimes(1); + expect(res.writeHead).toHaveBeenCalledWith(200, { 'Cache-Control': 'no-cache', Connection: 'keep-alive', 'Content-Type': 'text/event-stream', @@ -400,45 +400,45 @@ describe('createEventStream', () => { handlers.log('A Message'); - expect(res.write).toBeCalledTimes(1); - expect(res.write).toBeCalledWith(`event: log + expect(res.write).toHaveBeenCalledTimes(1); + expect(res.write).toHaveBeenCalledWith(`event: log data: "A Message" `); - expect(res.flush).toBeCalledTimes(1); + expect(res.flush).toHaveBeenCalledTimes(1); }); it('should write log', async () => { handlers.log('A Message'); - expect(res.write).toBeCalledTimes(1); - expect(res.write).toBeCalledWith(`event: log + expect(res.write).toHaveBeenCalledTimes(1); + expect(res.write).toHaveBeenCalledWith(`event: log data: "A Message" `); - expect(res.end).toBeCalledTimes(0); + expect(res.end).toHaveBeenCalledTimes(0); }); it('should write error and end the connection', async () => { handlers.error(new Error('Some Error')); - expect(res.write).toBeCalledTimes(1); - expect(res.write).toBeCalledWith(`event: error + expect(res.write).toHaveBeenCalledTimes(1); + expect(res.write).toHaveBeenCalledWith(`event: error data: "Some Error" `); - expect(res.end).toBeCalledTimes(1); + expect(res.end).toHaveBeenCalledTimes(1); }); it('should finish and end the connection', async () => { handlers.finish({ updated: true }); - expect(res.write).toBeCalledTimes(1); - expect(res.write).toBeCalledWith(`event: finish + expect(res.write).toHaveBeenCalledTimes(1); + expect(res.write).toHaveBeenCalledWith(`event: finish data: {"updated":true} `); - expect(res.end).toBeCalledTimes(1); + expect(res.end).toHaveBeenCalledTimes(1); }); }); diff --git a/plugins/techdocs-node/src/stages/generate/generators.test.ts b/plugins/techdocs-node/src/stages/generate/generators.test.ts index 56343763e90e5..a1c585e7953f4 100644 --- a/plugins/techdocs-node/src/stages/generate/generators.test.ts +++ b/plugins/techdocs-node/src/stages/generate/generators.test.ts @@ -37,7 +37,7 @@ describe('generators', () => { it('should return error if no generator is registered', async () => { const generators = new Generators(); - expect(() => generators.get(mockEntity)).toThrowError( + expect(() => generators.get(mockEntity)).toThrow( 'No generator registered for entity: "techdocs"', ); }); diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 3deb17173a17c..b98a219eacc58 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -462,7 +462,7 @@ describe('helpers', () => { // Check if the file exists await expect( fs.access(filePath, fs.constants.F_OK), - ).resolves.not.toThrowError(); + ).resolves.not.toThrow(); }); it('should throw error when the JSON is invalid', async () => { @@ -470,7 +470,7 @@ describe('helpers', () => { await expect( createOrUpdateMetadata(filePath, mockLogger), - ).rejects.toThrowError('Unexpected token d in JSON at position 0'); + ).rejects.toThrow('Unexpected token d in JSON at position 0'); }); it('should add build timestamp to the metadata json', async () => { @@ -511,9 +511,9 @@ describe('helpers', () => { it('should throw error when the JSON is invalid', async () => { const filePath = path.join(rootDir, 'invalid_techdocs_metadata.json'); - await expect( - storeEtagMetadata(filePath, 'etag123abc'), - ).rejects.toThrowError('Unexpected token d in JSON at position 0'); + await expect(storeEtagMetadata(filePath, 'etag123abc')).rejects.toThrow( + 'Unexpected token d in JSON at position 0', + ); }); it('should add etag to the metadata json', async () => { @@ -552,7 +552,7 @@ describe('helpers', () => { it('throws when neither .yml nor .yaml file is present', async () => { const invalidInputDir = resolvePath(__filename); - await expect(getMkdocsYml(invalidInputDir)).rejects.toThrowError( + await expect(getMkdocsYml(invalidInputDir)).rejects.toThrow( /Could not read MkDocs YAML config file mkdocs.yml or mkdocs.yaml for validation/, ); }); diff --git a/plugins/techdocs-node/src/stages/publish/helpers.test.ts b/plugins/techdocs-node/src/stages/publish/helpers.test.ts index ceb1b02a20d80..fa934d6dd9f11 100644 --- a/plugins/techdocs-node/src/stages/publish/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/publish/helpers.test.ts @@ -102,9 +102,9 @@ describe('lowerCaseEntityTripletInStoragePath', () => { it('throws error when there is no triplet', () => { const originalPath = '/default/component/IMAGE.png'; const error = `Encountered file unmanaged by TechDocs ${originalPath}. Skipping.`; - expect(() => - lowerCaseEntityTripletInStoragePath(originalPath), - ).toThrowError(error); + expect(() => lowerCaseEntityTripletInStoragePath(originalPath)).toThrow( + error, + ); }); }); diff --git a/plugins/techdocs-node/src/stages/publish/local.test.ts b/plugins/techdocs-node/src/stages/publish/local.test.ts index ce2e0c3ccd295..f2f2b1e526613 100644 --- a/plugins/techdocs-node/src/stages/publish/local.test.ts +++ b/plugins/techdocs-node/src/stages/publish/local.test.ts @@ -131,7 +131,7 @@ describe('local publisher', () => { await expect(() => publisher.publish({ entity: mockEntity, directory: tmpDir }), - ).rejects.toThrowError('Unable to publish TechDocs site'); + ).rejects.toThrow('Unable to publish TechDocs site'); }); it('should throw with unsafe name', async () => { @@ -154,7 +154,7 @@ describe('local publisher', () => { await expect(() => publisher.publish({ entity: mockEntity, directory: tmpDir }), - ).rejects.toThrowError('Unable to publish TechDocs site'); + ).rejects.toThrow('Unable to publish TechDocs site'); }); }); diff --git a/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts b/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts index 51b67d6167da9..b1830652301ef 100644 --- a/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts +++ b/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts @@ -284,7 +284,7 @@ describe('OpenStackSwiftPublish', () => { entity, directory: wrongPathToGeneratedDirectory, }), - ).rejects.toThrowError(); + ).rejects.toThrow(); const fails = publisher.publish({ entity, diff --git a/plugins/techdocs/src/client.test.ts b/plugins/techdocs/src/client.test.ts index 8236b93c556cb..dde52cda49d8f 100644 --- a/plugins/techdocs/src/client.test.ts +++ b/plugins/techdocs/src/client.test.ts @@ -103,7 +103,7 @@ describe('TechDocsStorageClient', () => { identityApi.getCredentials.mockResolvedValue({}); await storageApi.syncEntityDocs(mockEntity); - expect(MockedEventSource).toBeCalledWith( + expect(MockedEventSource).toHaveBeenCalledWith( 'http://backstage:9191/api/techdocs/sync/default/Component/test-component', { withCredentials: true, headers: {} }, ); @@ -128,7 +128,7 @@ describe('TechDocsStorageClient', () => { identityApi.getCredentials.mockResolvedValue({ token: 'token' }); await storageApi.syncEntityDocs(mockEntity); - expect(MockedEventSource).toBeCalledWith( + expect(MockedEventSource).toHaveBeenCalledWith( 'http://backstage:9191/api/techdocs/sync/default/Component/test-component', { withCredentials: true, headers: { Authorization: 'Bearer token' } }, ); @@ -204,8 +204,8 @@ describe('TechDocsStorageClient', () => { storageApi.syncEntityDocs(mockEntity, logHandler), ).resolves.toEqual('cached'); - expect(logHandler).toBeCalledTimes(1); - expect(logHandler).toBeCalledWith('A log message'); + expect(logHandler).toHaveBeenCalledTimes(1); + expect(logHandler).toHaveBeenCalledWith('A log message'); }); it('should throw NotFoundError', async () => { @@ -232,7 +232,7 @@ describe('TechDocsStorageClient', () => { } as any); await expect(promise).rejects.toThrow(NotFoundError); - await expect(promise).rejects.toThrowError('Some not found warning'); + await expect(promise).rejects.toThrow('Some not found warning'); }); it('should throw generic errors', async () => { @@ -259,7 +259,7 @@ describe('TechDocsStorageClient', () => { } as any); await expect(promise).rejects.toThrow(Error); - await expect(promise).rejects.toThrowError('Some other error'); + await expect(promise).rejects.toThrow('Some other error'); }); }); }); diff --git a/plugins/techdocs/src/reader/components/TechDocsBuildLogs.test.tsx b/plugins/techdocs/src/reader/components/TechDocsBuildLogs.test.tsx index ea24a3627f0ac..afdac63a996aa 100644 --- a/plugins/techdocs/src/reader/components/TechDocsBuildLogs.test.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsBuildLogs.test.tsx @@ -54,7 +54,7 @@ describe('', () => { await rendered.findByText(/Waiting for logs.../i), ).toBeInTheDocument(); - expect(onClose).toBeCalledTimes(0); + expect(onClose).toHaveBeenCalledTimes(0); }); it('should render logs', async () => { @@ -69,7 +69,7 @@ describe('', () => { expect(await rendered.findByText(/Line 1/i)).toBeInTheDocument(); expect(await rendered.findByText(/Line 2/i)).toBeInTheDocument(); - expect(onClose).toBeCalledTimes(0); + expect(onClose).toHaveBeenCalledTimes(0); }); it('should call onClose', async () => { @@ -79,6 +79,6 @@ describe('', () => { ); rendered.getByTitle('Close the drawer').click(); - expect(onClose).toBeCalledTimes(1); + expect(onClose).toHaveBeenCalledTimes(1); }); }); diff --git a/plugins/techdocs/src/reader/components/useReaderState.test.tsx b/plugins/techdocs/src/reader/components/useReaderState.test.tsx index e41a114dbefcb..08bfa8f9add42 100644 --- a/plugins/techdocs/src/reader/components/useReaderState.test.tsx +++ b/plugins/techdocs/src/reader/components/useReaderState.test.tsx @@ -312,11 +312,11 @@ describe('useReaderState', () => { contentReload: expect.any(Function), }); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/example', ); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', @@ -397,13 +397,13 @@ describe('useReaderState', () => { contentReload: expect.any(Function), }); - expect(techdocsStorageApi.getEntityDocs).toBeCalledTimes(2); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledTimes(2); + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/example', ); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledTimes(1); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledTimes(1); + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', @@ -511,12 +511,12 @@ describe('useReaderState', () => { contentReload: expect.any(Function), }); - expect(techdocsStorageApi.getEntityDocs).toBeCalledTimes(2); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledTimes(2); + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/example', ); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', @@ -607,15 +607,15 @@ describe('useReaderState', () => { contentReload: expect.any(Function), }); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/example', ); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/new', ); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', @@ -660,11 +660,11 @@ describe('useReaderState', () => { contentReload: expect.any(Function), }); - expect(techdocsStorageApi.getEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.getEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', name: 'backstage' }, '/example', ); - expect(techdocsStorageApi.syncEntityDocs).toBeCalledWith( + expect(techdocsStorageApi.syncEntityDocs).toHaveBeenCalledWith( { kind: 'Component', namespace: 'default', diff --git a/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx b/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx index 5957aecc4d414..28d2346c61035 100644 --- a/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx @@ -66,7 +66,7 @@ describe('', () => { ); await emptyResults; - expect(querySpy).toBeCalled(); + expect(querySpy).toHaveBeenCalled(); expect(rendered.getByTestId('techdocs-search-bar')).toBeInTheDocument(); }); }); @@ -88,7 +88,7 @@ describe('', () => { ); await singleResult; - expect(querySpy).toBeCalledWith({ + expect(querySpy).toHaveBeenCalledWith({ filters: { kind: 'Testable', name: 'test', @@ -107,7 +107,7 @@ describe('', () => { await singleResult; await waitFor(() => - expect(querySpy).toBeCalledWith({ + expect(querySpy).toHaveBeenCalledWith({ filters: { kind: 'Testable', name: 'test', @@ -148,7 +148,7 @@ describe('', () => { const rendered = render(); await singleResult; - expect(querySpy).toBeCalledWith({ + expect(querySpy).toHaveBeenCalledWith({ filters: { kind: 'Testable', name: 'test', @@ -164,7 +164,7 @@ describe('', () => { await singleResult; await waitFor(() => - expect(querySpy).toBeCalledWith({ + expect(querySpy).toHaveBeenCalledWith({ filters: { kind: 'TestableDiff', name: 'test-diff', diff --git a/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx index fd9fee0f151b7..5062da4749f18 100644 --- a/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx +++ b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx @@ -103,13 +103,13 @@ describe('BuildListFilter', () => { const rendered = await renderWithFiltersVisible(callback); await setStatusFilter(rendered, 'Succeeded'); - expect(callback).toBeCalledWith({ + expect(callback).toHaveBeenCalledWith({ ...initialValues, buildStatus: 'succeeded', }); await setStatusFilter(rendered, 'All'); - expect(callback).toBeCalledWith(initialValues); + expect(callback).toHaveBeenCalledWith(initialValues); }); it('should call back with a project when project is selected', async () => { @@ -117,13 +117,13 @@ describe('BuildListFilter', () => { const rendered = await renderWithFiltersVisible(callback); await setProjectFilter(rendered, client.mockBuild.projectName); - expect(callback).toBeCalledWith({ + expect(callback).toHaveBeenCalledWith({ ...initialValues, project: client.mockBuild.projectName, }); await setProjectFilter(rendered, 'All'); - expect(callback).toBeCalledWith(initialValues); + expect(callback).toHaveBeenCalledWith(initialValues); }); it('should display a count of active (changed) filters', async () => { diff --git a/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx b/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx index c9acf5ac51781..7c5dc618f6a36 100644 --- a/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx +++ b/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx @@ -34,7 +34,7 @@ describe('DatePicker', () => { const input = rendered.getByLabelText(label); await userEvent.type(input, '2020-02-02'); - expect(callback).toBeCalledWith('2020-02-02'); + expect(callback).toHaveBeenCalledWith('2020-02-02'); }); it('should not accept non date', async () => {