diff --git a/apps/ledger-live-desktop/package.json b/apps/ledger-live-desktop/package.json index bd83463c92e9..9ba5b16bc8b6 100644 --- a/apps/ledger-live-desktop/package.json +++ b/apps/ledger-live-desktop/package.json @@ -217,6 +217,7 @@ "jest-environment-jsdom": "^29.7.0", "listr": "^0.14.3", "listr-verbose-renderer": "^0.6.0", + "nock": "^13.0.5", "prebuild-install": "^7.1.1", "react-refresh": "^0.14.0", "react-test-renderer": "^18.2.0", diff --git a/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.react.test.tsx b/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.react.test.tsx index 6aebf84ddccf..b056e328740f 100644 --- a/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.react.test.tsx +++ b/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.react.test.tsx @@ -1,8 +1,9 @@ +import nock from "nock"; import React from "react"; import axios from "axios"; +import { TFunction } from "i18next"; import BigNumber from "bignumber.js"; import { render, screen, waitFor } from "tests/testUtils"; - import { getCryptoCurrencyById, setSupportedCurrencies, @@ -13,16 +14,13 @@ import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; import { DomainServiceProvider } from "@ledgerhq/domain-service/hooks/index"; import { Transaction, TransactionStatus } from "@ledgerhq/live-common/generated/types"; import RecipientField from "./RecipientField"; -import { TFunction } from "i18next"; // Temp mock to prevent error on sentry init jest.mock("../../../../sentry/install", () => ({ init: () => null, })); -jest.mock("axios"); - -const mockedAxios = jest.mocked(axios); +nock.disableNetConnect(); jest.mock("@ledgerhq/live-common/featureFlags/index", () => ({ useFeature: jest.fn(), @@ -335,6 +333,7 @@ describe("RecipientField", () => { }); it("should not change domain because currency not supported", async () => { + const spy = jest.spyOn(axios, "request"); const { user } = setup(null, null, polygonMockAccount); const input = screen.getByRole("textbox"); await user.type(input, "0x16bb635bc5c398b63a0fbb38dac84da709eb3e86"); @@ -345,7 +344,7 @@ describe("RecipientField", () => { recipientDomain: undefined, }), ); - expect(mockedAxios).not.toHaveBeenCalled(); + expect(spy).not.toHaveBeenCalled(); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bd40ec22e00b..692cdb4ebe22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -748,6 +748,9 @@ importers: listr-verbose-renderer: specifier: ^0.6.0 version: 0.6.0 + nock: + specifier: ^13.0.5 + version: 13.5.4 prebuild-install: specifier: ^7.1.1 version: 7.1.2