web-sdk icon indicating copy to clipboard operation
web-sdk copied to clipboard

Error on jest

Open aminlatifi opened this issue 5 years ago • 1 comments

We add Portis support to our Dapp. The below code is how we have imported that:

import Portis from '@portis/web3';

import config from '../configuration';

const PORTIS_DAPP_ID = 'xxxxxxxxxxxxxxx';
const NETWORK_CONFIG = { nodeUrl: config.foreignNodeConnection, nodeId: config.foreignNetworkId };

const portis = new Portis(PORTIS_DAPP_ID, NETWORK_CONFIG);

After adding this, out jest tests fail. The errors are the same on all tests:

 FAIL  src/models/User.test.js
  ● Test suite failed to run

    TypeError: web3_provider_engine_1.default is not a constructor

      at Portis.Object.<anonymous>.Portis._initProvider (node_modules/@portis/web3/lib/index.js:266:22)
      at new Portis (node_modules/@portis/web3/lib/index.js:81:30)
      ....

aminlatifi avatar Nov 26 '19 15:11 aminlatifi

I hope this link helps to fix it: https://stackoverflow.com/questions/52597778/testing-es6-class-with-jest-throws-not-a-constructor-error

aminlatifi avatar Nov 26 '19 15:11 aminlatifi