Estoy usando un SDK personalizado en mi proyecto React Native y lo estoy importando como:
import * as WalletLib from 'wallet-lib';y luego usando sus subclases y funciones como se muestra a continuación:
const client = new WalletLib.WalletClient( 'http://dev-s-wallet.bgdom.com/', 'https://dev-a-wallet.bgdom.com/', );Esto funciona bien para la aplicación, pero cuando escribo la prueba usando broma, me da errores.
Test suite failed to run TypeError: BoaWallet.WalletClient is not a constructor 8 | import * as WalletLib from 'wallet-lib'; 9 | > 10 | const boa_client = new WalletLib.WalletClient( | ^ 11 | 'http://dev-s-wallet.bgdom.com/', 12 | 'http://dev-a-wallet.bgdom.com/', 13 | ); at Object.<anonymous> (src/utils/bWalletLibCall.js:10:20) at Object.<anonymous> (src/screens/authenticated/overviewTabs/PendingTab.js:27:1)Me estoy burlando de la siguiente manera:
jest.mock('wallet-lib', () => { return { WalletLib: jest.fn().mockImplementation(() => ({ WalletClient: jest.fn().mockImplementation(() => { return {}; }), })), }; });Pero me sigue dando el mismo error. Cómo puedo resolver esto.
¡Gracias!