diff --git a/jest.config.js b/jest.config.js index dc79edbb913..7f0c776869e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,13 +3,8 @@ module.exports = { coveragePathIgnorePatterns: [ '/node_modules/', 'dist', - 'lib', - 'lib-esm', '__tests__', ], - moduleNameMapper: { - uuid: require.resolve('uuid'), - }, setupFiles: ['../../jest.setup.js'], testEnvironment: 'jsdom', testRegex: '/__tests__/.*\\.(test|spec)\\.[jt]sx?$', diff --git a/packages/analytics/jest.config.js b/packages/analytics/jest.config.js index 7ebdbd41abf..96f85fb0774 100644 --- a/packages/analytics/jest.config.js +++ b/packages/analytics/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 68, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts b/packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts index eb24d28f668..70156efb52e 100644 --- a/packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts +++ b/packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts @@ -571,7 +571,6 @@ describe('AWSAppSyncRealTimeProvider', () => { expect(e.errors[0].message).toEqual( 'Connection failed: Non-retriable Test' ); - // done(); }, }); diff --git a/packages/api-graphql/__tests__/helpers.ts b/packages/api-graphql/__tests__/helpers.ts index 84602c5abe0..08a8261546d 100644 --- a/packages/api-graphql/__tests__/helpers.ts +++ b/packages/api-graphql/__tests__/helpers.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { Hub } from '@aws-amplify/core'; import { Observable, Observer } from 'rxjs'; import { CONNECTION_STATE_CHANGE } from '../src/Providers/constants'; @@ -16,13 +15,11 @@ export function delay(timeout) { export class HubConnectionListener { teardownHubListener: () => void; observedConnectionStates: CS[] = []; - currentConnectionState: CS; + currentConnectionState!: CS; private connectionStateObservers: Observer[] = []; constructor(channel: string) { - let closeResolver: (value: PromiseLike) => void; - this.teardownHubListener = Hub.listen(channel, (data: any) => { const { payload } = data; if (payload.event === CONNECTION_STATE_CHANGE) { @@ -88,12 +85,12 @@ export class HubConnectionListener { } export class FakeWebSocketInterface { - webSocket: FakeWebSocket; - readyForUse: Promise; - hasClosed: Promise; + webSocket!: FakeWebSocket; + readyForUse!: Promise; + hasClosed!: Promise; hubConnectionListener: HubConnectionListener; - private readyResolve: (value: PromiseLike) => void; + private readyResolve!: (value: PromiseLike) => void; constructor() { this.hubConnectionListener = new HubConnectionListener('api'); @@ -300,16 +297,16 @@ class FakeWebSocket implements WebSocket { subscriptionId: string | undefined; closeResolverFcn: () => (value: PromiseLike) => void; - binaryType: BinaryType; - bufferedAmount: number; - extensions: string; - onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: Event) => any; - onmessage: (this: WebSocket, ev: MessageEvent) => any; - onopen: (this: WebSocket, ev: Event) => any; - protocol: string; - readyState: number; - url: string; + binaryType!: BinaryType; + bufferedAmount!: number; + extensions!: string; + onclose!: (this: WebSocket, ev: CloseEvent) => any; + onerror!: (this: WebSocket, ev: Event) => any; + onmessage!: (this: WebSocket, ev: MessageEvent) => any; + onopen!: (this: WebSocket, ev: Event) => any; + protocol!: string; + readyState!: number; + url!: string; close(code?: number, reason?: string): void { const closeResolver = this.closeResolverFcn(); if (closeResolver) closeResolver(Promise.resolve(undefined)); @@ -355,10 +352,10 @@ class FakeWebSocket implements WebSocket { constructor(closeResolver: () => (value: PromiseLike) => void) { this.closeResolverFcn = closeResolver; } - CONNECTING: 0; - OPEN: 1; - CLOSING: 2; - CLOSED: 3; + CONNECTING: 0 = 0; + OPEN: 1 = 1; + CLOSING: 2 = 2; + CLOSED: 3 = 3; } export async function replaceConstant( diff --git a/packages/api-rest/src/utils/createCancellableOperation.ts b/packages/api-rest/src/utils/createCancellableOperation.ts index 2d80db50249..26535a7e71d 100644 --- a/packages/api-rest/src/utils/createCancellableOperation.ts +++ b/packages/api-rest/src/utils/createCancellableOperation.ts @@ -59,7 +59,7 @@ export function createCancellableOperation( return response; } catch (error: any) { const abortSignal = internalPostAbortSignal ?? publicApisAbortSignal; - const message = abortSignal.reason ?? abortReason; + const message = abortReason ?? abortSignal.reason; if (error.name === 'AbortError' || abortSignal?.aborted === true) { const canceledError = new CanceledError({ ...(message && { message }), diff --git a/packages/aws-amplify/jest.config.js b/packages/aws-amplify/jest.config.js index 9ed76c708a7..9f65be3c87a 100644 --- a/packages/aws-amplify/jest.config.js +++ b/packages/aws-amplify/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 91, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/packages/core/jest.config.js b/packages/core/jest.config.js index 21663b6f997..858a5ddd5e8 100644 --- a/packages/core/jest.config.js +++ b/packages/core/jest.config.js @@ -3,7 +3,7 @@ module.exports = { coverageThreshold: { global: { branches: 75, - functions: 78, + functions: 72, lines: 88, statements: 88, }, diff --git a/packages/geo/jest.config.js b/packages/geo/jest.config.js index ef14be94658..793f297724a 100644 --- a/packages/geo/jest.config.js +++ b/packages/geo/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 89, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/packages/interactions/jest.config.js b/packages/interactions/jest.config.js index b77e202a5b4..73540b7bc7e 100644 --- a/packages/interactions/jest.config.js +++ b/packages/interactions/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 96, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/packages/predictions/jest.config.js b/packages/predictions/jest.config.js index edf7c040ff0..8235622a9d1 100644 --- a/packages/predictions/jest.config.js +++ b/packages/predictions/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 89, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/packages/pubsub/jest.config.js b/packages/pubsub/jest.config.js index 9b1aa1e54fa..b37fd6a8d1c 100644 --- a/packages/pubsub/jest.config.js +++ b/packages/pubsub/jest.config.js @@ -8,4 +8,7 @@ module.exports = { statements: 28, }, }, + moduleNameMapper: { + uuid: require.resolve('uuid'), + }, }; diff --git a/yarn.lock b/yarn.lock index 71058efd69c..bc07301cf3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11818,11 +11818,6 @@ pouchdb-collections@^1.0.1: resolved "https://registry.yarnpkg.com/pouchdb-collections/-/pouchdb-collections-1.0.1.tgz#fe63a17da977611abef7cb8026cb1a9553fd8359" integrity sha512-31db6JRg4+4D5Yzc2nqsRqsA2oOkZS8DpFav3jf/qVNBxusKa2ClkEIZ2bJNpaDbMfWtnuSq59p6Bn+CipPMdg== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== - prettier@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.0.tgz#c6d16474a5f764ea1a4a373c593b779697744d5e"