Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CJS modules to quell Jest #1130

Merged
merged 2 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%",
Expand Down
2 changes: 1 addition & 1 deletion app/src/hooks/useCpk.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CPK from 'contract-proxy-kit'
import CPK from 'contract-proxy-kit/lib/esm'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this to explicitly use the ESM path because Webpack and Jest resolves 'contract-proxy-kit' differently.

import EthersAdapter from 'contract-proxy-kit/lib/esm/ethLibAdapters/EthersAdapter'
import { ethers } from 'ethers'
import { useEffect, useState } from 'react'
Expand Down
2 changes: 1 addition & 1 deletion app/src/services/cpk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CPK from 'contract-proxy-kit'
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'
Expand Down