The node implementation for expo-random
npm install node-expo-randomThe package node-expo-random provides the same interface of expo-random. So Thus, you can implement mocks that work as expected even in the Node environment.
``typescript
const random = require('node-expo-random');
const bytes = random.getRandomBytes(8);
console.log(bytes); // Uint8Array(8) [5, 169, 234, 152, 41, 248, 121, 197]
`
This package also contains default mocks for Jest testing framework. For details on how to configure, see below.
``
$ npm install --save-dev node-expo-random
In your Jest configuration.
`json``
{
...
"json": {
"setupFilesAfterEnv": [
"node-expo-random/jest-setup.js"
]
}
}