Closed supertong closed 3 months ago
@supertong i added below in the jest config to get away with the node
annotation in each ts file
projects: [
{
displayName: "node",
testEnvironment: "node",
testMatch: ["<rootDir>/tests/**/*.test.ts"],
},
{
displayName: "jsdom",
testEnvironment: "jsdom",
testMatch: ["<rootDir>/tests/**/*.test.tsx"],
},
],
@gbarkhatov and @jeremy-babylonchain i will let u guys review this as i heavily involved in making of this PR. there is no point for me to approve commits from myself
The main problem of those
import
complains are caused by thetestEnvironment
setup in Jest config.When we set
testEnvironment: jsdom
, the jest default resolver would assume it's in browser environment which means it will consume thebrowser
condition from theexports
. For example, the@bitcoin-js/tiny-secp256k1-asmjs
has the followingexports
fieldThe Jest resolver will pick up
"browser": "./lib/index.js",
however what we want is thecjs
version for the test.We had tried a few fix and it didn't quite work and these fixes includes
transformIgnorePatterns
. For some reason the compiled code complains about invalid library error.A custom jest resolver.
This ends with with the same error as the above.
testEnvironment
for that specify test file with commentI have also updated jest configs to use the one from
next/jest
to simplify things a bit.Also, the CI build requires the PR https://github.com/babylonchain/btc-staking-ts/pull/27 to be released into NPM and bump the package.