node-expo-random
The 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.
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.
Install
$ npm install --save-dev node-expo-random
Jest configuration
In your Jest configuration.
{
...
"json": {
"setupFilesAfterEnv": [
"node-expo-random/jest-setup.js"
]
}
}