From 1e58f02a2d39a7657d8f8f13df6692cfc76aa2c0 Mon Sep 17 00:00:00 2001 From: Alan Lu Date: Mon, 28 Sep 2020 18:35:16 -0500 Subject: [PATCH 1/2] Use CJS modules to quell Jest --- app/src/hooks/useCpk.tsx | 2 +- app/src/services/cpk.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/hooks/useCpk.tsx b/app/src/hooks/useCpk.tsx index 7c5f6ddcb1..2f8e818ce1 100644 --- a/app/src/hooks/useCpk.tsx +++ b/app/src/hooks/useCpk.tsx @@ -1,5 +1,5 @@ import CPK from 'contract-proxy-kit' -import EthersAdapter from 'contract-proxy-kit/lib/esm/ethLibAdapters/EthersAdapter' +import EthersAdapter from 'contract-proxy-kit/lib/cjs/ethLibAdapters/EthersAdapter' import { ethers } from 'ethers' import { useEffect, useState } from 'react' import { useWeb3Context } from 'web3-react' diff --git a/app/src/services/cpk.ts b/app/src/services/cpk.ts index 0ad2599127..ce9d0dc8c7 100644 --- a/app/src/services/cpk.ts +++ b/app/src/services/cpk.ts @@ -1,5 +1,5 @@ import CPK from 'contract-proxy-kit' -import EthersAdapter from 'contract-proxy-kit/lib/esm/ethLibAdapters/EthersAdapter' +import EthersAdapter from 'contract-proxy-kit/lib/cjs/ethLibAdapters/EthersAdapter' import { ethers } from 'ethers' import { TransactionReceipt, Web3Provider } from 'ethers/providers' import { BigNumber } from 'ethers/utils' From e8bd3bc6c036a6d2360dd179dcdd674e7c721ef9 Mon Sep 17 00:00:00 2001 From: Alan Lu Date: Tue, 29 Sep 2020 12:22:09 -0500 Subject: [PATCH 2/2] Have Jest correctly transpile ESM imports --- app/package.json | 6 ++++++ app/src/hooks/useCpk.tsx | 4 ++-- app/src/services/cpk.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/package.json b/app/package.json index 872c5dcc90..557c609d0f 100644 --- a/app/package.json +++ b/app/package.json @@ -111,6 +111,12 @@ "pre-push": "yarn lint:check" } }, + "jest": { + "transformIgnorePatterns": [ + "[/\\\\]node_modules[/\\\\](?!(contract-proxy-kit))[/\\\\].*\\.(js|jsx|mjs|cjs|ts|tsx)$", + "^.+\\.module\\.(css|sass|scss)$" + ] + }, "browserslist": { "production": [ ">0.2%", diff --git a/app/src/hooks/useCpk.tsx b/app/src/hooks/useCpk.tsx index 2f8e818ce1..f0bcd85ad8 100644 --- a/app/src/hooks/useCpk.tsx +++ b/app/src/hooks/useCpk.tsx @@ -1,5 +1,5 @@ -import CPK from 'contract-proxy-kit' -import EthersAdapter from 'contract-proxy-kit/lib/cjs/ethLibAdapters/EthersAdapter' +import CPK from 'contract-proxy-kit/lib/esm' +import EthersAdapter from 'contract-proxy-kit/lib/esm/ethLibAdapters/EthersAdapter' import { ethers } from 'ethers' import { useEffect, useState } from 'react' import { useWeb3Context } from 'web3-react' diff --git a/app/src/services/cpk.ts b/app/src/services/cpk.ts index ce9d0dc8c7..4661620fe3 100644 --- a/app/src/services/cpk.ts +++ b/app/src/services/cpk.ts @@ -1,5 +1,5 @@ -import CPK from 'contract-proxy-kit' -import EthersAdapter from 'contract-proxy-kit/lib/cjs/ethLibAdapters/EthersAdapter' +import CPK from 'contract-proxy-kit/lib/esm' +import EthersAdapter from 'contract-proxy-kit/lib/esm/ethLibAdapters/EthersAdapter' import { ethers } from 'ethers' import { TransactionReceipt, Web3Provider } from 'ethers/providers' import { BigNumber } from 'ethers/utils'