window.crypto is undefined
See original GitHub issuei’m trying to run tests using jsdom and mocha but I got this error:
ReferenceError: crypto is not defined
Is crypto really defined in jsdom?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:19 (2 by maintainers)
Top Results From Across the Web
How to use SubtleCrypto in chrome (window.crypto.subtle is ...
According to the spec (via Github issues) a la this Google page for WebCrypto: crypto.subtle is supposed to be undefined in insecure ...
Read more >self.crypto - Web APIs - MDN Web Docs - Mozilla
The global read-only crypto property returns the Crypto object associated to the global object. This object allows web pages access to ...
Read more >Web Crypto API | Node.js v19.3.0 Documentation
crypto or require('node:crypto').webcrypto to access this module. const { subtle } = globalThis.crypto; (async function() ...
Read more >builtins.Window.crypto JavaScript and Node.js code examples
src/assets/js/helpers.js/undefined/generateRandomString. generateRandomString() { const crypto = window.crypto || window.msCrypto; let array = new ...
Read more >How to Use window.crypto in Node.js - David Walsh Blog
I've been writing a bunch of jest tests recently for libraries that use the underlying window.crypto methods like getRandomValues() and.
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I used
@peculiar/webcrypto
in jestsetupFiles
Seems to be working fine.
If you only require random numbers to be polyfilled, then you can also do
Note: You’ll need Node v10 if you want buffer to be able to be Uint32Array as in v8 only Uint8Array and Buffer are supported