-
Notifications
You must be signed in to change notification settings - Fork 7
Description
As per multiformats/js-multibase#66 (quoting below):
Describe the bug
When running the test in jest (with either env=jsdom or env=node setting) theTextDecoderorTextEncoderis not a constructor error makes it impossible to write unit tests using this moduleTo Reproduce
This simple test and code fails to run in jest
code:
https://github.com/Uniswap/uniswap-interface/blob/0aabf4856e6e90041caf4233db4b7defb01574a2/src/utils/contenthashToUri.ts
test:
https://github.com/Uniswap/uniswap-interface/blob/0aabf4856e6e90041caf4233db4b7defb01574a2/src/utils/contenthashToUri.test.skip.tserror:
TypeError: TextDecoder is not a constructorTypeError: TextDecoder is not a constructor > 1 | import CID from 'cids' | ^ 2 | import { getCodec, rmPrefix } from 'multicodec' 3 | import { decode, toB58String } from 'multihashes' 4 | at Object.<anonymous> (node_modules/multibase/src/util.js:6:21) at Object.<anonymous> (node_modules/multibase/src/base.js:4:24) at Object.<anonymous> (node_modules/multibase/src/constants.js:5:14) at Object.<anonymous> (node_modules/multibase/src/index.js:9:19) at Object.<anonymous> (node_modules/multihashes/src/index.js:10:19) at Object.<anonymous> (node_modules/cids/src/index.js:3:12) at Object.<anonymous> (src/utils/contenthashToUri.ts:1:1) at Object.<anonymous> (src/utils/contenthashToUri.test.ts:1:1)Expected behavior
TextDecoderfrom the environment (specifically, global for node and window for jsdom jest setting) is successfully loadedDesktop (please complete the following information):
- OS: MacOS
