I have been writing a bunch of jest assessments just lately for libraries that use the underlying
window.crypto strategies like
window.crypto.delicate key administration strategies. One drawback I run into is that the
window.crypto object is not accessible, so I must shim it.
To make use of the
window.crypto strategies, you have to Node 15+. You may set the
window.crypto by importing the
crypto package deal and setting it on the worldwide:
const crypto = require('crypto').webcrypto; // Shims the crypto property onto world world.crypto = crypto;
I actually detest creating mock capabilities for lacking libraries in Node as a result of they’ll result in defective positives on assessments; I actually recognize
webcrypto being accessible!