Skip to content Skip to sidebar Skip to footer

Jest: How To Globally Mock Node-uuid (or Any Other Imported Module)

Recently migrated from mocha to jest and I'm running into an issue. I have lots of warnings in my tests: [SECURITY] node-uuid: crypto not usable, falling back to insecure Math.rand

Solution 1:

You can define a manual-mock in the [root]/__mocks__/node-uuid.js where [root] is the directory where the node_modules directory is located:

module.exports = { v4: jest.fn(() => 1) }

Post a Comment for "Jest: How To Globally Mock Node-uuid (or Any Other Imported Module)"