Page MenuHomePhabricator

[cashtab] fix useWallet test
ClosedPublic

Authored by alcipir on Mar 25 2022, 14:58.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC840faaffb19c: [cashtab] fix useWallet test
Summary

Depends on D11258.
This adds useWallet test back, with a custom environment to handle issues with jest27 and Uint8Array.

Test Plan

npm install
npm test

ALL tests should pass.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Mar 25 2022, 14:58
alcipir requested review of this revision.Mar 25 2022, 14:58

Removing comments from custom envinronment for jest

add react-hooks testing library back

  • Please rebase to latest master
  • Please include a short explanation for the rationale for this change (just in a comment in phab on this diff), so I don't forget again the next time it comes up ;)
This revision now requires changes to proceed.Mar 25 2022, 16:52
web/cashtab-v2/config/jest/uint8array-environment.js
1 ↗(On Diff #32948)

Some crypto-related libraries we use often targets nodejs only. They work in the browser because webpack shims them (see webpack config, searching for Buffer, there are others too.)

That doesn't happen on jest 27 when using the JSDOM environment for tests and it was breaking the useWallet test, because of some external libraries causing the hash generated by the HDNode to not being recognized as Uint8Array.

(See: https://github.com/facebook/jest/issues/4422)

So that's why this file is needed, we have a custom environment extending JSDOM environment and binding nodejs Uint8Array/ArrayBuffer to it so we are able to run tests.

This revision is now accepted and ready to land.Mar 25 2022, 17:07
This revision was automatically updated to reflect the committed changes.