UnhandledPromiseRejectionWarning: TypeError: crypto.subtle.digest is not a function

Viewed 213

I am getting "crypto.subtle.digest is not a function" while running unit tests with Jest for a function which uses crypto.subtle.digest() for hashing. I am using JSDOM and I have tried these two options with no luck:

 1. `[How to use Jest to test functions using crypto or window.msCrypto][1]`

    Object.defineProperty(global.self, 'crypto', {
              value: {
                subtle: crypto.subtle,
              }
            });
  1. global.crypto.subtle = {};
0 Answers
Related