I'm using a custome SDK in my React Native project and importing it as:
import * as WalletLib from 'wallet-lib';
and then using its sub classes and function like below:
const client = new WalletLib.WalletClient(
'http://dev-s-wallet.bgdom.com/',
'https://dev-a-wallet.bgdom.com/',
);
This is working fine for application but when I write test using jest it gives me errors.
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)
I'm mocking it as below:
jest.mock('wallet-lib', () => {
return {
WalletLib: jest.fn().mockImplementation(() => ({
WalletClient: jest.fn().mockImplementation(() => {
return {};
}),
})),
};
});
But it still giving me same error. How can I resolve this.
Thank you!