diff --git a/package.json b/package.json index 50cee787a..89ba7e31d 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "fake-indexeddb": "^4.0.0", "jest": "^29.0.0", "jest-localstorage-mock": "^2.4.6", - "jest-mock": "^27.5.1", + "jest-mock": "^29.0.0", "jest-sonar-reporter": "^2.0.0", "jsdoc": "^3.6.6", "matrix-mock-request": "^2.5.0", diff --git a/spec/test-utils/client.ts b/spec/test-utils/client.ts index 3cacd179d..79af87022 100644 --- a/spec/test-utils/client.ts +++ b/spec/test-utils/client.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MethodKeysOf, mocked, MockedObject } from "jest-mock"; +import { MethodLikeKeys, mocked, MockedObject } from "jest-mock"; import { ClientEventHandlerMap, EmittedEvents, MatrixClient } from "../../src/client"; import { TypedEventEmitter } from "../../src/models/typed-event-emitter"; @@ -26,7 +26,7 @@ import { User } from "../../src/models/user"; * to MatrixClient events */ export class MockClientWithEventEmitter extends TypedEventEmitter { - constructor(mockProperties: Partial, unknown>> = {}) { + constructor(mockProperties: Partial, unknown>> = {}) { super(); Object.assign(this, mockProperties); } @@ -44,7 +44,7 @@ export class MockClientWithEventEmitter extends TypedEventEmitter, unknown>>, + mockProperties: Partial, unknown>>, ): MockedObject => { const mock = mocked(new MockClientWithEventEmitter(mockProperties) as unknown as MatrixClient); return mock; @@ -84,7 +84,7 @@ export const mockClientMethodsEvents = () => ({ /** * Returns basic mocked client methods related to server support */ -export const mockClientMethodsServer = (): Partial, unknown>> => ({ +export const mockClientMethodsServer = (): Partial, unknown>> => ({ doesServerSupportSeparateAddAndBind: jest.fn(), getIdentityServerUrl: jest.fn(), getHomeserverUrl: jest.fn(), diff --git a/spec/unit/http-api/index.spec.ts b/spec/unit/http-api/index.spec.ts index 89e122452..55a4d49df 100644 --- a/spec/unit/http-api/index.spec.ts +++ b/spec/unit/http-api/index.spec.ts @@ -28,7 +28,7 @@ describe("MatrixHttpApi", () => { const baseUrl = "http://baseUrl"; const prefix = ClientPrefix.V3; - let xhr: Partial>; + let xhr: Writeable; let upload: Promise; const DONE = 0; @@ -44,7 +44,7 @@ describe("MatrixHttpApi", () => { setRequestHeader: jest.fn(), onreadystatechange: undefined, getResponseHeader: jest.fn(), - }; + } as unknown as XMLHttpRequest; // We stub out XHR here as it is not available in JSDOM // @ts-ignore global.XMLHttpRequest = jest.fn().mockReturnValue(xhr); @@ -62,7 +62,7 @@ describe("MatrixHttpApi", () => { }); it("should fall back to `fetch` where xhr is unavailable", () => { - global.XMLHttpRequest = undefined; + global.XMLHttpRequest = undefined!; const fetchFn = jest.fn().mockResolvedValue({ ok: true, json: jest.fn().mockResolvedValue({}) }); const api = new MatrixHttpApi(new TypedEventEmitter(), { baseUrl, prefix, fetchFn }); upload = api.uploadContent({} as File); diff --git a/yarn.lock b/yarn.lock index 57fda872a..67200d97f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1278,17 +1278,6 @@ slash "^3.0.0" write-file-atomic "^4.0.1" -"@jest/types@^27.5.1": - version "27.5.1" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.5.1.tgz#3c79ec4a8ba61c170bf937bcf9e98a9df175ec80" - integrity sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw== - dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^3.0.0" - "@types/node" "*" - "@types/yargs" "^16.0.0" - chalk "^4.0.0" - "@jest/types@^28.1.3": version "28.1.3" resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.1.3.tgz#b05de80996ff12512bc5ceb1d208285a7d11748b" @@ -1705,13 +1694,6 @@ resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== -"@types/yargs@^16.0.0": - version "16.0.4" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.4.tgz#26aad98dd2c2a38e421086ea9ad42b9e51642977" - integrity sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw== - dependencies: - "@types/yargs-parser" "*" - "@types/yargs@^17.0.8": version "17.0.13" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.13.tgz#34cced675ca1b1d51fcf4d34c3c6f0fa142a5c76" @@ -4348,15 +4330,7 @@ jest-message-util@^29.2.1: slash "^3.0.0" stack-utils "^2.0.3" -jest-mock@^27.5.1: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-27.5.1.tgz#19948336d49ef4d9c52021d34ac7b5f36ff967d6" - integrity sha512-K4jKbY1d4ENhbrG2zuPWaQBvDly+iZ2yAW+T1fATN78hc0sInwn7wZB8XtlNnvHug5RMwV897Xm4LqmPM4e2Og== - dependencies: - "@jest/types" "^27.5.1" - "@types/node" "*" - -jest-mock@^29.2.1: +jest-mock@^29.0.0, jest-mock@^29.2.1: version "29.2.1" resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.2.1.tgz#a0d361cffcb28184fa9c5443adbf591fa5759775" integrity sha512-NDphaY/GqyQpTfnTZiTqqpMaw4Z0I7XnB7yBgrT6IwYrLGxpOhrejYr4ANY4YvO2sEGdd8Tx/6D0+WLQy7/qDA==