[web] Fix missing WebCrypto mock in tests
Summary:
Fixes https://linear.app/comm/issue/ENG-3276/web-unit-tests-mock-missing-webcrypto-apis
There are a few solutions, I decided to go with Jest setupFiles.
Some other solutions on StackOverflow: https://stackoverflow.com/questions/52612122/how-to-use-jest-to-test-functions-using-crypto-or-window-mscrypto - they use Object.defineProperty, but simply assigning the variable does the trick as well.
The crypto.webcrypto is a polyfill introduced in Node 15 that provides compatibility with browser APIs.
Test Plan:
- Run yarn test in web without this change. Tests for text-utils and device-id should fail.
- Apply this diff and re-run tests. All tests should pass.
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: tomek, atul
Differential Revision: https://phab.comm.dev/D7019